/
usr
/
local
/
lib
/
node_modules
/
pm2
/
node_modules
/
extrareqp2
/
lib
/
cancel
/
/usr/local/lib/node_modules/pm2/node_modules/extrareqp2/lib/cancel
mkdir
upload
Name
Size
Mode
Actions
Cancel.js
385
0644
edit
dl
rm
CancelToken.js
1240
0644
edit
dl
rm
isCancel.js
102
0644
edit
dl
rm
Edit:
/usr/local/lib/node_modules/pm2/node_modules/extrareqp2/lib/cancel/CancelToken.js
(1240B)
'use strict'; var Cancel = require('./Cancel'); /** * A `CancelToken` is an object that can be used to request cancellation of an operation. * * @class * @param {Function} executor The executor function. */ function CancelToken(executor) { if (typeof executor !== 'function') { throw new TypeError('executor must be a function.'); } var resolvePromise; this.promise = new Promise(function promiseExecutor(resolve) { resolvePromise = resolve; }); var token = this; executor(function cancel(message) { if (token.reason) { // Cancellation has already been requested return; } token.reason = new Cancel(message); resolvePromise(token.reason); }); } /** * Throws a `Cancel` if cancellation has been requested. */ CancelToken.prototype.throwIfRequested = function throwIfRequested() { if (this.reason) { throw this.reason; } }; /** * Returns an object that contains a new `CancelToken` and a function that, when called, * cancels the `CancelToken`. */ CancelToken.source = function source() { var cancel; var token = new CancelToken(function executor(c) { cancel = c; }); return { token: token, cancel: cancel }; }; module.exports = CancelToken;
Save
cmd:
run