@amjs/utils-string
v0.1.0
Published
Set of tools as capitalize, camelize, etc. for handle strings
Downloads
4
Readme
@amjs/utils-string 0.1.0
Set of tools as capitalize text, camelize text, etc.
Installation
$ npm i @amjs/utils-string
Usage
capitalize
const { capitalize } = require('@amjs/utils-string');
console.log(capitalize('hello')); // 'Hello'
camelize
const { camelize } = require('@amjs/utils-string');
console.log(camelize('hello-world')); // 'helloWorld'
decamelize
const { decamelize } = require('@amjs/utils-string');
console.log(decamelize('helloWorld')); // 'hello-world'
// Use second parameter to assign an specific word character separator
console.log(decamelize('helloWorld', '/')); // 'hello/world'
stringify
const { stringify } = require('@amjs/utils-string');
console.log(stringify('text')); // 'text'
console.log(stringify('')); // ''
console.log(stringify(1)); // '1'
console.log(stringify(true)); // 'true'
console.log(stringify({ key : 'value' })); // '{"key":"value"}'
console.log(stringify([{ key : 'value' }])); // '[{"key":"value"}]'
console.log(stringify()); // Error
console.log(stringify(null); // Error```