Comparing version 0.1.11 to 0.1.12
@@ -6,21 +6,19 @@ 'use strict'; | ||
var PromiseInspection$1 = PromiseInspection = class PromiseInspection { | ||
constructor(arg) { | ||
var reason, state, value; | ||
state = arg.state, value = arg.value, reason = arg.reason; | ||
this.state = state; | ||
this.value = value; | ||
this.reason = reason; | ||
var PromiseInspection$1 = PromiseInspection = (function() { | ||
function PromiseInspection(arg) { | ||
this.state = arg.state, this.value = arg.value, this.reason = arg.reason; | ||
} | ||
isFulfilled() { | ||
PromiseInspection.prototype.isFulfilled = function() { | ||
return this.state === 'fulfilled'; | ||
} | ||
}; | ||
isRejected() { | ||
PromiseInspection.prototype.isRejected = function() { | ||
return this.state === 'rejected'; | ||
} | ||
}; | ||
}; | ||
return PromiseInspection; | ||
})(); | ||
// src/utils.coffee | ||
@@ -135,14 +133,18 @@ var _undefined$1 = void 0; | ||
Promise$1 = class Promise { | ||
constructor(fn) { | ||
Promise$1 = (function() { | ||
function Promise(fn) { | ||
if (fn) { | ||
fn((arg) => { | ||
return this.resolve(arg); | ||
}, (arg) => { | ||
return this.reject(arg); | ||
}); | ||
fn((function(_this) { | ||
return function(arg) { | ||
return _this.resolve(arg); | ||
}; | ||
})(this), (function(_this) { | ||
return function(arg) { | ||
return _this.reject(arg); | ||
}; | ||
})(this)); | ||
} | ||
} | ||
resolve(value) { | ||
Promise.prototype.resolve = function(value) { | ||
var clients, err, first, next; | ||
@@ -160,15 +162,19 @@ if (this.state !== STATE_PENDING) { | ||
if (typeof next === 'function') { | ||
next.call(value, (ra) => { | ||
if (first) { | ||
next.call(value, (function(_this) { | ||
return function(ra) { | ||
if (first) { | ||
if (first) { | ||
first = false; | ||
} | ||
_this.resolve(ra); | ||
} | ||
}; | ||
})(this), (function(_this) { | ||
return function(rr) { | ||
if (first) { | ||
first = false; | ||
_this.reject(rr); | ||
} | ||
this.resolve(ra); | ||
} | ||
}, (rr) => { | ||
if (first) { | ||
first = false; | ||
this.reject(rr); | ||
} | ||
}); | ||
}; | ||
})(this)); | ||
return; | ||
@@ -187,13 +193,15 @@ } | ||
if (clients = this.c) { | ||
soon$1(() => { | ||
var c, i, len; | ||
for (i = 0, len = clients.length; i < len; i++) { | ||
c = clients[i]; | ||
resolveClient(c, value); | ||
} | ||
}); | ||
soon$1((function(_this) { | ||
return function() { | ||
var c, i, len; | ||
for (i = 0, len = clients.length; i < len; i++) { | ||
c = clients[i]; | ||
resolveClient(c, value); | ||
} | ||
}; | ||
})(this)); | ||
} | ||
} | ||
}; | ||
reject(reason) { | ||
Promise.prototype.reject = function(reason) { | ||
var clients; | ||
@@ -216,5 +224,5 @@ if (this.state !== STATE_PENDING) { | ||
} | ||
} | ||
}; | ||
then(onFulfilled, onRejected) { | ||
Promise.prototype.then = function(onFulfilled, onRejected) { | ||
var a, client, p, s; | ||
@@ -245,27 +253,29 @@ p = new Promise; | ||
return p; | ||
} | ||
}; | ||
["catch"](cfn) { | ||
Promise.prototype["catch"] = function(cfn) { | ||
return this.then(null, cfn); | ||
} | ||
}; | ||
["finally"](cfn) { | ||
Promise.prototype["finally"] = function(cfn) { | ||
return this.then(cfn, cfn); | ||
} | ||
}; | ||
timeout(ms, msg) { | ||
Promise.prototype.timeout = function(ms, msg) { | ||
msg = msg || 'timeout'; | ||
return new Promise((resolve, reject) => { | ||
setTimeout(function() { | ||
return reject(Error(msg)); | ||
}, ms); | ||
this.then(function(val) { | ||
resolve(val); | ||
}, function(err) { | ||
reject(err); | ||
}); | ||
}); | ||
} | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
setTimeout(function() { | ||
return reject(Error(msg)); | ||
}, ms); | ||
_this.then(function(val) { | ||
resolve(val); | ||
}, function(err) { | ||
reject(err); | ||
}); | ||
}; | ||
})(this)); | ||
}; | ||
callback(cb) { | ||
Promise.prototype.callback = function(cb) { | ||
if (typeof cb === 'function') { | ||
@@ -280,6 +290,8 @@ this.then(function(val) { | ||
return this; | ||
} | ||
}; | ||
}; | ||
return Promise; | ||
})(); | ||
var Promise$2 = Promise$1; | ||
@@ -286,0 +298,0 @@ |
{ | ||
"name": "broken", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "Promises are meant to be broken.", | ||
@@ -22,7 +22,7 @@ "homepage": "https://github.com/zeekay/broken#readme", | ||
"devDependencies": { | ||
"cake-bundle": "0.2.2", | ||
"cake-outdated": "0.1.13", | ||
"cake-publish": "0.1.5", | ||
"cake-bundle": "0.2.17", | ||
"cake-outdated": "0.1.16", | ||
"cake-publish": "0.1.10", | ||
"cake-test": "0.1.0", | ||
"cake-version": "0.1.11", | ||
"cake-version": "0.1.14", | ||
"chai": "3.5.0", | ||
@@ -33,3 +33,3 @@ "chai-as-promised": "6.0.0", | ||
"mocha": "3.2.0", | ||
"shortcake": "1.2.5" | ||
"shortcake": "1.2.7" | ||
}, | ||
@@ -36,0 +36,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55732
657