Package Exports
- @xcmats/js-toolbox
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@xcmats/js-toolbox) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
js-toolbox
Various JS utilities.
$ npm install @xcmats/js-toolboxexperimenting
$ git clone git@github.com:drmats/js-toolbox.git
Cloning into 'js-toolbox'...
$ cd js-toolbox
$ npm i
$ npm start
🎉 Successfully compiled 8 files with Babel.> array
{ draw: [Function: draw],
flatten: [Function: flatten],
head: [Function: head],
init: [Function: init],
last: [Function: last],
range: [Function: range],
shuffle: [Function: shuffle],
sparse: [Function: sparse],
tail: [Function: tail] }
> async
{ delay: [Function: delay],
interval: [Function: interval],
timeout: [Function: timeout] }
> func
{ curry: [Function: curry],
partial: [Function: partial],
Y: [Function: Y] }
> math
{ average: [Function: average],
log10: [Function: log10],
log2: [Function: log2],
roundIfClose: [Function: roundIfClose],
sum: [Function: sum] }
> redux
{ createReducer: [Function: createReducer] }
> string
{ asciiLetters: [Function: asciiLetters],
asciiLowercase: [Function: asciiLowercase],
asciiUppercase: [Function: asciiUppercase],
big: [Function],
camelToPascal: [Function: camelToPascal],
camelToSnake: [Function: camelToSnake],
capitalize: [Function: capitalize],
digits: [Function: digits],
empty: [Function: empty],
pascalToCamel: [Function: pascalToCamel],
pascalToSnake: [Function: pascalToSnake],
quote: [Function: quote],
random: [Function: random],
snakeToCamel: [Function: snakeToCamel],
snakeToPascal: [Function: snakeToPascal] }
> utils
{ access: [Function: access],
choose: [Function: choose],
dict: [Function: dict],
handleException: [Function: handleException],
isFunction: [Function: isFunction],
isObject: [Function: isObject],
nullToUndefined: [Function: nullToUndefined],
objectMap: [Function: objectMap],
objectReduce: [Function: objectReduce],
swap: [Function: swap] }examples
> array.draw(string.asciiLetters())
'S'> array.flatten(Object.entries({ a: 'b', c: 'd', e: 'f' }))
[ 'a', 'b', 'c', 'd', 'e', 'f' ]> array.range(10)
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]> array.shuffle(array.range(12))
[ 9, 7, 0, 8, 2, 10, 3, 1, 11, 4, 5, 6 ]> f = (...args) => math.sum(args)
[Function: f]
> func.curry(f)(1)(2)(3)(4)(5)()
15> array.sparse(1024, 8)
[ 6, 34, 170, 422, 530, 643, 855, 862 ]> math.average([1, 2, 3, 4, 5])
3> math.log2(2**32)
32> math.log10(1e9)
9> math.sum([5, 6, 7, 8, 9, 10])
45> string.big(4)
'xxxxxxxxxxxxxxxx'> string.camelToSnake('someNightsIStayUpCashingInMyBadLuck')
'some_nights_i_stay_up_cashing_in_my_bad_luck'> string.quote('div', '<>')
'<div>'> string.random(16)
'MxWGe8MoOss0yUAP'> string.snakeToCamel('some_nights_i_call_it_a_draw')
'someNightsICallItADraw'> utils.access({ a: { b: { c: 42 } } }, ['a', 'b', 'c'])
42> utils.dict([['a', 'b'], ['c', 'd'], ['e', 'f']])
{ a: 'b', c: 'd', e: 'f' }> utils.isObject(null)
false
> utils.isObject([])
false
> utils.isObject({})
true> utils.objectMap(
... { what: 'od', i: '?rof dnats' },
... ([k, v,]) => [
... string.capitalize(k),
... v.split('').reverse().join('')
... ]
... )
{ What: 'do', I: 'stand for?' }> utils.swap({ a: 'b', c: 'd', e: 'f' })
{ b: 'a', d: 'c', f: 'e' }