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

name-intl

v3.0.1

Published

A JS helper for formatting names of persons according to locale.

Downloads

46

Readme

name-intl

A small JavaScript/TypeScript helper for formatting person names based on locale conventions.

name-intl gives you:

  • sensible defaults for common locales
  • simple formatting for first/last names
  • full formatting with prefix/middle/suffix
  • custom locale definitions
  • callback-based custom formatters

Installation

npm install name-intl

Quick Start

import nameintl from "name-intl";

const client = nameintl("en-US");

console.log(client.formatSimple("Avneet", "Sunner"));
// Avneet Sunner

console.log(client.formatName("Mr.", "Avneet", "Singh", "Sunner", "Sr"));
// Mr. Avneet Singh Sunner, Sr

Default Locales

The package includes built-in conventions for:

  • en-US
  • en-CA
  • en-PH
  • zh-TW
  • zh-CN

If a locale is not defined, formatting falls back to en-US.

API

nameintl(locale?: string): Client

Creates and returns a Client instance.
Default locale is en-US.

Client

formatSimple(personal: string, family: string): string

Formats a simple two-part name.

formatName(prefix: string, personal: string, middle: string, family: string, suffix: string): string

Formats a full name with optional prefix, middle, and suffix.

define(locale: string, conventionDefinition: NamePart[]): void

Adds or overrides a locale convention.

defineCustom(locale: string, action: CallableFunction): void

Registers a custom formatter callback for a locale.

Exported Types and Enums

You can also import:

  • Client
  • NamePart
  • NameTypes
  • MissingNameRules
  • IDefinitions
  • getStandardDefinitions

Custom Locale Definition

import nameintl, { NameTypes, MissingNameRules } from "name-intl";

const client = nameintl("en-XX");

client.define("en-XX", [
  {
    Order: 0,
    Type: NameTypes.Preffix,
    BeforeSeparator: "",
    AfterSeparator: "",
    MissingNameRule: MissingNameRules.DontShowEmptySpace,
    MissingNameRuleCustom: null,
  },
  {
    Order: 2,
    Type: NameTypes.Personal,
    BeforeSeparator: "",
    AfterSeparator: "",
    MissingNameRule: MissingNameRules.DontShowEmptySpace,
    MissingNameRuleCustom: null,
  },
  {
    Order: 3,
    Type: NameTypes.Middle,
    BeforeSeparator: "",
    AfterSeparator: "",
    MissingNameRule: MissingNameRules.DontShowEmptySpace,
    MissingNameRuleCustom: null,
  },
  {
    Order: 1,
    Type: NameTypes.Family,
    BeforeSeparator: "",
    AfterSeparator: " Separator ",
    MissingNameRule: MissingNameRules.DontShowEmptySpace,
    MissingNameRuleCustom: null,
  },
  {
    Order: 4,
    Type: NameTypes.Suffix,
    BeforeSeparator: "",
    AfterSeparator: "",
    MissingNameRule: MissingNameRules.DontShowEmptySpace,
    MissingNameRuleCustom: null,
  },
]);

console.log(client.formatSimple("Avneet", "Sunner"));
// Sunner Separator Avneet

Custom Formatter Callback

import nameintl from "name-intl";

const client = nameintl("en-XX");

client.defineCustom(
  "en-XX",
  (prefix: string, personal: string, middle: string, family: string, suffix: string) => {
    return `Bla: ${personal}${family}`;
  }
);

console.log(client.formatName("", "Avneet", "", "Sunner", ""));
// Bla: AvneetSunner

Development

npm install
npm run build
npm test

Available scripts:

  • npm run build - build ESM, CJS, and type declarations with tsup
  • npm test - run tests using Node test runner + tsx
  • npm run prepublishOnly - run build and tests before publish