run-callback
Run async or sync callbacks, such as gulp tasks.
Usage
var run = var thunkify = runthunkify
promise = run(callback, ...args)
Run callback
with args
,
and return a promise to fetch the results,
which is always an Array
.
callback
Type: Function
callback
can be made asynchronous if it does one of the following:
Return a promise
Return a stream
var Readable = Readable var src = 'beep' '\n' 'boop' { var rs = rs { if sourcelength this else this } return rs}
Accept one more argument than declared
run.thunkify(fn)
Return a new function to run fn
later with a list of arguments.
var task = run
Runner = run.Runner
var runner = Runner(opts)
Create a custom Runner
instance to run callbacks.
opts
By default, callbacks returning a stream is thought to be in progress before the stream ends.
However, if opts.stream
is false
,
callbacks returning a stream wil be treated as synchronous.
If opts.promise
is false
,
callbacks returning a promise will be treated as synchronous.
If opts.async
is false
,
callbacks can only be made asynchronous
by returning a promise (when opts.promise
is true
),
or returning a stream (when opts.stream
is true
).
var Stream = var Readable = StreamReadablevar Writable = StreamWritable ; { var runner = var outputs = var rs = return runner} { var stream = var i = 0 stream { if i < inputlength this else this } return stream} { var stream = var i = 0 stream { output } return stream}