@r14c/async-utils v0.4.1
@r14c/async-utils(1) -- async implementations of common utility functions
don't block
async-utils
is designed to work with the new async syntax to allow you to write non-blocking
code that looks synchronous. functions like Array.prototype.map()
are very useful, but
operating over large collections will always block. async-utils
rethinks a full range of
useful tools to work with the event loop rather than against it.
contributors welcome! please email a patch or pull request to a maintainer and we'll get your changes merged as quickly as possible.
Modules
Functions
fork
fork(fns, predicate) ⇒ Promise.<any> ⏏
execute a chain of async operations using the return value of each function as the argument for the next
Kind: global method of fork
Param | Type |
---|---|
fns | Array.<function(value)> |
predicate | any |
memoize
Memoize(identity) ⇒ function ⏏
cache namespace cosntructor
the passed identity
function is used to track which function made a
particular call so it can be associated with the cache. by default, memoize
uses the included checksum function.
Kind: global method of memoize
Returns: function - cache instance
See: checksum
Param | Type | Default | Description |
---|---|---|---|
identity | function | optional identity function |
Memoize~memoize(fn, args, ttl)
cache the result of a function call in memory.
Kind: inner method of Memoize
Param | Type | Description |
---|---|---|
fn | function | the function that is being memoized |
args | array | arguments that should be passed into fn |
ttl | number | Object | time to live value and cache group |
memoize.clear(cacheGroup)
evict a group of cached objects
Kind: static method of memoize
Param | Type |
---|---|
cacheGroup | string |
microTask
microTask(fn) ⏏
schedule a task to run on nextTick
Kind: global method of microTask
Param | Type |
---|---|
fn | function |
to
to(promise) ⇒ Promise ⏏
Kind: global method of to
Param | Type |
---|---|
promise | Promise |