cancelable-promise
Advanced tools
Comparing version 2.4.1 to 2.5.0
@@ -41,21 +41,24 @@ const handleCallback = (resolve, reject, callback, r) => { | ||
const p = new CancelablePromise((resolve, reject) => { | ||
this._promise.then((r) => { | ||
if (this._canceled) { | ||
p.cancel(); | ||
this._promise.then( | ||
r => { | ||
if (this._canceled) { | ||
p.cancel(); | ||
} | ||
if (success && !this._canceled) { | ||
handleCallback(resolve, reject, success, r); | ||
} else { | ||
resolve(r); | ||
} | ||
}, | ||
r => { | ||
if (this._canceled) { | ||
p.cancel(); | ||
} | ||
if (error && !this._canceled) { | ||
handleCallback(resolve, reject, error, r); | ||
} else { | ||
reject(r); | ||
} | ||
} | ||
if (success && !this._canceled) { | ||
handleCallback(resolve, reject, success, r); | ||
} else { | ||
resolve(r); | ||
} | ||
}, (r) => { | ||
if (this._canceled) { | ||
p.cancel(); | ||
} | ||
if (error && !this._canceled) { | ||
handleCallback(resolve, reject, error, r); | ||
} else { | ||
reject(r); | ||
} | ||
}); | ||
); | ||
}); | ||
@@ -62,0 +65,0 @@ return p; |
@@ -6,7 +6,10 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var handleCallback = function handleCallback(resolve, reject, callback, r) { | ||
@@ -20,3 +23,5 @@ try { | ||
var CancelablePromise = function () { | ||
var CancelablePromise = | ||
/*#__PURE__*/ | ||
function () { | ||
_createClass(CancelablePromise, null, [{ | ||
@@ -69,2 +74,3 @@ key: "all", | ||
} | ||
if (success && !_this._canceled) { | ||
@@ -79,2 +85,3 @@ handleCallback(resolve, reject, success, r); | ||
} | ||
if (error && !_this._canceled) { | ||
@@ -98,5 +105,7 @@ handleCallback(resolve, reject, error, r); | ||
this._canceled = true; | ||
if (errorCallback) { | ||
this._promise.catch(errorCallback); | ||
} | ||
return this; | ||
@@ -103,0 +112,0 @@ } |
{ | ||
"name": "cancelable-promise", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "A simple cancelable promise", | ||
"main": "dist/CancelablePromise.js", | ||
"jsnext:main": "CancelablePromise.js", | ||
"files": [ | ||
"dist/CancelablePromise.js", | ||
"CancelablePromise.js", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"scripts": { | ||
@@ -20,20 +27,12 @@ "test": "mocha --opts mocha.opts", | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"babelify" | ||
] | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
] | ||
}, | ||
"homepage": "https://github.com/alkemics/CancelablePromise#readme", | ||
"devDependencies": { | ||
"babel-cli": "~6.16.0", | ||
"babel-core": "~6.17.0", | ||
"babel-preset-es2015": "~6.16.0", | ||
"chai": "~3.5.0", | ||
"mocha": "~3.1.2" | ||
"@babel/cli": "~7.5.0", | ||
"@babel/core": "~7.5.4", | ||
"@babel/preset-env": "~7.5.4", | ||
"@babel/register": "~7.4.4", | ||
"chai": "~4.2.0", | ||
"mocha": "~6.1.4", | ||
"prettier": "~1.18.2" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
24613
7
5
167
2