New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chorkaichan/jp-phone-parser

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chorkaichan/jp-phone-parser

A module parses numbers according to the Japanese phone number pattern.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JP Phone Parser

A module parses numbers according to the Japanese phone number pattern.

Tests npm downloads

Installation

via npm

npm install @chorkaichan/jp-phone-parser --save
// CommonJS
const phoneParser = require('@chorkaichan/jp-phone-parser');
// ES modules
import phoneParser from '@chorkaichan/jp-phone-parser';
<script src="https://cdn.jsdelivr.net/npm/@chorkaichan/jp-phone-parser/dist/jp-phone-parser.min.js"></script>

direct download

curl -o https://cdn.jsdelivr.net/npm/@chorkaichan/jp-phone-parser/dist/jp-phone-parser.min.js
<script src="/path/to/jp-phone-parser.min.js"></script>

Usage

// 03-* (Tokyo)
console.log(phoneParser('0')) // '0'
console.log(phoneParser('03')) // '03'
console.log(phoneParser('031')) // '03-1'
console.log(phoneParser('0312345')) // '03-1234-5'
console.log(phoneParser('0312345678')) // '03-1234-5678'

// 05979-* (Kumano, Mie)
console.log(phoneParser('05979')) // '05979'
console.log(phoneParser('059792')) // '05979-2'
console.log(phoneParser('0597921')) // '05979-2-1'
console.log(phoneParser('0597921234')) // '05979-2-1234'

// 090-* (mobile)
console.log(phoneParser('0901')) // '090-1'
console.log(phoneParser('09010012')) // '090-1001-2'
console.log(phoneParser('09010012345')) // '090-1001-2345'

// 0200-* (for data transmission)
console.log(phoneParser('02001')) // '0200-1'
console.log(phoneParser('02001000012345')) // '0200-10000-12345'

// change delimiter
console.log(phoneParser('0312345678', ' ')) // '03 1234 5678'

// type-safe
console.log(phoneParser('')) // ''
console.log(phoneParser(null)) // ''
console.log(phoneParser(undefined)) // ''
console.log(phoneParser(123456)) // ''

License

This project is licensed under MIT license.

Keywords

FAQs

Package last updated on 26 Jan 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc