Socket
Socket
Sign inDemoInstall

namecase

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

namecase

Module for fixing capitalization of people's names


Version published
Weekly downloads
4K
increased by0.92%
Maintainers
1
Weekly downloads
 
Created
Source

NameCase

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

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

It's always best to let the user capitalize their own name as there are too many variations to programmatically catch them all. However, when working with legacy databases, sometimes such a module is needed.

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.

Examples

Browser

<script source="namecase.js"></script>

<script>

  var name = "GEORGE WASHINGTON";

  if (NameCase.checkName(name)) {
    document.write(
      NameCase(name)
    );
  } else {
    document.write(name);
  }

</script>

Node

var nc = require('namecase');

String.prototype.toNameCase = function () {
  var name = this.toString();

  if (nc.checkName(name)) {
    return nc(name, { individualFields : true } );
  }
}

console.log("WILLIAM".toNameCase());
console.log("MCKINLEY".toNameCase());

Command line

Install with npm install -g namecase.

namecase < input.txt > ouput.txt

Meteor Integration

NameCase also includes Meteor integration. The NameCase function is available on the Client and Server and comes with a Template helper entitled NameCase.

<template name="templateName">
  {{ NameCase "abe lincoln" optionalNamecaseOptionsHelper }}
</template>
Template.templateName.helpers({
  optionalNamecaseOptionsHelper : function () {
    return { individualFields : true };
  }
});

Build Status

Keywords

FAQs

Package last updated on 30 Apr 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc