Merge pull request #5388 from Necroskillz/bluebird_fromNode

Add fromNode to bluebird
This commit is contained in:
Masahiro Wakame
2015-08-17 23:38:57 +09:00
2 changed files with 11 additions and 0 deletions
+5
View File
@@ -144,6 +144,10 @@ var BlueBird: typeof Promise;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var nodeCallbackFunc = (callback: (err: any, result: string) => void) => {}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooThen = fooProm;
barThen = barProm;
@@ -616,6 +620,7 @@ func = Promise.promisify(f, obj);
;
obj = Promise.promisifyAll(obj);
anyProm = Promise.fromNode(callback => nodeCallbackFunc(callback));
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+6
View File
@@ -417,6 +417,12 @@ declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
// TODO how to model promisifyAll?
static promisifyAll(target: Object, options?: Object): Object;
/**
* Returns a promise that is resolved by a node style callback function.
*/
static fromNode(resolver: (callback: (err: any, result: any) => void) => void): Promise<any>;
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/