Skip to content

A Javascript library for fixing the capitalization of people's names.

License

Notifications You must be signed in to change notification settings

compwright/namecase

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@compwright/namecase

Build Status

A Javascript library for fixing the capitalization of people's names.

It is heavily based on the Perl Lingua-EN-NameCase module.

Usage

namecase provides two functions:

nameCase.checkName() which returns true if the name is in all UPPERCASE or lowercase.

nameCase(string or array, { individualFields: boolean }) returns a properly capitalized name.

The option individualFields defaults to false which works best when the person's names are combined into a single field. If individualFields is set to true, it means you're passing in given and surnames separately. The only difference between these two options is with individualFields set to false, the first character is always capitalized.

Namecase can also be executed from the command line via namecase, which accepts data from STDIN and outputs the formatted names to STDOUT.

Usage Examples

Browser

<script src="https://unpkg.com/@compwright/namecase@latest/dist/namecase.min.js"></script>
<script>
  console.log(window.namecase('GEORGE WASHINGTON'));
</script>

Node

const nameCase = require('@compwright/namecase');
console.log(nameCase('WILLIAM MCKINLEY'));

Command line

$ npm install -g @compwright/namecase
$ namecase < input.txt > ouput.txt

About

A Javascript library for fixing the capitalization of people's names.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • JavaScript 100.0%