zv-utils
v2.2.0
Published
Collection of handy utilities using javascript functions.
Downloads
4
Maintainers
Readme
zv-utils
Collection of handy utilities using javascript functions.
Basic Usage
const _ = require('zv-utils');
Utilities
camelCase(text)
_.camelCase('Pack my Box with five Dozen liquor Jugs');
// result: packMyBoxWithFiveDozenLiquorJugs
_.camelCase('Pack_my_Box_with_five_Dozen_liquor_Jugs');
// result: packMyBoxWithFiveDozenLiquorJugs
capitalizeInitials(text)
_.capitalizeInitials('pack my box with five dozen liquor jugs');
// result: Pack My Box With Five Dozen Liquor Jugs
commaSeparated(num)
_.commaSeparated(84457675);
// result: 84,457,675
isEmail(email)
_.isEmail('teamzv@example');
_.isEmail('[email protected]');
_.isEmail('teamzv-example.com');
// results: false true false
mapKeys(array, key)
const arr = [ { id: 1, name: 'Team zV' }, { id: 2, name: 'zV Rocks!' } ];
_.mapKeys(arr, 'id');
// result: { '1': { id: 1, name: 'Team zV' }, '2': { id: 2, name: 'zV Rocks!' } }
omit(object, key)
const obj = { name: 'Team zV', age: 16, city: 'Quezon City', rating: 100 };
_.omit(obj, 'name');
// result: { rating: 100 }
pick(object, stringKey1, stringKey2)
const obj = { name: 'Team zV', rating: 100 };
_.pick(obj, 'name', 'city');
// result: { name: 'Team zV', city: 'Quezon City' }
_.pick(obj, 'name', 'age', 'city');
// result: { name: 'Team zV', age: 16, city: 'Quezon City' }
prepend(num, length = 8, prepender = '0')
_.prepend(58742));
// result: 00058742
_.prepend(58742, 10));
// result: 0000058742
_.prepend(58742, 10, 'x');
// result: xxxxx58742
slugify(text)
_.slugify('Pack My Box with Five Dozen Liquor Jugs');
// result: pack-my-box-with-five-dozen-liquor-jugs