2.6.6 • Published 2 years ago
@stool/core v2.6.6
@stool/core
JavaScript core tools.
Install
npm install @stool/core
Using
String
camelCase()
camelCase('a-b-c'); // aBC
hyphenate()
hyphenate('aBC'); // a-b-c
format()
format('Hello {{name}}!!!', {name:'Tom'}); // 'Hello Tom!!!'
Function
noop()
declarate function noop() {};
tr()
Pick first value without error
tr(() => { throw new Error() }, () => 'One'); // 'One';
clone()
Clone object
Random
randomInt()
randomInt(10); // [0..9]
randomInt(5, 10); //[5..9]
choice()
choice(); // null
choice([1,2,3]); // 1 or 2 or 3
sid(len=32)
sid(); // IBA1CCRQ69NIELNLBG65WHHEGNVGQPO1 (32)
sid(3); //WK5
createUID()
const uid = createUID();
uid(); // '0'
...
uid(); // 'ac'
uid(); // 'ad'
License
MIT