npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cubaprovincias

v1.0.0

Published

Cuba's province, by telephone's local prefix

Downloads

2

Readme

What is «cubaprovincias»

This is a Cuban phone number's parser utility for nodejs.

Very useful, not only for work with phone numbers, also, if need Cuban provinces as uniform data. For example: "choose region from the list", while database has a number field named «province».

Install

Install is pretty difficult because is completely different to the common way. (sarcasm)

npm install cubaprovincias

If everything was fine, you should have cubaprovincias recorded in you storage device. Search for the string «cubaprovincias» in your package.json and node_modules directory.

Warning: No more jokes after the below line

Usage

I prefer call «CubanNumber» to instances, because work with phone numbers (almost the time).

// call «CubanNumber» to instances, because work with phone numbers
const CubanNumber = require('cubaprovincias')

// or if you does not need phone number framework
const Provinces = require('cubaprovincias').prototype.provinces

Provinces and Prefix

Does you need prefix-province relation? That info your are looking for, is just an {} in the class.

const Provinces = require('cubaprovincias').prototype.provinces
Provinces[7] // 'La Habana'
Provinces[24] // 'Holguín'
Provinces[32] // 'Camagüey'

Prefix number 5, is reserved for cell phone numeration in Cuba.

Provinces[5] // '(Cell Phone)'

Parsing a phone number.

Processing a number means "get their local dialing prefix and province name", regardless input format. Assuming "input" is a common fancy format but not your own weird custom format.

// load it
const CubanNumber = require('cubaprovincias')

// working with a cell phone
let number = new CubanNumber('+53 (5) 234 56-78')
number.getPrefix() // 5
number.getProvince() // '(Cell Phone)'
number.flatNumber() // '52345678'


// reverse payment incoming number
// (just like is displayed in the caller id)
let incoming = new CubanNumber('99535270405099')
entrante.getProvince() // '(Cell Phone)'
entrante.flatNumber() // '52704050'

// reverse payment outgoing number
// *99 prefixed when you are dialing
let dialing = new CubanNumber('*9952704050')
dialing.getProvince() // '(Cell Phone)'
dialing.flatNumber() // '52704050'


// Havana number, with  international prefix, +53 or 00
// no matter how fancy writing, it can be converted to local number
(new CubanNumber('007 [870] 3344')).flatNumber() // '78703344'
(new CubanNumber('+53 (7) 870 33-44')).flatNumber() // '78703344'


// a number with international dialing prefix, get province name
(new CubanNumber('+53 (7) 870 33-44')).getProvince() // 'La Habana'

// get the local dialing prefix as number
// Warning, it RETURNS a Number (NOT a String)
(new CubanNumber('007 [870] 3344')).getPrefix() // 7


// a number from Artemisa (or Mayabeque) just like you dial it
// from fixed phones. Note that, 47 represents both provinces
// Mayabeque and Artemisa, so, I'm using «/» to represent that duality.
(new CubanNumber('047-876-123')).getProvince() // 'Mayabeque/Artemisa'

That's all.