New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

metal-promise

Package Overview
Dependencies
Maintainers
9
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metal-promise - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

77

lib/ProgressPromise.js

@@ -52,3 +52,5 @@ 'use strict';

/**
* Invokes any listeners that have been attached via the progress` method.
* Overwrites `CancellablePromise.prototype.addChildPromise_` so that it
* implements another `ProgressPromise` as a child.
* @inheritdoc
*/

@@ -58,8 +60,67 @@

_createClass(ProgressPromise, [{
key: 'addChildPromise_',
value: function addChildPromise_(onFulfilled, onRejected, opt_context) {
var callbackEntry = {
child: null,
onFulfilled: null,
onRejected: null
};
callbackEntry.child = new ProgressPromise(function (resolve, reject) {
callbackEntry.onFulfilled = onFulfilled ? function (value) {
try {
var result = onFulfilled.call(opt_context, value);
resolve(result);
} catch (err) {
reject(err);
}
} : resolve;
callbackEntry.onRejected = onRejected ? function (reason) {
try {
var result = onRejected.call(opt_context, reason);
if (!isDef(result) && reason.IS_CANCELLATION_ERROR) {
reject(reason);
} else {
resolve(result);
}
} catch (err) {
reject(err);
}
} : reject;
});
callbackEntry.child.parent_ = this;
this.addCallbackEntry_(callbackEntry);
return callbackEntry.child;
}
/**
* Invokes any listeners that have been attached to child promises.
* @param {!number} progress A percentage between 0 and 1
*/
}, {
key: 'callChildProgressListeners_',
value: function callChildProgressListeners_(progress) {
var _this2 = this;
if (this.callbackEntries_ && this.callbackEntries_.length) {
this.callbackEntries_.forEach(function (callback) {
_this2.callProgressListeners_(progress, callback.child.listeners_);
});
}
}
/**
* Invokes any listeners that have been attached via the `progress` method.
* @param {!number} progress A percentage between 0 and 1
* @param {!Array} listeners Array of listeners
*/
}, {
key: 'callProgressListeners_',
value: function callProgressListeners_() {
var progress = this.progress_;
if (this.listeners_.length) {
this.listeners_.forEach(function (listener) {
value: function callProgressListeners_(progress, listeners) {
if (listeners.length) {
listeners.forEach(function (listener) {
listener(progress);

@@ -112,3 +173,5 @@ });

this.progress_ = progress;
this.callProgressListeners_();
this.callProgressListeners_(progress, this.listeners_);
this.callChildProgressListeners_(progress);
}

@@ -115,0 +178,0 @@ }]);

2

package.json
{
"name": "metal-promise",
"version": "3.0.0",
"version": "3.0.1",
"description": "Promises polyfill from Google's Closure Library in ES6",

@@ -5,0 +5,0 @@ "license": "BSD",

@@ -30,9 +30,62 @@ 'use strict';

/**
* Invokes any listeners that have been attached via the progress` method.
* Overwrites `CancellablePromise.prototype.addChildPromise_` so that it
* implements another `ProgressPromise` as a child.
* @inheritdoc
*/
callProgressListeners_() {
const progress = this.progress_;
addChildPromise_(onFulfilled, onRejected, opt_context) {
var callbackEntry = {
child: null,
onFulfilled: null,
onRejected: null
};
if (this.listeners_.length) {
this.listeners_.forEach(listener => {
callbackEntry.child = new ProgressPromise(function(resolve, reject) {
callbackEntry.onFulfilled = onFulfilled ? function(value) {
try {
var result = onFulfilled.call(opt_context, value);
resolve(result);
} catch (err) {
reject(err);
}
} : resolve;
callbackEntry.onRejected = onRejected ? function(reason) {
try {
var result = onRejected.call(opt_context, reason);
if (!isDef(result) && reason.IS_CANCELLATION_ERROR) {
reject(reason);
} else {
resolve(result);
}
} catch (err) {
reject(err);
}
} : reject;
});
callbackEntry.child.parent_ = this;
this.addCallbackEntry_(callbackEntry);
return callbackEntry.child;
}
/**
* Invokes any listeners that have been attached to child promises.
* @param {!number} progress A percentage between 0 and 1
*/
callChildProgressListeners_(progress) {
if (this.callbackEntries_ && this.callbackEntries_.length) {
this.callbackEntries_.forEach(callback => {
this.callProgressListeners_(progress, callback.child.listeners_);
});
}
}
/**
* Invokes any listeners that have been attached via the `progress` method.
* @param {!number} progress A percentage between 0 and 1
* @param {!Array} listeners Array of listeners
*/
callProgressListeners_(progress, listeners) {
if (listeners.length) {
listeners.forEach(listener => {
listener(progress);

@@ -76,3 +129,5 @@ });

this.progress_ = progress;
this.callProgressListeners_();
this.callProgressListeners_(progress, this.listeners_);
this.callChildProgressListeners_(progress);
}

@@ -79,0 +134,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc