Skip to content

Commit

Permalink
Convert CJS to esm module
Browse files Browse the repository at this point in the history
  • Loading branch information
dhershman1 committed Aug 17, 2023
1 parent 33bd1f3 commit 3f03b5f
Show file tree
Hide file tree
Showing 15 changed files with 12,260 additions and 4,615 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '33 17 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![npm](https://img.shields.io/npm/v/phone-fns.svg?style=flat-square)](https://www.npmjs.com/package/phone-fns)
[![CircleCI](https://circleci.com/gh/dhershman1/phone-fns.svg?style=svg)](https://circleci.com/gh/dhershman1/phone-fns)
[![codecov](https://codecov.io/gh/dhershman1/phone-fns/branch/master/graph/badge.svg)](https://codecov.io/gh/dhershman1/phone-fns)
[![npm](https://img.shields.io/npm/v/phone-fns.svg?style=flat-square&color=%23bef9c6)](https://www.npmjs.com/package/phone-fns)
![License (MIT)](https://img.shields.io/badge/license-mit-green.svg?style=flat-square&color=%23bef9c6)
![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/dhershman1/phone-fns/phone-fns.yml?style=flat-square&logo=github)
[![Netlify Status](https://api.netlify.com/api/v1/badges/9a96c817-73dc-40c9-b052-c855397cf2c1/deploy-status)](https://app.netlify.com/sites/phone-fns/deploys)

# Phone Fns

Expand All @@ -17,25 +18,42 @@ npm i phone-fns
Standard module system

```js
import phoneFns from 'phone-fns'
import * as phoneFns from 'phone-fns'

phoneFns.uglify('555-444-3333') // => '5554443333'
```

Common JS

```js
const phoneFns = require('phone-fns')

phoneFns.uglify('555-444-3333') // => '5554443333'
```

Using Unpkg or jsdelivr CDN (As of v4.0.0+)

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phone-fns.iife.min.js"></script>
<script>
phoneFns.uglify('555-444-3333') // => '5554443333'
</script>
```


Through the browser

```html
<script src="path/to/location/dist/phone-fns.min.js"></script>
<script src="path/to/location/dist/phone-fns.iife.min.js"></script>
<script>
phoneFns.uglify('555-444-3333') // => '5554443333'
</script>
```

## Usage

```javascript
import phoneFns from 'phone-fns'
import * as phoneFns from 'phone-fns'

phoneFns.breakdown('4443332222')
// => { areaCode: '444', localCode: '333', lineNumber: '2222', extension: '' }
Expand Down
20 changes: 20 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## v4.0.0

### Breaking Changes

- Converted Phone-Fns to a standard ESM module
- This means if you are using import statements in an ESM module for phone-fns this changes:
- `import phoneFns from 'phone-fns'` --> `import * as phoneFns from 'phone-fns'`
- You can also just destructure from here still like so: `import { isValid } from 'phone-fns'`
- Phone fns should still support common js syntax out of the box as well
- Upgraded to `Kyanite v2.0.1`

### New

- CDN support sould be working for phone-fns again
- Updated README to reflect these changes

### Improved

- Made typings less confusing

## v3.2.5

### :confetti_ball: Enhanced
Expand Down
Loading

0 comments on commit 3f03b5f

Please sign in to comment.