1.0.2 • Published 6 years ago

@sigodenh/name v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

name

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

install

npm i @sigodenh/name -s

Usage

var Name = require('@sigodenh/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