Comparing version 0.1.8 to 0.1.9
/* | ||
Yaku v0.1.8 | ||
Yaku v0.1.9 | ||
(c) 2015 Yad Smood. http://ysmood.org | ||
@@ -28,3 +28,3 @@ License MIT | ||
*/ | ||
var $circularChain, $function, $handlerStack, $hasUnhandledRejection, $invalid_argument, $isNode, $noop, $object, $pending, $prePromise, $rejected, $resolved, $settlerStack, $tryCatchFn, $tryErr, addHandler, assertIterable, callHanler, genScheduler, genSettler, genTraceInfo, genTryCatcher, genTypeError, getThen, isLongStackTrace, newEmptyYaku, release, scheduleHandler, scheduleUnhandledRejection, settlePromise, settleWithX, settleXthen, tryCatcher; | ||
var $circularChain, $handlerStack, $hasUnhandledRejection, $invalid_argument, $noop, $pending, $prePromise, $rejected, $resolved, $settlerStack, $tryCatchFn, $tryErr, addHandler, assertIterable, callHanler, genScheduler, genSettler, genTraceInfo, genTryCatcher, genTypeError, getThen, isFunction, isLongStackTrace, isObject, newEmptyYaku, release, scheduleHandler, scheduleUnhandledRejection, settlePromise, settleWithX, settleXthen, tryCatcher; | ||
@@ -238,14 +238,19 @@ function Yaku(executor) { | ||
Yaku.onUnhandledRejection = function(reason, p) { | ||
var hStack, stack; | ||
if (typeof console === $object) { | ||
hStack = ''; | ||
if (isLongStackTrace && p[$handlerStack]) { | ||
while (p) { | ||
hStack = p[$handlerStack] + hStack; | ||
p = p[$prePromise]; | ||
} | ||
var $info, hStack, stack; | ||
if (!isObject(console)) { | ||
return; | ||
} | ||
$info = 'Unhandled Rejection:'; | ||
hStack = ''; | ||
if (isLongStackTrace && p[$handlerStack]) { | ||
while (p) { | ||
hStack = p[$handlerStack] + hStack; | ||
p = p[$prePromise]; | ||
} | ||
stack = reason ? reason.stack || reason : reason; | ||
console.error(('Unhandled rejection Error: ' + stack + hStack).replace(RegExp(".+" + __filename + ".+\\n", "g"), '')); | ||
} | ||
if (typeof __filename === 'string') { | ||
hStack = hStack.replace(RegExp(".+" + __filename + ".+\\n", "g"), ''); | ||
} | ||
stack = reason ? reason.stack || reason : reason; | ||
return console.error($info, stack, hStack); | ||
}; | ||
@@ -284,9 +289,11 @@ | ||
$function = 'function'; | ||
isObject = function(obj) { | ||
return typeof obj === 'object'; | ||
}; | ||
$object = 'object'; | ||
isFunction = function(obj) { | ||
return typeof obj === 'function'; | ||
}; | ||
$isNode = typeof process === $object; | ||
/** | ||
@@ -522,6 +529,6 @@ * Release the specified key of an object. | ||
addHandler = function(p1, p2, onFulfilled, onRejected) { | ||
if (typeof onFulfilled === $function) { | ||
if (isFunction(onFulfilled)) { | ||
p2._onFulfilled = onFulfilled; | ||
} | ||
if (typeof onRejected === $function) { | ||
if (isFunction(onRejected)) { | ||
p2._onRejected = onRejected; | ||
@@ -611,3 +618,3 @@ } | ||
settleWithX = function(p, x) { | ||
var type, xthen; | ||
var xthen; | ||
if (x === p && x) { | ||
@@ -617,4 +624,3 @@ settlePromise(p, $rejected, genTypeError($circularChain)); | ||
} | ||
type = typeof x; | ||
if (x !== null && (type === $function || type === $object)) { | ||
if (x !== null && (isFunction(x) || isObject(x))) { | ||
xthen = genTryCatcher(getThen)(x); | ||
@@ -625,3 +631,3 @@ if (xthen === $tryErr) { | ||
} | ||
if (typeof xthen === $function) { | ||
if (isFunction(xthen)) { | ||
if (isLongStackTrace) { | ||
@@ -628,0 +634,0 @@ p[$prePromise] = x; |
{ | ||
"name": "yaku", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"description": "A ES6 Promise/A+ implementation that doesn't hurt.", | ||
@@ -5,0 +5,0 @@ "main": "dist/yaku.js", |
@@ -60,9 +60,9 @@ # Overview | ||
| Name | Unit Test | 1ms async task | sync task | Helpers | file size | | ||
| --------------- | --------- | -------------- | --------- | ------- | --------- | | ||
| Yaku | 872/872 | 283ms | 68ms | ++ | 3.2KB | | ||
| [Bluebird][] | 872/872 | 244ms | 164ms | +++++++ | 73KB | | ||
| [ES6-promise][] | 872/872 | 435ms | 110ms | + | 18KB | | ||
| [native][] | 872/872 | 816ms | 605ms | + | 0KB | | ||
| [q][] | 208/872 | 2637ms | 2327ms | +++ | 24K | | ||
| Name | Unit Test | 1ms async task | sync task | Helpers | file size | | ||
| -------------------- | --------- | -------------- | --------- | ------- | --------- | | ||
| Yaku | 872/872 | 283ms | 68ms | ++ | 3.2KB | | ||
| [Bluebird][] v2.9 | 872/872 | 244ms | 164ms | +++++++ | 73KB | | ||
| [ES6-promise][] v2.1 | 872/872 | 435ms | 110ms | + | 18KB | | ||
| [native][] iojs v1.8 | 872/872 | 816ms | 605ms | + | 0KB | | ||
| [q][] v1.3 | 208/872 | 2637ms | 2327ms | +++ | 24K | | ||
@@ -295,3 +295,3 @@ - **Helpers**: extra methods that help with your promise programming, such as | ||
- ### **[@enableLongStackTrace](src/yaku.coffee?source#L241)** | ||
- ### **[@enableLongStackTrace](src/yaku.coffee?source#L242)** | ||
@@ -298,0 +298,0 @@ It is used to enable the long stack trace. |
31010
596