Socket
Socket
Sign inDemoInstall

phone-fns

Package Overview
Dependencies
1
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    phone-fns

A small, modern, and functional phone library for javascript


Version published
Maintainers
1
Install size
334 kB
Created

Changelog

Source

v3.0.0

Breaking Changes

  • Removed find function since it was rather pointless
  • Removed match function since it was rather pointless
  • The main import is no longer a function but an object of functions
  • Re wrote how format works so it's easier to use and more light weight
    • Specify country code in the layout with C. Example: C + (NNN) NNN-NNNN
    • Usage example: format('C + (NNN) NNN-NNNN', 14445556666) // => '1 + (444) 555-6666'
  • breakdown no longer handles or accepts country codes
    • Technically the only function that cares about Country Codes is the format function this is to make functions easier to use
  • Scrapped modular functions
    • There is no need for this anymore, since Rollup & webpack v2+ treeshaking support curried functions, destructing works much better now

New

  • Documentation was moved onto a more sustainable location for quicker and more up to date docs, should be hosted via github pages now too

Improved

  • Using Kyanite to improve how format functions and better currying from the library
  • Replaced uglify-js with terser for performance gains
  • isValid optimizations using Kyanite
  • Overall documentation system should be built directly into its own page now
  • Added Typing declarations for TS and vscode IDE support

Readme

Source

npm David Travis Coverage Status

Phone Fns

A small modern, and functional phone number library which gathers inspiration from the fun date-fns library

How-To

npm i phone-fns

Standard module system

import phoneFns from 'phone-fns'

Common JS

const phoneFns = require('phone-fns')

CDN

<!-- It is recommended to replace the @latest with a strict version number for production -->
<script src="https://cdn.jsdelivr.net/npm/phone-fns@latest/dist/phone-fns.min.js"></script>

Through the browser

<script src="path/to/location/dist/phone-fns.min.js"></script>

Usage

import phoneFns from 'phone-fns'

phoneFns.breakdown('4443332222')
// => { areaCode: '444', localCode: '333', lineNumber: '2222', extension: '' }

phoneFns.format('(NNN) NNN-NNNN', '4443332222')
// => '(444) 333-2222'

You can also destructure to only use the functions you want

import { breakdown, format } from 'phone-fns'

breakdown('4443332222')
// => { areaCode: '444', localCode: '333', lineNumber: '2222', extension: '' }

format('(NNN) NNN-NNNN', '4443332222')
// => '(444) 333-2222'

Keywords

FAQs

Last updated on 16 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc