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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@intl-phone-js/core

v0.7.0

Published

Headless international phone input engine with smart masking, validation and country auto-detection powered by libphonenumber-js.

Downloads

695

Readme

@intl-phone-js/core

@intl-phone-js/core is a headless phone number state engine focused on parsing, normalization, and validation for international numbers.

It is built on top of libphonenumber-js, a widely used JavaScript implementation inspired by Google's libphonenumber.

NPM: https://www.npmjs.com/package/@intl-phone-js/core


Summary

  • Headless phone state manager for international numbers
  • Powered by libphonenumber-js
  • No UI, no DOM, no event binding
  • Framework-agnostic and runtime-agnostic

Features

  • International phone normalization
  • Automatic country detection
  • Phone validation
  • Country helpers
  • Runtime configuration
  • Framework agnostic

Installation

npm install @intl-phone-js/core
<script src="https://unpkg.com/@intl-phone-js/core/dist/index.global.min.js"></script>
<script>
  const phone = new IntlPhoneJS.IntlPhoneCore();
  phone.setValue("+5511999999999");
  console.log(phone.getState());
</script>
<script type="module">
  import { IntlPhoneCore } from "https://unpkg.com/@intl-phone-js/core/dist/index.js";

  const phone = new IntlPhoneCore();
  phone.setValue("+5511999999999");
  console.log(phone.getState());
</script>

Basic Usage

import { IntlPhoneCore } from "@intl-phone-js/core";

const phone = new IntlPhoneCore();

console.log("initial:", phone.getState());

phone.setValue("11999999999");
console.log("after local value:", phone.getState());

phone.setValue("+5511999999999");
const state = phone.getState();

console.log("after intl value:", state);
console.log("formatted:", state.formatted);
console.log("country:", state.country);
console.log("e164:", state.e164);

Using Initial Value

import { IntlPhoneCore } from "@intl-phone-js/core";

const phone = new IntlPhoneCore({
  value: "+12025550123",
});

console.log(phone.getState());

Programmatic Control

import { IntlPhoneCore } from "@intl-phone-js/core";

const phone = new IntlPhoneCore();

phone.setValue("+351912345678");
phone.setCountry("US");
phone.reset();

Configuration

import { IntlPhoneCore } from "@intl-phone-js/core";

const phone = new IntlPhoneCore({
  allowedCountries: ["BR", "US"],
});

phone.setOptions({ allowedCountries: ["US"] });

const options = phone.getOptions();
console.log(options);

Reading State

import { IntlPhoneCore } from "@intl-phone-js/core";

const phone = new IntlPhoneCore();
phone.setValue("+5511999999999");

console.log(phone.getState());
console.log(phone.getCountry());
console.log(phone.getCallingCode());
console.log(phone.getE164());

Validation

import { IntlPhoneCore } from "@intl-phone-js/core";

const phone = new IntlPhoneCore();
phone.setValue("+5511999999999");

console.log(phone.isValid());
console.log(phone.isPossible());
console.log(phone.getValidationReason());

ValidationReason:

  • EMPTY
  • INVALID_COUNTRY
  • TOO_SHORT
  • TOO_LONG
  • NOT_POSSIBLE
  • VALID

Country Helpers

import {
  getAllCountries,
  getCountryName,
  getAllCountriesWithNames,
} from "@intl-phone-js/core";

const countries = getAllCountries();
const brazilName = getCountryName("BR");
const countriesWithNames = getAllCountriesWithNames();

console.log(countries[0], brazilName, countriesWithNames[0]);

Phone State

getState() returns:

type PhoneState = {
  rawInput: string;
  formatted: string;
  value: string;
  country: string | null;
  callingCode: string | null;
  nationalNumber: string | null;
  e164: string | null;
  isValid: boolean;
  isPossible: boolean;
};

Public API

State

  • getState()
  • getValue()
  • getRawInput()
  • getCountry()
  • getCallingCode()
  • getE164()

Validation

  • isValid()
  • isPossible()
  • getValidationReason()

Mutations

  • setValue(value)
  • setCountry(countryCode)
  • reset()

Configuration

  • setOptions(options, reprocess?)
  • getOptions()

Headless Philosophy

This core does not include:

  • UI
  • Dropdowns
  • Flags
  • Styling
  • Event binding

Use IntlPhoneCore as the base layer for platform-specific adapters.


License

MIT