Skip to content

Latest commit

 

History

History

helpers

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

SWR Audio Lab / Helpers

Common functions and helpers.

Install

Add the parent package to your dependencies:

yarn add @swrlab/utils

arrayToObjectCount - reduce array elements to object with count

  • value (required) - Array to get entries from

Import the library:

const { arrayToObjectCount } = require('@swrlab/utils/packages/helpers')

Then use the toolkit:

arrayToObjectCount(['foo', 'bar', 'bar'])
// { bar: 2, foo: 1 }

getJsonKeys - get all keys of json input

  • value (required) - Json to get keys from

Import the library:

const { getJsonKeys } = require('@swrlab/utils/packages/helpers')

Then use the toolkit:

getJsonKeys({ hello: 'world', foo: 'bar' })
// ['hello', 'foo']

sleep - sleep a given time (async)

  • value (required) - Value to sleep (in ms)

Import the library:

const { sleep } = require('@swrlab/utils/packages/helpers')

Then use the toolkit:

await sleep(1e3)
// will sleep 1s