@sigodenjs/name

1.0.2 • Public • Published

name

A utility class to convert a string into CamelCase/dash-case/snake_case, capitalized/uncapitalized, plural/singular name.

install

npm i @sigodenjs/name -s

Usage

var Name = require('@sigodenjs/name');
var name = new Name('helloWorld');

name.toDashCase().toValue(); // returns hello-world
name.toDashCase().toCamelCase().toValue() === name.toValue(); // true
name.toCapital().toUncapital().toValue() === name.toValue();  // true
name.toPlural().toSingular().toValue() === name.toValue(); // true

API

static methods

capitalize()

Name.capitalize('apple'); // returns Apple

uncapitalize()

Name.uncapitalize('Apple');  // returns apple

toDashCase()

Name.toDashCase('helloWorld'); // returns hello-world

toSnakeCase()

Name.toSnakeCase('helloWorld'); // returns hello_world

toCamelCase()

Name.toCamelCase('hello-world'); // returns helloWorld

pluralize()

Name.pluralize('apple'); // returns apples

singularize()

Name.singularize('apples'); // returns apple

public methods

toValue()

new Name('hello-world').toValue(); // returns hello-world

toPlural()

new Name('apple').toPlural().toValue(); // returns apples;

toSingular()

new Name('apples').toSingular().toValue(); // returns apple;

toCapital()

new Name('apple').toCapital().toValue(); // returns Apple;

toCapitalWords()

new Name('hello-world').toCapitalWords().toValue(); // returns Hello-World;

toUncapital()

new Name('Apple').toUncapital().toValue(); // returns apple;

toDashCase()

new Name('helloWorld').toDashCase().toValue(); //returns hello-world

toSnakeCase()

new Name('helloWorld').toDashCase().toValue(); //returns hello_world

toCamelCase()

new Name('hello-world').toCamelCase().toValue(); //returns helloWorld

License

MIT

Package Sidebar

Install

npm i @sigodenjs/name

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

6.64 kB

Total Files

4

Last publish

Collaborators

  • sigoden