Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@foundernest/namecase
Advanced tools
A fully typed library for fixing capitalization of people's names. Based on tamtamchik PHP library.
NameCase 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.
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, NameCase deals correctly with them.
Currently NameCase 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.
Via npm
npm install @foundernest/namecase
Via yarn
yarn add @foundernest/namecase
import { nameCase } from '@foundernest/namecase';
nameCase('KEITH'); // => Keith
nameCase('LEIGH-WILLIAMS'); // => Leigh-Williams
nameCase('MCCARTHY'); // => McCarthy
nameCase("O'CALLAGHAN"); // => O'Callaghan
nameCase('ST. JOHN'); // => St. John
nameCase('VON STREIT'); // => von Streit
nameCase('AP LLWYD DAFYDD'); // => ap Llwyd Dafydd
nameCase('HENRY VIII'); // => Henry VIII
nameCase('VAN DYKE'); // => van Dyke
You can override the default options by calling the nameCase
function with the EnvironmentOptions
optional parameter:
import { nameCase } from '@foundernest/namecase';
nameCase('macmurdo'); // => MacMurdo
nameCase('macmurdo', { irish: false }); // => Macmurdo
You can also set the options of all the subsequent calls:
import { nameCase, setOptions } from '@foundernest/namecase';
nameCase('macmurdo'); // => MacMurdo
setOptions({ irish: false });
nameCase('macmurdo'); // => Macmurdo
Or you can even create a new Environment
object with custom options:
import Environment from '@foundernest/namecase';
const ncEnv = new Environment({
lazy: false
roman: false
});
ncEnv.nameCase('Na li'); // => Na Li
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
.import { excludePostNominals, nameCase } from '@foundernest/namecase';
nameCase('ČERNÝ MOST'); // Černý MOst
excludePostNominals('MOst');
nameCase('ČERNÝ MOST'); // Černý Most
Please see CHANGELOG for more information about what has changed recently.
yarn test
Please see the Contributing guide and Code of Conduct for details.
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.
Original PERL Lingua::EN::NameCase
Version:
Ruby Version:
PHP Version:
Typescript version:
The MIT License (MIT). Please see License File for more information.
FAQs
A fully typed library for fixing capitalization of people's names. Based on tamtamchik PHP library.
The npm package @foundernest/namecase receives a total of 3,229 weekly downloads. As such, @foundernest/namecase popularity was classified as popular.
We found that @foundernest/namecase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.