Comparing version 0.2.1 to 0.2.2
/* | ||
Yaku v0.2.1 | ||
Yaku v0.2.2 | ||
(c) 2015 Yad Smood. http://ysmood.org | ||
@@ -237,21 +237,32 @@ License MIT | ||
Yaku.onUnhandledRejection = function(reason, p) { | ||
var stackInfo, stackStr; | ||
var clean, iter, push, stackInfo, stackStr; | ||
if (!isObject(console)) { | ||
return; | ||
} | ||
stackInfo = [(reason ? reason.stack ? reason.stack.trim() : reason : reason)]; | ||
stackInfo = []; | ||
if (isLongStackTrace && p[$promiseTrace]) { | ||
push = function(trace) { | ||
return stackInfo.push(trace.trim()); | ||
}; | ||
if (p[$settlerTrace]) { | ||
stackInfo.push(p[$settlerTrace].trim()); | ||
push(p[$settlerTrace]); | ||
} | ||
while (p) { | ||
stackInfo.push(p[$promiseTrace].trim()); | ||
p = p._pre; | ||
iter = function(node) { | ||
if (!node) { | ||
return; | ||
} | ||
iter(node._next); | ||
push(node[$promiseTrace]); | ||
return iter(node._pre); | ||
}; | ||
iter(p); | ||
} | ||
stackStr = '\n' + stackInfo.join('\n'); | ||
clean = function(stack) { | ||
if (typeof __filename === 'string') { | ||
return stack.replace(RegExp(".+" + __filename + ".+\\n?", "g"), ''); | ||
} | ||
} | ||
stackStr = stackInfo.join('\n'); | ||
if (typeof __filename === 'string') { | ||
stackStr = stackStr.replace(RegExp(".+" + __filename + ".+\\n?", "g"), ''); | ||
} | ||
console.error('Unhandled Rejection:', stackStr); | ||
}; | ||
console.error('Unhandled Rejection:', (reason ? reason.stack ? clean(reason.stack.trim()) : reason : reason), clean(stackStr)); | ||
stackInfo.unshift(reason); | ||
return stackInfo; | ||
@@ -514,3 +525,7 @@ }; | ||
} | ||
return settlePromise(self, state, value); | ||
if (state === $resolved) { | ||
settleWithX(self, value); | ||
} else { | ||
settlePromise(self, state, value); | ||
} | ||
}; | ||
@@ -537,5 +552,4 @@ }; | ||
p2._pre = p1; | ||
if (p1._state === $pending) { | ||
p1[p1._pCount++] = p2; | ||
} else { | ||
p1[p1._pCount++] = p2; | ||
if (p1._state !== $pending) { | ||
scheduleHandler(p1, p2); | ||
@@ -635,2 +649,5 @@ } | ||
} | ||
if (isLongStackTrace && x instanceof Yaku) { | ||
p._next = x; | ||
} | ||
if (x !== null && (isFunction(x) || isObject(x))) { | ||
@@ -643,6 +660,2 @@ xthen = genTryCatcher(getThen)(x); | ||
if (isFunction(xthen)) { | ||
if (x instanceof Yaku) { | ||
x._pre = p._pre; | ||
p._pre = x; | ||
} | ||
settleXthen(p, x, xthen); | ||
@@ -649,0 +662,0 @@ } else { |
{ | ||
"name": "yaku", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A ES6 Promise/A+ implementation that doesn't hurt.", | ||
@@ -5,0 +5,0 @@ "main": "dist/yaku.js", |
@@ -16,7 +16,7 @@ # Overview | ||
- The minified file is only 3.4KB ([Bluebird][] / 73KB, [ES6-promise][] / 18KB) | ||
- The minified file is only 3.5KB ([Bluebird][] / 73KB, [ES6-promise][] / 18KB) | ||
- 100% compliant with Promise/A+ specs | ||
- Better performance than the native Promise | ||
- Designed to work on IE5+ and other major browsers | ||
- Possibly unhandled rejection and long stack trace support | ||
- Better `possibly unhandled rejection` and `long stack trace` than [Bluebird][] | ||
- Well commented source code with every Promise/A+ spec | ||
@@ -63,3 +63,3 @@ | ||
| -------------------- | --------- | -------------- | --------- | ------- | --------- | | ||
| Yaku | 872/872 | 283ms | 68ms | ++ | 3.4KB | | ||
| Yaku | 872/872 | 283ms | 68ms | ++ | 3.5KB | | ||
| [Bluebird][] v2.9 | 872/872 | 272ms | 164ms | +++++++ | 73KB | | ||
@@ -71,3 +71,3 @@ | [ES6-promise][] v2.1 | 872/872 | 459ms | 110ms | + | 18KB | | ||
- **Helpers**: extra methods that help with your promise programming, such as | ||
async flow control helpers, debug helpers. | ||
async flow control helpers, debug helpers. For more details: [docs/debugHelperComparison.md][]. | ||
- **1ms async task**: `npm run no -- benchmark`, the smaller the better. | ||
@@ -297,3 +297,3 @@ - **sync task**: `npm run no -- benchmark --sync`, the smaller the better. | ||
- ### **[@enableLongStackTrace](src/yaku.coffee?source#L250)** | ||
- ### **[@enableLongStackTrace](src/yaku.coffee?source#L262)** | ||
@@ -330,2 +330,3 @@ It is used to enable the long stack trace. | ||
[docs/lazyTree.md]: docs/lazyTree.md | ||
[docs/debugHelperComparison.md]: docs/debugHelperComparison.md | ||
[Bluebird]: https://github.com/petkaantonov/bluebird | ||
@@ -332,0 +333,0 @@ [ES6-promise]: https://github.com/jakearchibald/es6-promise |
31844
625
340