time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (2135B)


      1 
      2 {{alias}}( ...fcn )
      3     Returns a pipeline function.
      4 
      5     Starting from the left, the pipeline function evaluates each function and
      6     passes the result as the first argument of the next function. The result of
      7     the rightmost function is the result of the whole.
      8 
      9     The last argument for each provided function is a `next` callback which
     10     should be invoked upon function completion. The callback accepts two
     11     arguments:
     12 
     13     - `error`: error argument
     14     - `result`: function result
     15 
     16     If a provided function calls the `next` callback with a truthy `error`
     17     argument, the pipeline function suspends execution and immediately calls the
     18     `done` callback for subsequent `error` handling.
     19 
     20     Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony,
     21     wrap the `done` callback in a function which either executes at the end of
     22     the current stack (e.g., `nextTick`) or during a subsequent turn of the
     23     event loop (e.g., `setImmediate`, `setTimeout`).
     24 
     25     Only the leftmost function is explicitly permitted to accept multiple
     26     arguments. All other functions are evaluated as binary functions.
     27 
     28     The function will throw if provided fewer than two input arguments.
     29 
     30     Parameters
     31     ----------
     32     fcn: ...Function
     33         Functions to evaluate in sequential order.
     34 
     35     Returns
     36     -------
     37     out: Function
     38         Pipeline function.
     39 
     40     Examples
     41     --------
     42     > function a( x, next ) {
     43     ...    setTimeout( onTimeout, 0 );
     44     ...    function onTimeout() {
     45     ...        next( null, 2*x );
     46     ...    }
     47     ... };
     48     > function b( x, next ) {
     49     ...    setTimeout( onTimeout, 0 );
     50     ...    function onTimeout() {
     51     ...        next( null, x+3 );
     52     ...    }
     53     ... };
     54     > function c( x, next ) {
     55     ...    setTimeout( onTimeout, 0 );
     56     ...    function onTimeout() {
     57     ...        next( null, x/5 );
     58     ...    }
     59     ... };
     60     > var f = {{alias}}( a, b, c );
     61     > function done( error, result ) {
     62     ...    if ( error ) {
     63     ...        throw error;
     64     ...    }
     65     ...    console.log( result );
     66     ... };
     67     > f( 6, done )
     68     3
     69 
     70     See Also
     71     --------
     72