Skip to content

Files

Latest commit

 

History

History
68 lines (45 loc) · 1.36 KB

README.md

File metadata and controls

68 lines (45 loc) · 1.36 KB

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