diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 7770e7c9b..d5be272fc 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -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)); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index 665b66990..573a3e107 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -417,6 +417,12 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { // 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; + /** * 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. */