Comparing version 0.13.3 to 0.13.4
@@ -6,57 +6,57 @@ // Type definitions for es6-promise | ||
interface Thenable<R> { | ||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>; | ||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>; | ||
export interface Thenable<R> { | ||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U> | void): Thenable<U>; | ||
} | ||
export default class Promise<R> implements Thenable<R> { | ||
/** | ||
* If you call resolve in the body of the callback passed to the constructor, | ||
* your promise is fulfilled with result object passed to resolve. | ||
* If you call reject your promise is rejected with the object passed to reject. | ||
* For consistency and debugging (eg stack traces), obj should be an instanceof Error. | ||
* Any errors thrown in the constructor callback will be implicitly passed to reject(). | ||
*/ | ||
constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void); | ||
/** | ||
* If you call resolve in the body of the callback passed to the constructor, | ||
* your promise is fulfilled with result object passed to resolve. | ||
* If you call reject your promise is rejected with the object passed to reject. | ||
* For consistency and debugging (eg stack traces), obj should be an instanceof Error. | ||
* Any errors thrown in the constructor callback will be implicitly passed to reject(). | ||
*/ | ||
constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void); | ||
/** | ||
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. | ||
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. | ||
* Both callbacks have a single parameter , the fulfillment value or rejection reason. | ||
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. | ||
* If an error is thrown in the callback, the returned promise rejects with that error. | ||
* | ||
* @param onFulfilled called when/if "promise" resolves | ||
* @param onRejected called when/if "promise" rejects | ||
*/ | ||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>; | ||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>; | ||
/** | ||
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. | ||
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. | ||
* Both callbacks have a single parameter , the fulfillment value or rejection reason. | ||
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. | ||
* If an error is thrown in the callback, the returned promise rejects with that error. | ||
* | ||
* @param onFulfilled called when/if "promise" resolves | ||
* @param onRejected called when/if "promise" rejects | ||
*/ | ||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U> | void): Thenable<U>; | ||
/** | ||
* Sugar for promise.then(undefined, onRejected) | ||
* | ||
* @param onRejected called when/if "promise" rejects | ||
*/ | ||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;/** | ||
* Make a new promise from the thenable. | ||
* A thenable is promise-like in as far as it has a "then" method. | ||
*/ | ||
resolve<R>(value?: R | Thenable<R>): Promise<R>; | ||
/** | ||
* Sugar for promise.then(undefined, onRejected) | ||
* | ||
* @param onRejected called when/if "promise" rejects | ||
*/ | ||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>; | ||
/** | ||
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error | ||
*/ | ||
reject(error: any): Promise<any>; | ||
/** | ||
* Make a new promise from the thenable. | ||
* A thenable is promise-like in as far as it has a "then" method. | ||
*/ | ||
static resolve<R>(value?: R | Thenable<R>): Promise<R>; | ||
/** | ||
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. | ||
* the array passed to all can be a mixture of promise-like objects and other objects. | ||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. | ||
*/ | ||
all<R>(promises: (R | Thenable<R>)[]): Promise<R[]>; | ||
/** | ||
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error | ||
*/ | ||
static reject(error: any): Promise<any>; | ||
/** | ||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. | ||
*/ | ||
race<R>(promises: (R | Thenable<R>)[]): Promise<R>; | ||
} | ||
/** | ||
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. | ||
* the array passed to all can be a mixture of promise-like objects and other objects. | ||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. | ||
*/ | ||
static all<R>(promises: (R | Thenable<R>)[]): Promise<R[]>; | ||
/** | ||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. | ||
*/ | ||
static race<R>(promises: (R | Thenable<R>)[]): Promise<R>; | ||
} |
/* | ||
Yaku v0.13.3 | ||
Yaku v0.13.4 | ||
(c) 2015 Yad Smood. http://ysmood.org | ||
@@ -4,0 +4,0 @@ License MIT |
{ | ||
"name": "yaku", | ||
"version": "0.13.3", | ||
"version": "0.13.4", | ||
"description": "A light-weight ES6 Promises/A+ implementation that doesn't hurt.", | ||
@@ -5,0 +5,0 @@ "main": "lib/yaku.js", |
@@ -24,3 +24,3 @@ <a href="http://promisesaplus.com/"> | ||
- The minified file is only 3.2KB (2KB gzipped) | ||
- The minified file is only 3.8KB (2KB gzipped) | ||
- [Better "possibly unhandled rejection" and "long stack trace"][docs/debugHelperComparison.md] than [Bluebird][] | ||
@@ -84,3 +84,3 @@ - Much better performance than the native Promise | ||
| ---- | ---------- | -------------- | ---------------- | ------- | ------ | | ||
| [yaku][]@0.13.1 | ✓ | 337ms / 106MB | ✓ | 31 | 3.2KB | | ||
| [yaku][]@0.13.1 | ✓ | 337ms / 106MB | ✓ | 31 | 3.8KB | | ||
| [bluebird][]@3.3.1 | x (26 failing) | 258ms / 88MB | partial | 100 | 52.2KB | | ||
@@ -87,0 +87,0 @@ | [es6-promise][]@3.1.2 | x (39 failing) | 457ms / 112MB | x | 10 | 6.3KB | |
84231