aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/bluebird/js/release/bind.js
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-04-12 21:47:49 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2017-04-25 10:52:01 -0400
commit00842604483e4c2e622dfdb3a97440e07646158f (patch)
treef3346902636a44b6037652523767636bf7e4f2c9 /deps/npm/node_modules/bluebird/js/release/bind.js
parent061c5da010e0d249379618382a499840d38247b8 (diff)
downloadandroid-node-v8-00842604483e4c2e622dfdb3a97440e07646158f.tar.gz
android-node-v8-00842604483e4c2e622dfdb3a97440e07646158f.tar.bz2
android-node-v8-00842604483e4c2e622dfdb3a97440e07646158f.zip
deps: upgrade npm to 4.5.0
PR-URL: https://github.com/nodejs/node/pull/12480 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/node_modules/bluebird/js/release/bind.js')
-rw-r--r--deps/npm/node_modules/bluebird/js/release/bind.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/deps/npm/node_modules/bluebird/js/release/bind.js b/deps/npm/node_modules/bluebird/js/release/bind.js
new file mode 100644
index 0000000000..fc3379db28
--- /dev/null
+++ b/deps/npm/node_modules/bluebird/js/release/bind.js
@@ -0,0 +1,67 @@
+"use strict";
+module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
+var calledBind = false;
+var rejectThis = function(_, e) {
+ this._reject(e);
+};
+
+var targetRejected = function(e, context) {
+ context.promiseRejectionQueued = true;
+ context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
+};
+
+var bindingResolved = function(thisArg, context) {
+ if (((this._bitField & 50397184) === 0)) {
+ this._resolveCallback(context.target);
+ }
+};
+
+var bindingRejected = function(e, context) {
+ if (!context.promiseRejectionQueued) this._reject(e);
+};
+
+Promise.prototype.bind = function (thisArg) {
+ if (!calledBind) {
+ calledBind = true;
+ Promise.prototype._propagateFrom = debug.propagateFromFunction();
+ Promise.prototype._boundValue = debug.boundValueFunction();
+ }
+ var maybePromise = tryConvertToPromise(thisArg);
+ var ret = new Promise(INTERNAL);
+ ret._propagateFrom(this, 1);
+ var target = this._target();
+ ret._setBoundTo(maybePromise);
+ if (maybePromise instanceof Promise) {
+ var context = {
+ promiseRejectionQueued: false,
+ promise: ret,
+ target: target,
+ bindingPromise: maybePromise
+ };
+ target._then(INTERNAL, targetRejected, undefined, ret, context);
+ maybePromise._then(
+ bindingResolved, bindingRejected, undefined, ret, context);
+ ret._setOnCancel(maybePromise);
+ } else {
+ ret._resolveCallback(target);
+ }
+ return ret;
+};
+
+Promise.prototype._setBoundTo = function (obj) {
+ if (obj !== undefined) {
+ this._bitField = this._bitField | 2097152;
+ this._boundTo = obj;
+ } else {
+ this._bitField = this._bitField & (~2097152);
+ }
+};
+
+Promise.prototype._isBound = function () {
+ return (this._bitField & 2097152) === 2097152;
+};
+
+Promise.bind = function (thisArg, value) {
+ return Promise.resolve(value).bind(thisArg);
+};
+};