Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

phone-fns

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phone-fns - npm Package Compare versions

Comparing version 3.2.3 to 4.0.0

dist/phone-fns.iife.min.js

35

changelog.md
# 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
- Added: New github flows and files
## v3.2.4
### Improved
- Audited packaged
- Replaced `tap-spec` with `tap-on`
- Optimized ignore files
- Removed dist from repo
## v3.2.3

@@ -4,0 +39,0 @@

2

dist/phone-fns.min.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("kyanite")):"function"==typeof define&&define.amd?define(["exports","kyanite"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).phoneFns={},e.kyanite)}(this,(function(e,t){"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(r=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var o=t.compose(t.replace(/[a-z]\w?|\W/gi,""),String),i=function(e){var t=n(o(e).match(/([_0-9]{3})?([_0-9]{3})([_0-9]{4})([_0-9]{1,})?/),5),r=t[1],i=t[2],u=t[3],a=t[4];return{areaCode:r,localCode:i,lineNumber:u,extension:void 0===a?"":a}};function u(e){return function(){var n=i(e),r=n.localCode,o=n.lineNumber;return t.test(/^([0-9]{3})[-. ]?([0-9]{4})$/,r+o)}}function a(e){return function(){var n=i(e),r=n.areaCode,o=n.localCode,u=n.lineNumber;return t.test(/^\+?([0-9]{2})\)?[-. ]?([0-9]{4})[-. ]?([0-9]{4})$/,r+o+u)}}var c,l=function(e){var n=o(e),r=t.compose(t.reduced);return t.pipe([t.when(t.isEmpty,r(t.F)),t.length,t.when(t.lt(7),r(t.F)),t.when(t.eq(7),u(n)),a(n)],n)},f=(c=function(e,n){var r=t.includes("C",e)?t.length(e.match(/C/g)):0,i=t.addIndex(t.reduce);return t.branch(t.both(t.complement(l),t.complement(function(e){return function(n){var r=t.compose(t.countBy(t.toUpper),t.split(""),e),i=r.N,u=r.C,a=void 0===u?0:u;return t.pipe([o,t.length,t.eq(t.add(i,a))],n)}}(e))),t.identity,t.pipe([o,t.split(""),i((function(e,n,o){return t.gt(o,r)?t.replace(/C/i,e,n):t.replace(/N/i,e,n)}),e)]),n)},function e(t,n){return arguments.length?1===arguments.length?function(e){return c(t,e)}:c(t,n):e});e.breakdown=i,e.format=f,e.isValid=l,e.uglify=o,Object.defineProperty(e,"__esModule",{value:!0})}));
import{compose as r,replace as n,reduced as t,pipe as e,when as o,isEmpty as u,F as i,length as a,lt as l,eq as c,test as f,includes as m,addIndex as y,reduce as v,branch as d,both as s,complement as b,identity as h,split as g,gt as p,countBy as C,toUpper as A,add as S}from"kyanite";function j(r,n){return function(r){if(Array.isArray(r))return r}(r)||function(r,n){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,o,u,i,a=[],l=!0,c=!1;try{if(u=(t=t.call(r)).next,0===n){if(Object(t)!==t)return;l=!1}else for(;!(l=(e=u.call(t)).done)&&(a.push(e.value),a.length!==n);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}(r,n)||function(r,n){if(!r)return;if("string"==typeof r)return w(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);"Object"===t&&r.constructor&&(t=r.constructor.name);if("Map"===t||"Set"===t)return Array.from(r);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return w(r,n)}(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}var N=r(n(/[a-z]\w?|\W/gi,""),String);function O(r){var n=j(N(r).match(/([_0-9]{3})?([_0-9]{3})([_0-9]{4})([_0-9]{1,})?/),5),t=n[1],e=n[2],o=n[3],u=n[4];return{areaCode:t,localCode:e,lineNumber:o,extension:void 0===u?"":u}}function _(r){return function(){var n=O(r),t=n.localCode,e=n.lineNumber;return f(/^([0-9]{3})[-. ]?([0-9]{4})$/,t+e)}}function x(r){return function(){var n=O(r),t=n.areaCode,e=n.localCode,o=n.lineNumber;return f(/^\+?([0-9]{2})\)?[-. ]?([0-9]{4})[-. ]?([0-9]{4})$/,t+e+o)}}function I(n){var f=N(n),m=r(t);return e([o(u,m(i)),a,o(l(7),m(i)),o(c(7),_(f)),x(f)],f)}var $,k=($=function(t,o){var u=m("C",t)?a(t.match(/C/g)):0,i=y(v);return d(s(b(I),b(function(n){return function(t){var o=r(C(A),g(""),n),u=o.N,i=o.C;return e([N,a,c(S(u,void 0===i?0:i))],t)}}(t))),h,e([N,g(""),i((function(r,t,e){return p(e,u)?n(/C/i,r,t):n(/N/i,r,t)}),t)]),o)},function r(n,t){return arguments.length?1===arguments.length?function(r){return $(n,r)}:$(n,t):r});export{O as breakdown,k as format,I as isValid,N as uglify};
{
"name": "phone-fns",
"version": "3.2.3",
"version": "4.0.0",
"description": "A small, modern, and functional phone library for javascript",

@@ -8,23 +8,28 @@ "main": "dist/phone-fns.min.js",

"typings": "types/index.d.ts",
"type": "module",
"unpkg": "dist/phone-fns.iife.min.js",
"jsdelivr": "dist/phone-fns.iife.min.js",
"scripts": {
"prepack": "npm run scripts && rollup -c",
"scripts": "npm run docs && node scripts/create-export.js",
"prepack": "npm-run-all --parallel docs scripts lint test --serial build",
"scripts": "node scripts/create-export.js",
"docs": "node_modules/.bin/jsdoc -c jsdoc.json",
"docs:deploy": "gh-pages -m 'auto commit [ci skip]' --dist docs",
"docs:test": "gh-pages -m 'auto commit [ci skip]' --dist docs --branch gh-pages",
"build": "rollup -c",
"lint": "standard src/**/*.js",
"test": "tape -r esm tests/*.js | tap-spec",
"test:cov": "nyc npm test",
"check-cov": "nyc check-coverage --lines 90 --functions 100 --branches 90",
"report": "nyc report --reporter=text-lcov > coverage.lcov"
"test": "tape tests/*.js | tap-on"
},
"nyc": {
"include": [
"src/**"
],
"exclude": [
"src/index.js",
"tests/**"
]
"exports": {
".": {
"require": {
"types": "./types/index.d.cts",
"default": "./dist/phone-fns.min.cjs"
},
"import": {
"types": "./types/index.d.ts",
"default": "./dist/phone-fns.min.js"
},
"default": {
"types": "./types/index.d.ts",
"default": "./dist/phone-fns.iife.min.js"
}
}
},

@@ -52,2 +57,4 @@ "standard": {

"phone-fns",
"telephone",
"tel",
"functional library",

@@ -61,23 +68,20 @@ "formatting",

"devDependencies": {
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@rollup/plugin-babel": "^5.2.1",
"esm": "3.2.25",
"gh-pages": "3.1.0",
"globby": "11.0.1",
"jsdoc": "3.6.5",
"npm-run-all": "^4.1.5",
"nyc": "15.1.0",
"pinet": "1.0.0",
"rollup": "2.33.3",
"rollup-plugin-cleanup": "3.2.1",
"rollup-plugin-filesize": "9.0.2",
"rollup-plugin-terser": "7.0.2",
"standard": "16.0.3",
"tap-spec": "5.0.0",
"tape": "5.0.1"
"@babel/core": "7.22.10",
"@babel/preset-env": "7.22.10",
"@rollup/plugin-babel": "6.0.3",
"@rollup/plugin-node-resolve": "^15.2.0",
"@rollup/plugin-terser": "0.4.3",
"globby": "13.2.2",
"jsdoc": "4.0.2",
"npm-run-all": "4.1.5",
"pinet": "1.1.4",
"rollup": "3.28.0",
"rollup-plugin-filesize": "10.0.0",
"standard": "17.1.0",
"tap-on": "0.3.1",
"tape": "5.6.6"
},
"dependencies": {
"kyanite": "1.4.2"
"kyanite": "2.0.1"
}
}

@@ -1,4 +0,18 @@

[![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)
<p align=center>
<a href="./LICENSE">
<img
alt="license:mit"
src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square&color=%23bef9c6"
/>
</a>
<a href="https://phone-fns.dusty.codes/">
<img alt="Netlify Status" src="https://api.netlify.com/api/v1/badges/9a96c817-73dc-40c9-b052-c855397cf2c1/deploy-status">
</a>
<a href="https://www.npmjs.com/package/phone-fns">
<img alt="Npm Version" src="https://img.shields.io/npm/v/phone-fns.svg?style=flat-square&color=%23bef9c6">
</a>
<a href="https://github.com/dhershman1/kyanite/actions/workflows/kyanite.yml">
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/dhershman1/phone-fns/phone-fns.yml?style=flat-square&logo=github">
</a>
</p>

@@ -20,3 +34,5 @@ # Phone Fns

```js
import phoneFns from 'phone-fns'
import * as phoneFns from 'phone-fns'
phoneFns.uglify('555-444-3333') // => '5554443333'
```

@@ -28,8 +44,23 @@

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/phone-fns@4.0.0/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>
```

@@ -40,3 +71,3 @@

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

@@ -43,0 +74,0 @@ phoneFns.breakdown('4443332222')

@@ -1,2 +0,2 @@

import uglify from './uglify'
import uglify from './uglify.js'

@@ -27,3 +27,3 @@ /**

*/
const breakdown = phone => {
export default function breakdown (phone) {
const [, areaCode, localCode, lineNumber, extension = ''] = uglify(phone)

@@ -39,3 +39,1 @@ .match(/([_0-9]{3})?([_0-9]{3})([_0-9]{4})([_0-9]{1,})?/)

}
export default breakdown

@@ -20,5 +20,5 @@ import {

} from 'kyanite'
import _curry2 from './_internals/_curry2'
import isValid from './isValid'
import uglify from './uglify'
import _curry2 from './_internals/_curry2.js'
import isValid from './isValid.js'
import uglify from './uglify.js'

@@ -31,10 +31,12 @@ /**

*/
const validFormat = layout => phone => {
const { N, C = 0 } = compose(countBy(toUpper), split(''), layout)
function validFormat (layout) {
return phone => {
const { N, C = 0 } = compose(countBy(toUpper), split(''), layout)
return pipe([
uglify,
length,
eq(add(N, C))
], phone)
return pipe([
uglify,
length,
eq(add(N, C))
], phone)
}
}

@@ -68,3 +70,3 @@

*/
const format = (layout, phone) => {
function format (layout, phone) {
const cCount = includes('C', layout) ? length(layout.match(/C/g)) : 0

@@ -71,0 +73,0 @@ const _reduce = addIndex(reduce)

import { compose, when, F, reduced, eq, isEmpty, length, lt, pipe, test } from 'kyanite'
import breakdown from './breakdown'
import uglify from './uglify'
import breakdown from './breakdown.js'
import uglify from './uglify.js'

@@ -48,3 +48,3 @@ /**

*/
const isValid = phone => {
export default function isValid (phone) {
const uglyPhone = uglify(phone)

@@ -61,3 +61,1 @@ const done = compose(reduced)

}
export default isValid

@@ -1,10 +0,5 @@

// Type definitions for Phone-Fns v3.0.0
// Type definitions for Phone-Fns
// Project: Phone-Fns
// Definitions by: Dustin Hershman <dustinh17@gmail.com>
/// <reference path="./breakdown.d.ts" />
/// <reference path="./format.d.ts" />
/// <reference path="./isValid.d.ts" />
/// <reference path="./uglify.d.ts" />
declare let phoneFns: phoneFns.Static;

@@ -40,3 +35,3 @@

*/
uglify(phone: string): string;
uglify(phone: string|number): string;
}

@@ -43,0 +38,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc