Small js package I use to help me deal with functions
$ npm install help-func
This package is pure ESM. It cannot be require()
'd from CommonJS.
Use import foo from 'foo'
instead of const foo = require('foo')
to import the package.
// Load entire build
import * as helpFunc from 'help-func';
// Load by method
import {debounce} from 'help-func';
If the package is used in an async context, you could use await import(…)
from CommonJS instead of require(…)
.
You also need to make sure you're on the latest minor version of Node.js. At minimum Node.js 12.20, 14.14, or 16.0.
Read more here: sindresorhus/esm-package
debounce([1,2,3], (element) => typeof element === 'string');
//=> false
debounce(['1', '2', '3'], (element) => typeof element === 'string');
//=> true
delay
: Invokes func
after wait
milliseconds. Any additional arguments are provided to func
when it's invoked.
safelyRun
:
debounce
: Returns a function that will only run n
milliseconds after it stops being called.
negate
: Creates a function that negates the result of the predicate func
.
overArgs
: Creates a function that invokes func
with its arguments transformed.
waitTime
:
waitFor
:
retry
:
mock
: Mock promise, useful for testing asynchronous functions.
mockFactory
:
MIT © Paul Nodet