1 | import types = require('../types');
|
2 | import Config = require('./config');
|
3 | import makeAsyncFunc = require('./makeAsyncFunc');
|
4 | export = async;
|
5 |
|
6 |
|
7 | /**
|
8 | * Creates a suspendable function. Suspendable functions may use the await() function
|
9 | * internally to suspend execution at arbitrary points, pending the results of
|
10 | * internal asynchronous operations.
|
11 | * @param {Function} fn - Contains the body of the suspendable function. Calls to await()
|
12 | * may appear inside this function.
|
13 | * @returns {Function} A function of the form `(...args) --> Promise`. Any arguments
|
14 | * passed to this function are passed through to fn. The returned
|
15 | * promise is resolved when fn returns, or rejected if fn throws.
|
16 | */
|
17 | var async: types.Async = <any> makeAsyncFunc(new Config());
|
18 | async.cps = <any> async.mod('returns: none, callback: true, iterable: false');
|
19 | async.thunk = <any> async.mod('returns: thunk, callback: false, iterable: false');
|
20 | async.result = <any> async.mod('returns: result, callback: false, iterable: false');
|
21 | async.iterable = <any> async.mod('returns: promise, callback: false, iterable: true');
|