time-to-botec/js/node_modules/@stdlib/utils/async/function-sequence/docs/repl.txt
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

73 lines
2.1 KiB
Plaintext

{{alias}}( ...fcn )
Returns a pipeline function.
Starting from the left, the pipeline function evaluates each function and
passes the result as the first argument of the next function. The result of
the rightmost function is the result of the whole.
The last argument for each provided function is a `next` callback which
should be invoked upon function completion. The callback accepts two
arguments:
- `error`: error argument
- `result`: function result
If a provided function calls the `next` callback with a truthy `error`
argument, the pipeline function suspends execution and immediately calls the
`done` callback for subsequent `error` handling.
Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony,
wrap the `done` callback in a function which either executes at the end of
the current stack (e.g., `nextTick`) or during a subsequent turn of the
event loop (e.g., `setImmediate`, `setTimeout`).
Only the leftmost function is explicitly permitted to accept multiple
arguments. All other functions are evaluated as binary functions.
The function will throw if provided fewer than two input arguments.
Parameters
----------
fcn: ...Function
Functions to evaluate in sequential order.
Returns
-------
out: Function
Pipeline function.
Examples
--------
> function a( x, next ) {
... setTimeout( onTimeout, 0 );
... function onTimeout() {
... next( null, 2*x );
... }
... };
> function b( x, next ) {
... setTimeout( onTimeout, 0 );
... function onTimeout() {
... next( null, x+3 );
... }
... };
> function c( x, next ) {
... setTimeout( onTimeout, 0 );
... function onTimeout() {
... next( null, x/5 );
... }
... };
> var f = {{alias}}( a, b, c );
> function done( error, result ) {
... if ( error ) {
... throw error;
... }
... console.log( result );
... };
> f( 6, done )
3
See Also
--------