0.1.8 • Published 9 years ago

format-phone-swedish v0.1.8

Weekly downloads
84
License
MIT
Repository
github
Last release
9 years ago

format-phone-swedish

Module for formatting strings to Swedish phone numbers. For international phone numbers use format-phone instead.

Supports traditional grouping of telephone numbers. All two, three, and four digit area codes are supported as well.

Will remove +46 prefix code if present.

Installation

Use npm:

npm install --save format-phone-swedish

API

format-phone-swedish.format

(number: String, separator?: String) => String
ParamDescription
number: StringInput telephone number
separator?: StringThe separator character to use. Default is " "

Takes a phone number-like string and formats it to traditional Swedish grouping.

Usage

import { format } from "format-phone-swedish"

console.log( format("081234567") )        // => "08 123 45 67"

// Changes the area code separator
console.log( format("081234567", "-") )   // => "08-123 45 67"

// Removes +46 country prefix and extension numbers
console.log( format("+46 (0) 81234567") ) // => "08 123 45 67"

// Adds missing 0
console.log( format("81234567") )         // => "08 123 45 67"

// Supports number grouping for numbers without area codes
console.log( format("112") )              // => "112"
console.log( format("1177") )             // => "1177"
console.log( format("11414") )            // => "114 14"
console.log( format("123 456") )          // => "12 34 56"
console.log( format("1234567") )          // => "123 45 67"
console.log( format("12345678") )         // => "123 456 78"

License

MIT, Read more at the LICENSE file.

0.1.8

9 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago