Common functions and helpers.
Add the parent package to your dependencies:
yarn add @swrlab/utilsvalue(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 }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']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