Comparing version 0.16.1 to 0.16.2
@@ -12,6 +12,2 @@ var Promise = require("./yaku"); | ||
isArray: function (obj) { | ||
return obj instanceof Array; | ||
}, | ||
isFunction: function (obj) { | ||
@@ -18,0 +14,0 @@ return typeof obj === "function"; |
@@ -32,5 +32,5 @@ var _ = require("./_"); | ||
function genThrow () { | ||
function genThrow (reason) { | ||
running--; | ||
return step("throw"); | ||
return reject(reason); | ||
} | ||
@@ -49,2 +49,3 @@ | ||
if (info.done) { | ||
if (running === 0) resolve(); | ||
return done = true; | ||
@@ -51,0 +52,0 @@ } else { |
@@ -17,17 +17,6 @@ var _ = require("./_"); | ||
if (!isFn && arguments.length === 1) { | ||
args = [cb]; | ||
cb = null; | ||
} | ||
return fn.apply(self, args).then(function (val) { | ||
return isFn ? cb(null, val) : void 0; | ||
})["catch"](function (err) { | ||
if (cb) { | ||
return cb(err); | ||
} else { | ||
return _.Promise.reject(err); | ||
} | ||
}); | ||
cb(null, val); | ||
})["catch"](cb); | ||
}; | ||
}; |
@@ -18,2 +18,3 @@ var _ = require("./_"); | ||
// For the sake of performance. | ||
switch (len) { | ||
@@ -20,0 +21,0 @@ case 0: fn.call(self, cb); break; |
/* | ||
Yaku v0.16.1 | ||
Yaku v0.16.2 | ||
(c) 2015 Yad Smood. http://ysmood.org | ||
@@ -11,3 +11,3 @@ License MIT | ||
, $null = null | ||
, root = typeof global === "object" ? global : window | ||
, root = typeof window === "object" ? window : global | ||
, isLongStackTrace = false | ||
@@ -44,2 +44,3 @@ , process = root.process | ||
, $noop = function () {} | ||
, $cleanStackReg = /^.+\/node_modules\/yaku\/.+\n?/mg | ||
; | ||
@@ -330,3 +331,6 @@ | ||
try { | ||
root.console.error($unhandledRejectionMsg, genStackInfo(reason, p)); | ||
root.console.error( | ||
$unhandledRejectionMsg, | ||
isLongStackTrace ? p.longStack : genStackInfo(reason, p) | ||
); | ||
} catch (e) {} // eslint-disable-line | ||
@@ -349,2 +353,3 @@ }; | ||
* application and waste your memory. | ||
* It will add an extra property `longStack` to the Error object. | ||
* @example | ||
@@ -354,2 +359,5 @@ * ```js | ||
* Promise.enableLongStackTrace(); | ||
* Promise.reject(new Error("err")).catch((err) => { | ||
* console.log(err.longStack); | ||
* }); | ||
* ``` | ||
@@ -407,3 +415,3 @@ */ | ||
function isObject (obj) { | ||
return typeof obj === "object"; | ||
return obj && typeof obj === "object"; | ||
} | ||
@@ -512,4 +520,5 @@ | ||
iter = gen.call(iterable); | ||
else if (isFunction(iterable.next)) | ||
else if (isFunction(iterable.next)) { | ||
iter = iterable; | ||
} | ||
else if (isInstanceOf(iterable, Arr)) { | ||
@@ -527,3 +536,3 @@ len = iterable.length; | ||
if (ret === $tryErr) { | ||
if (isFunction(iter[$return])) iter[$return](); | ||
isFunction(iter[$return]) && iter[$return](); | ||
throw ret.e; | ||
@@ -547,3 +556,3 @@ } | ||
function genTraceInfo (noTitle) { | ||
return (noTitle ? "" : $fromPrevious) + (new Err().stack || ""); | ||
return (noTitle ? "" : $fromPrevious) + new Err().stack; | ||
} | ||
@@ -707,3 +716,3 @@ | ||
iter(node._next); | ||
push(node[$promiseTrace] || ""); | ||
push(node[$promiseTrace] + ""); | ||
iter(node._pre); | ||
@@ -714,4 +723,4 @@ } | ||
return (isError(reason) ? reason.stack : reason) | ||
+ ("\n" + stackInfo.join("\n")).replace(/^.+\/node_modules\/yaku\/.+\n?/mg, ""); | ||
return reason.stack + | ||
("\n" + stackInfo.join("\n")).replace($cleanStackReg, ""); | ||
} | ||
@@ -733,4 +742,3 @@ | ||
var i = 0 | ||
, len = p._pCount | ||
, p2; | ||
, len = p._pCount; | ||
@@ -754,7 +762,3 @@ // 2.1.2 | ||
while (i < len) { | ||
p2 = p[i++]; | ||
if (p2._s !== $pending) continue; | ||
scheduleHandler(p, p2); | ||
scheduleHandler(p, p[i++]); | ||
} | ||
@@ -831,16 +835,8 @@ } | ||
// 2.3.3.3.3 | ||
if (x) { | ||
x = $null; | ||
// 2.3.3.3.1 | ||
settleWithX(p, y); | ||
} | ||
// 2.3.3.3.1 | ||
x && (x = $null, settleWithX(p, y)); | ||
}, function (r) { | ||
// 2.3.3.3.3 | ||
if (x) { | ||
x = $null; | ||
// 2.3.3.3.2 | ||
settlePromise(p, $rejected, r); | ||
} | ||
// 2.3.3.3.2 | ||
x && (x = $null, settlePromise(p, $rejected, r)); | ||
}); | ||
@@ -847,0 +843,0 @@ |
{ | ||
"name": "yaku", | ||
"version": "0.16.1", | ||
"description": "A light-weight ES6 Promises/A+ implementation that doesn't hurt.", | ||
"version": "0.16.2", | ||
"description": "A lightweight promise library", | ||
"main": "lib/yaku.js", | ||
@@ -41,12 +41,14 @@ "typings": "lib/yaku.d.ts", | ||
"devDependencies": { | ||
"bluebird": "3.3.5", | ||
"bluebird": "3.4.1", | ||
"co": "4.6.0", | ||
"core-js": "2.3.0", | ||
"es6-promise": "3.1.2", | ||
"es6-shim": "0.35.0", | ||
"eslint": "2.8.0", | ||
"junit": "1.4.0", | ||
"mocha": "2.4.5", | ||
"core-js": "2.4.0", | ||
"coveralls": "2.11.9", | ||
"es6-promise": "3.2.1", | ||
"es6-shim": "0.35.1", | ||
"eslint": "2.13.1", | ||
"istanbul": "0.4.4", | ||
"junit": "1.4.4", | ||
"mocha": "2.5.3", | ||
"my-promise": "1.1.0", | ||
"nokit": "0.20.8", | ||
"nokit": "0.21.0", | ||
"phantomjs-prebuilt": "2.1.7", | ||
@@ -57,4 +59,4 @@ "promises-aplus-tests": "*", | ||
"setprototypeof": "1.0.1", | ||
"uglify-js": "2.6.2", | ||
"webpack": "1.13.0" | ||
"uglify-js": "2.6.4", | ||
"webpack": "1.13.1" | ||
}, | ||
@@ -61,0 +63,0 @@ "eslintConfig": { |
@@ -15,6 +15,5 @@ <a href="http://promisesaplus.com/"> | ||
I am not an optimization freak, I try to keep the source code readable and maintainable. | ||
Premature optimization is the root of all evil. I write this lib to research one of my data structure | ||
ideas: [docs/lazyTree.md][]. | ||
I write this lib to research one of my data structure ideas: [docs/lazyTree.md][]. | ||
[![NPM version](https://badge.fury.io/js/yaku.svg)](http://badge.fury.io/js/yaku) [![Build Status](https://travis-ci.org/ysmood/yaku.svg)](https://travis-ci.org/ysmood/yaku) [![Deps Up to Date](https://david-dm.org/ysmood/yaku.svg?style=flat)](https://david-dm.org/ysmood/yaku) | ||
[![NPM version](https://badge.fury.io/js/yaku.svg)](http://badge.fury.io/js/yaku) [![Build Status](https://travis-ci.org/ysmood/yaku.svg)](https://travis-ci.org/ysmood/yaku) [![Deps Up to Date](https://david-dm.org/ysmood/yaku.svg?style=flat)](https://david-dm.org/ysmood/yaku) [![Coverage Status](https://coveralls.io/repos/ysmood/yaku/badge.svg?branch=master&service=github)](https://coveralls.io/github/ysmood/yaku?branch=master) | ||
@@ -28,2 +27,3 @@ | ||
- Designed to work on IE5+ and other major browsers | ||
- 100% statement and branch test coverage | ||
- Much better performance than the native Promise | ||
@@ -76,20 +76,25 @@ - Well commented source code with every Promises/A+ spec | ||
``` | ||
Node v5.11.0 | ||
Date: Tue Jun 28 2016 14:12:35 GMT+0800 (CST) | ||
Node v6.2.2 | ||
OS darwin | ||
Arch x64 | ||
CPU Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GH | ||
CPU Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz | ||
``` | ||
| name | unit tests | 1ms async task | optional helpers | helpers | min js | | ||
| ---- | ---------- | -------------- | ---------------- | ------- | ------ | | ||
| [yaku][]@0.15.2 | ✓ | 357ms / 108MB | ✓ | 32 | 3.9KB | | ||
| [bluebird][]@3.3.5 | x (27 failing) | 283ms / 89MB | partial | 100 | 52.7KB | | ||
| [es6-promise][]@3.1.2 | x (27 failing) | 403ms / 113MB | x | 10 | 6.3KB | | ||
| [native][]@0.15.3 | x (9 failing) | 572ms / 168MB | x | 13 | 0KB | | ||
| [core-js][]@2.3.0 | x (3 failing) | 826ms / 197MB | x | 11 | 12.3KB | | ||
| [es6-shim][]@0.35.0 | x (1 failing) | 993ms / 85MB | x | 12 | 55KB | | ||
| [q][]@1.4.1 | x (67 failing) | 1555ms / 425MB | x | 74 | 15.4KB | | ||
| [my-promise][]@1.1.0 | x (1 failing) | 922ms / 223MB | x | 10 | 8.4KB | | ||
| name | unit tests | coverage | 1ms async task | optional helpers | helpers | min js | | ||
| ---- | ---------- | -------- | -------------- | ---------------- | ------- | ------ | | ||
| [yaku][]@0.15.9 | ✓ | 100% 100% | 327ms / 108MB | ✓ | 33 | 4.1KB | | ||
| [bluebird][]@3.4.1 | x (33 failing) | 99% 96% | 212ms / 91MB | partial | 102 | 52.8KB | | ||
| [es6-promise][]@3.2.1 | x (48 failing) | ? ? | 473ms / 107MB | x | 10 | 6.4KB | | ||
| [native][]@0.16.1 | x (12 failing) | ? ? | 682ms / 164MB | x | 13 | 0KB | | ||
| [core-js][]@2.4.0 | x (10 failing) | ? ? | 600ms / 185MB | x | 11 | 12.3KB | | ||
| [es6-shim][]@0.35.1 | x (12 failing) | ? ? | 684ms / 165MB | x | 11 | 54.7KB | | ||
| [q][]@1.4.1 | x (47 failing) | ? ? | 1341ms / 389MB | x | 74 | 15.4KB | | ||
| [my-promise][]@1.1.0 | x (7 failing) | ? ? | 864ms / 226MB | x | 10 | 8.4KB | | ||
- **Helpers**: extra methods that help with your promise programming, such as | ||
- **unit test**: [promises-aplus-tests][], [promises-es6-tests][], and even the [core-js tests][]. | ||
- **coverage**: statement coverage and branch coverage. | ||
- **helpers**: extra methods that help with your promise programming, such as | ||
async flow control helpers, debug helpers. For more details: [docs/debugHelperComparison.md][]. | ||
@@ -186,3 +191,3 @@ | ||
- ### **[Yaku(executor)](src/yaku.js?source#L48)** | ||
- ### **[Yaku(executor)](src/yaku.js?source#L49)** | ||
@@ -199,3 +204,3 @@ This class follows the [Promises/A+](https://promisesaplus.com) and | ||
- ### **[then(onFulfilled, onRejected)](src/yaku.js?source#L96)** | ||
- ### **[then(onFulfilled, onRejected)](src/yaku.js?source#L97)** | ||
@@ -229,3 +234,3 @@ Appends fulfillment and rejection handlers to the promise, | ||
- ### **[catch(onRejected)](src/yaku.js?source#L123)** | ||
- ### **[catch(onRejected)](src/yaku.js?source#L124)** | ||
@@ -255,3 +260,3 @@ The `catch()` method returns a Promise and deals with rejected cases only. | ||
- ### **[Yaku.resolve(value)](src/yaku.js?source#L150)** | ||
- ### **[Yaku.resolve(value)](src/yaku.js?source#L151)** | ||
@@ -276,3 +281,3 @@ The `Promise.resolve(value)` method returns a Promise object that is resolved with the given value. | ||
- ### **[Yaku.reject(reason)](src/yaku.js?source#L164)** | ||
- ### **[Yaku.reject(reason)](src/yaku.js?source#L165)** | ||
@@ -294,3 +299,3 @@ The `Promise.reject(reason)` method returns a Promise object that is rejected with the given reason. | ||
- ### **[Yaku.race(iterable)](src/yaku.js?source#L188)** | ||
- ### **[Yaku.race(iterable)](src/yaku.js?source#L189)** | ||
@@ -324,3 +329,3 @@ The `Promise.race(iterable)` method returns a promise that resolves or rejects | ||
- ### **[Yaku.all(iterable)](src/yaku.js?source#L244)** | ||
- ### **[Yaku.all(iterable)](src/yaku.js?source#L245)** | ||
@@ -369,3 +374,3 @@ The `Promise.all(iterable)` method returns a promise that resolves when | ||
- ### **[Yaku.Symbol](src/yaku.js?source#L280)** | ||
- ### **[Yaku.Symbol](src/yaku.js?source#L281)** | ||
@@ -385,3 +390,3 @@ The ES6 Symbol object that Yaku should use, by default it will use the | ||
- ### **[Yaku.speciesConstructor(O, defaultConstructor)](src/yaku.js?source#L295)** | ||
- ### **[Yaku.speciesConstructor(O, defaultConstructor)](src/yaku.js?source#L296)** | ||
@@ -397,3 +402,3 @@ Use this api to custom the species behavior. | ||
- ### **[Yaku.unhandledRejection(reason, p)](src/yaku.js?source#L321)** | ||
- ### **[Yaku.unhandledRejection(reason, p)](src/yaku.js?source#L322)** | ||
@@ -427,3 +432,3 @@ Catch all possibly unhandled rejections. If you want to use specific | ||
- ### **[Yaku.rejectionHandled(reason, p)](src/yaku.js?source#L333)** | ||
- ### **[Yaku.rejectionHandled(reason, p)](src/yaku.js?source#L337)** | ||
@@ -441,3 +446,3 @@ Emitted whenever a Promise was rejected and an error handler was | ||
- ### **[Yaku.enableLongStackTrace](src/yaku.js?source#L347)** | ||
- ### **[Yaku.enableLongStackTrace](src/yaku.js?source#L355)** | ||
@@ -449,2 +454,3 @@ It is used to enable the long stack trace. | ||
application and waste your memory. | ||
It will add an extra property `longStack` to the Error object. | ||
@@ -456,5 +462,8 @@ - **<u>example</u>**: | ||
Promise.enableLongStackTrace(); | ||
Promise.reject(new Error("err")).catch((err) => { | ||
console.log(err.longStack); | ||
}); | ||
``` | ||
- ### **[Yaku.nextTick](src/yaku.js?source#L370)** | ||
- ### **[Yaku.nextTick](src/yaku.js?source#L378)** | ||
@@ -461,0 +470,0 @@ Only Node has `process.nextTick` function. For browser there are |
1117
85885
19
24
1584