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

name-fixer

v1.0.1

Published

A fully typed library for fixing capitalization of people's names. Based on tamtamchik PHP library.

Downloads

5,290

Readme

name-fixer

npm Node.js CI Coverage Status npm bundle size

name-fixer is a fully typed implementation of Lingua::EN::NameCase, a library for converting strings to be properly cased. This is good for converting denormalized data to human friendly data.

NOTE: This is a fork from the discontinued library @foundernest/namecase. I was the author but I don't work in that company anymore. I still wanted to continue improving the library.

Description

Forenames and surnames are often stored either entirely in UPPERCASE or lowercase. This library allows you to convert names into the correct case where possible. Although forenames and surnames are typically stored separately if they do appear in a single string, whitespace-separated, name-fixer deals correctly with them.

Currently name-fixer correctly name cases names which include any of the following:

Mc, Mac, al, el, ap, bat, ben, bin, binti, binte, da, de, das, dos, delle, della, di, du, del, der, den, ten, ter, la, le, lo, van and von.

It correctly deals with names which contain apostrophes and hyphens too.

Installation

Via npm

npm install name-fixer

Via yarn

yarn add name-fixer

Via pnpm

pnpm add name-fixer

Usage

Basic usage

import { nameFixer } from 'name-fixer';

nameFixer('KEITH');               // => Keith
nameFixer('LEIGH-WILLIAMS');      // => Leigh-Williams
nameFixer('MCCARTHY');            // => McCarthy
nameFixer("O'CALLAGHAN");         // => O'Callaghan
nameFixer('ST. JOHN');            // => St. John
nameFixer('VON STREIT');          // => von Streit
nameFixer('AP LLWYD DAFYDD');     // => ap Llwyd Dafydd
nameFixer('HENRY VIII');          // => Henry VIII
nameFixer('VAN DYKE');            // => van Dyke

Advance usage

You can override the default options by calling the nameFixer function with the EnvironmentOptions optional parameter:

import { nameFixer } from 'name-fixer';

nameFixer('macmurdo');                        // => MacMurdo
nameFixer('macmurdo', { irish: false });      // => Macmurdo

You can also set the options of all the subsequent calls:

import { nameFixer, setOptions } from 'name-fixer';

nameFixer('macmurdo');               // => MacMurdo
setOptions({ irish: false });
nameFixer('macmurdo');               // => Macmurdo

Or you can even create a new Environment object with custom options:

import Environment from 'name-fixer';

const ncEnv = new Environment({
  lazy: false
  roman: false
});

ncEnv.nameFixer('Na li');     // => Na Li

Options

  • lazy – Default: true. Do not do anything if string is already mixed case and lazy option is true.
  • irish – Default: true. Correct "Mac" exceptions.
  • spanish – Default: true. Correct spanish conjunctions y, e or i.
  • roman – Default: true. Correct roman numbers.
  • hebrew – Default: true. Correct ben, bat.
  • postNominal – Default: true. Correct post-nominal. e.g. PhD.

Exclude Post-Nominals

import { excludePostNominals, nameFixer } from 'name-fixer';

nameFixer('ČERNÝ MOST');         // Černý MOst
excludePostNominals('MOst');
nameFixer('ČERNÝ MOST');         // Černý Most

Changelog

Please see CHANGELOG for more information about what has changed recently.

Testing

pnpm test

Contributing

Please see the Contributing guide and Code of Conduct for details.

Acknowledgements

This library is a port of the PHP package by Yuri Tkachenko which is also a port of the Perl library and owes most of its functionality to the Perl version by Mark Summerfield. Any bugs in the Typescript port are my fault.

Credits

Original PERL Lingua::EN::NameCase Version:

  • Copyright © Mark Summerfield 1998-2014. All Rights Reserved.
  • Copyright © Barbie 2014-2020. All Rights Reserved.

Ruby Version:

  • Copyright © Aaron Patterson 2006. All Rights Reserved.

PHP Version:

  • Copyright © Yuri Tkachenko 2016-2020. All Rights Reserved.

Typescript version:

NOTE: This is a fork from foundernest/namecase since I don't work there anymore but I still wanted to continue improving the library.

License

The MIT License (MIT). Please see License File for more information.