Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parley

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parley - npm Package Compare versions

Comparing version 3.4.2 to 3.4.3

6

lib/parley.js

@@ -253,4 +253,4 @@ /**

methodName === 'tolerate' ||
// (Note that we explicitly omit `.log()` and `.now()`
// so that they may be overridden.)
// (Note that we explicitly omit `.log()`, `.now()`, `.timeout()`, and
// `.retry()` so that they may be potentially overridden.)

@@ -267,2 +267,4 @@ // • other special, private properties:

methodName === '_timeout' ||
methodName === '_retryDelaySeries' ||
methodName === '_errorsThatCausedRetries' ||
methodName === '_omen' ||

@@ -269,0 +271,0 @@ methodName === '_userlandAfterExecLCs' ||

@@ -22,3 +22,3 @@ /**

* > The lifecycle callback attached here will run *before* this Deferred's
* > `interceptAfterExec` function (if it has one configured from implementorland.)
* > `_finalAfterExecLC` function (if it has one configured from implementorland.)
* >

@@ -25,0 +25,0 @@ * > Historical notes:

@@ -89,4 +89,2 @@ /**

/**

@@ -209,7 +207,20 @@ * .exec()

// (a new one that we'll call `cb`) which adds some additional checks.
//
// > Note that we don't use .slice() on the `arguments` keyword -- this is for perf.
// > (see https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#what-is-safe-arguments-usage)
cb = function _tryToRunCb(/*…*/) {
// > Note that we don't use .slice() on the `arguments` keyword -- this is for perf.
// > (see https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#what-is-safe-arguments-usage)
var errCbArg;
var resultCbArg;
var extraCbArgs;
if (arguments.length > 2) {
errCbArg = arguments[0];
resultCbArg = arguments[1];
extraCbArgs = Array.prototype.slice.call(arguments, 2);
} else if (arguments.length > 1) {
errCbArg = arguments[0];
resultCbArg = arguments[1];
} else if (arguments.length > 0) {
errCbArg = arguments[0];
}
// ┬ ┬┬─┐┌─┐┌─┐ ┌─┐┌─┐┌┬┐┌─┐┌┐┌┌┬┐┬┌─┐┬ ┬ ┬ ┬ ┌─┐┌─┐┌┐┌┌─┐┬ ┬┌─┐┬┌┐┌┌─┐ ┌─┐┬─┐┬─┐┌─┐┬─┐┌─┐

@@ -224,3 +235,3 @@ // │││├┬┘├─┤├─┘ ├─┘│ │ │ ├┤ │││ │ │├─┤│ │ └┬┘───│ │ ││││├┤ │ │└─┐│││││ ┬ ├┤ ├┬┘├┬┘│ │├┬┘└─┐

// └┴┘┴ ┴ ┴ ┴┴┘└┘ ┴ ┴ ┴└─┘ ┴ ┴┴ ┴┘└┘─┴┘┴─┘└─┘└─┘┴ └─└─┘└─┘ └ └─┘┘└┘└─┘ ┴ ┴└─┘┘└┘
if (arguments[0]) {
if (errCbArg) {

@@ -232,3 +243,3 @@ var doWrap;

// and the code that checks that is not even part of .exec())
if (_.isObject(arguments[0]) && arguments[0].code === 'E_NOT_SYNCHRONOUS') {
if (_.isObject(errCbArg) && errCbArg.code === 'E_NOT_SYNCHRONOUS') {
doWrap = true;

@@ -238,3 +249,3 @@ }

// then wrap it.
else if (_.isObject(arguments[0]) && arguments[0].name === 'TimeoutError' && arguments[0].traceRef !== self) {
else if (_.isObject(errCbArg) && errCbArg.name === 'TimeoutError' && errCbArg.traceRef !== self) {
doWrap = true;

@@ -251,3 +262,3 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

if (doWrap) {
arguments[0] = flaverr.wrap({
errCbArg = flaverr.wrap({
code:

@@ -258,3 +269,3 @@ 'E_FROM_WITHIN',

' [?] See `.raw` for more details, or visit https://sailsjs.com/support for help.',
}, arguments[0], self._omen);
}, errCbArg, self._omen);
}//fi

@@ -268,10 +279,11 @@

// └─┘└─┘└─┘┴└─┴─┘┴ ┴┘└┘─┴┘ ┴ ┴└ ┴ └─┘┴└─└─┘┴ └─└─┘└─┘ ┴─┘└─┘└─┘
// TODO: finish .retry() support, which probably means making .intercept() and .tolerate() support AsyncFunctions
try {
// If this Deferred was configured with after-exec lifecycle callbacks from
// userland via .intercept() or .tolerate(), then call those lifecycle callbacks
// now, if appropriate, picking up the potentially-changed (even potentially-
// reconstructed!) error or result.
// userland via .intercept(), .tolerate(), or .retry(), then call those
// lifecycle callbacks now, if appropriate, picking up the potentially-changed
// (even potentially-reconstructed!) error or result.
//
// > Note that this is only relevant if there was an error of some kind.
if (self._userlandAfterExecLCs && arguments[0]) {
if (self._userlandAfterExecLCs && errCbArg) {

@@ -286,3 +298,3 @@ // Now before proceeding further, check for a match (if there are any configured).

break;
} else if (flaverr.taste(lcDef.rule, arguments[0])) {
} else if (flaverr.taste(lcDef.rule, errCbArg)) {
matchingUserlandLC = lcDef;

@@ -307,3 +319,3 @@ break;

try {
resultFromHandler = matchingUserlandLC.handler(arguments[0]);
resultFromHandler = matchingUserlandLC.handler(errCbArg);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@@ -335,3 +347,3 @@ // FUTURE: add support for this, beginning with something like the

// else {
// resultFromHandler = matchingUserlandLC.handler(arguments[0]);
// resultFromHandler = matchingUserlandLC.handler(errCbArg);
// }

@@ -346,2 +358,7 @@ // ```

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FUTURE: (Maybe) Specifically for `.tolerate()`, allow throwing special exit signals
// from within the handler.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If this is an .intercept() handler, then it's possible the handler threw on purpose,

@@ -390,4 +407,4 @@ // perhaps because it was attempting to send a special signal to its caller (e.g. the

if (matchingUserlandLC.type === 'tolerate') {
arguments[0] = undefined;
arguments[1] = resultFromHandler;
errCbArg = undefined;
resultCbArg = resultFromHandler;
}

@@ -409,6 +426,6 @@ // Swap:

'Regardless, here is a summary of the original underlying error:\n'+
flaverr.parseOrBuildError(arguments[0]).message+'\n'+
flaverr.parseOrBuildError(errCbArg).message+'\n'+
' [?] See https://sailsjs.com/support for help.',
raw:
arguments[0]
errCbArg
}, self._omen);

@@ -455,3 +472,3 @@ }

// Stuff the Error in our arguments.
arguments[0] = interceptError;
errCbArg = interceptError;

@@ -463,8 +480,13 @@ }//fi </ if this is an .intercept() >

} catch (err) {
// If any error was encountered above, then stuff it in `arguments[0]` so
// If any error was encountered above, then stuff it in `errCbArg` so
// that it can still be handled gracefully-- including getting any final
// treatment from implementorland's `finalAfterExecLC`.
arguments[0] = err;
errCbArg = err;
}
// (function(){
// See TODO above
// })(function(err){
//
// });//_∏_ (†)

@@ -481,7 +503,7 @@ // ╔═╗╦╔╗╔╔═╗╦ ┌─┐┌─┐┌┬┐┌─┐┬─┐┌─┐─┐ ┬┌─┐┌─┐ ┬ ┌─┐

if (self._finalAfterExecLC) {
if (arguments[0]) {
arguments[0] = self._finalAfterExecLC(arguments[0]);
if (errCbArg) {
errCbArg = self._finalAfterExecLC(errCbArg);
}
else {
arguments[1] = self._finalAfterExecLC(undefined, arguments[1]);
resultCbArg = self._finalAfterExecLC(undefined, resultCbArg);
}

@@ -491,20 +513,2 @@ }//fi

// ┌─┐┬─┐ ┬ ┌─┐┬─┐┌─┐┬ ┬┌┬┐┌─┐┌┐┌┌┬┐┌─┐ ┌─┐┌┐ ┬┌─┐┌─┐┌┬┐ ┬┌─┐ ┌┐┌┌─┐┌─┐┌─┐┌─┐┌─┐┌─┐┬─┐┬ ┬
// ├┤ │┌┴┬┘ ├─┤├┬┘│ ┬│ ││││├┤ │││ │ └─┐ │ │├┴┐ │├┤ │ │ │├┤ │││├┤ │ ├┤ └─┐└─┐├─┤├┬┘└┬┘
// └ ┴┴ └─ ┴ ┴┴└─└─┘└─┘┴ ┴└─┘┘└┘ ┴ └─┘ └─┘└─┘└┘└─┘└─┘ ┴┘ ┴└ ┘└┘└─┘└─┘└─┘└─┘└─┘┴ ┴┴└─ ┴
// Since we're modifying `arguments` inline, make sure the length is getting set properly.
if (arguments[1] !== undefined && arguments.length < 2) {
arguments.length = 2;
}
else if (arguments[0] !== undefined && arguments.length < 1) {
arguments.length = 1;
}
// console.log('arguments[0]', arguments[0]);
// console.log('arguments[1]', arguments[1]);
// console.log('arguments', arguments);
// console.log('arguments.length', arguments.length);
// (function(){
// console.log('(()=>{ console.log(arguments); }).apply(undefined, arguments)', arguments);
// }).apply(undefined, arguments);
// ┌┐┌┌─┐┬ ┬ ┌─┐┌─┐┌┬┐┬ ┬┌─┐┬ ┬ ┬ ┬ ┌┬┐┬─┐┬┌─┐┌─┐┌─┐┬─┐ ┌─┐┌┐ ┌─┐┌┐┌┌─┐┬ ┬┬─┐┬┌┐┌┌─┐

@@ -530,3 +534,9 @@ // ││││ ││││ ├─┤│ │ │ │├─┤│ │ └┬┘ │ ├┬┘││ ┬│ ┬├┤ ├┬┘ │ ├┴┐ ├┤ │││└─┐│ │├┬┘│││││ ┬

try {
return _cb.apply(undefined, arguments);
if (extraCbArgs) {
return _cb.apply(undefined, [errCbArg, resultCbArg].concat(extraCbArgs));
} else if (resultCbArg !== undefined) {
return _cb(errCbArg, resultCbArg);
} else {
return _cb(errCbArg);
}
} catch (unexpectedErrorFromCallback) {

@@ -539,3 +549,9 @@ return handleUncaughtException(unexpectedErrorFromCallback);

// (If it throws, it will crash the process!)
return _cb.apply(undefined, arguments);
if (extraCbArgs) {
return _cb.apply(undefined, [errCbArg, resultCbArg].concat(extraCbArgs));
} else if (resultCbArg !== undefined) {
return _cb(errCbArg, resultCbArg);
} else {
return _cb(errCbArg);
}

@@ -562,3 +578,9 @@ }//•

try {
return _cb.apply(undefined, arguments);
if (extraCbArgs) {
return _cb.apply(undefined, [errCbArg, resultCbArg].concat(extraCbArgs));
} else if (resultCbArg !== undefined) {
return _cb(errCbArg, resultCbArg);
} else {
return _cb(errCbArg);
}
} catch (unexpectedErrorFromCallback) {

@@ -599,3 +621,3 @@ throw flaverr.wrap({

};//ƒ
};//ƒ </ definition of `cb` >

@@ -642,4 +664,4 @@

console.warn(
'WARNING: Consistency violation: Trying to trigger timeout, but after execution is\n'+
'has already finished! This should not be possible, and the fact that you\'re seeing\n'+
'WARNING: Consistency violation: Trying to trigger timeout, but after execution has\n'+
'already finished! This should not be possible, and the fact that you\'re seeing\n'+
'this message indicates that there is probably a bug somewhere in the tools -- or\n'+

@@ -894,5 +916,5 @@ 'possibly that this Deferred instance has been mutated by userland code.\n'+

};
/**

@@ -911,2 +933,3 @@ * .then()

/**

@@ -969,2 +992,3 @@ * .catch()

/**

@@ -1090,3 +1114,3 @@ * .intercept()

'it is not actually synchronous. Rather than `.now()`, please use '+
'`await`'+(process.version.match(/^v8\./)?'':' or `.exec()`, `.then()`, etc')+'.',
'`await` or `.exec()`, `.then()`, etc.',
}, this._omen);

@@ -1110,4 +1134,2 @@

*
* * * * WARNING: THIS METHOD IS EXPERIMENTAL! * * *
*
* Note: This is for debugging / for exploration purposes, especially

@@ -1119,3 +1141,3 @@ * for use on the Node.js/Sails.js REPL or in the browser console.

if (process.env.NODE_ENV === 'production' && !process.env.DEBUG) {
if (!IS_DEBUG_OR_NON_PRODUCTION_ENV) {
console.warn('* * * * * * * * * * * * * * * * * * * * * * * * * *');

@@ -1167,2 +1189,72 @@ console.warn('Warning: Production environment detected...');

// /**
// * .timeout()
// *
// * Set a timeout for this invocation (i.e. from userland).
// *
// * > Note: This works by reusing/overriding the implementor-land `_timeout` property.
// *
// * @param {Number} ms [number of milliseconds to wait for execution to finish before considering this timed out]
// * @throws {Error} If already begun executing
// */
// Deferred.prototype.timeout = function (ms){
// if (!_.isNumber(ms)) {
// throw flaverr({
// name:
// 'UsageError',
// message:
// 'Invalid usage for `.timeout()`. Please provide a number of milliseconds\n'+
// 'as the first argument, or use 0 to eliminate the timeout for this invocation.'
// }, this._omen);
// }
// if (this._hasBegunExecuting) {
// throw flaverr({
// name:
// 'UsageError',
// message:
// 'Could not attach max milliseconds with `.timeout()` because this invocation\n'+
// 'has already '+(this._hasTimedOut?'timed out':this._hasFinishedExecuting?'finished executing':'begun executing')+'.'
// }, this._omen);
// }
// this._timeout = ms;
// return this;
// };
// /**
// * .retry()
// *
// * Attach an exponential backoff and retry strategy for this invocation.
// *
// * > See `bindUserlandAfterExecLC` utility for details on how this works.
// *
// * > WARNING: Please be sure that the function being wrapped is idempotent, or
// * > at least that you very, very clearly understand what you're doing before
// * > using this function!
// *
// * @throws {Error} If already begun executing
// */
// Deferred.prototype.retry = function (negotiationRuleOrWildcardHandler){
// if (this._hasBegunExecuting) {
// throw flaverr({
// name:
// 'UsageError',
// message:
// 'Could not attach exponential backoff & retry strategy with `.retry()` because\n'+
// 'this invocation has already '+(this._hasTimedOut?'timed out':this._hasFinishedExecuting?'finished executing':'begun executing')+'.'
// }, this._omen);
// }
// this._errorsThatCausedRetries = [];
// this._retryDelaySeries = [100, 200, 400];
// bindUserlandAfterExecLC('retry', negotiationRuleOrWildcardHandler, undefined, this);
// return this;
// };
// Attach `inspect`, `toString`, and `toJSON` functions

@@ -1175,5 +1267,4 @@ // (This is mainly to hide the `_omen` property, which is pretty scary-looking)

// Finally, export the Deferred constructor.
// (we could have done this earlier-- we just do it down here for consistency)
module.exports = Deferred;
{
"name": "parley",
"version": "3.4.2",
"version": "3.4.3",
"description": "Practical, lightweight flow control for Node.js. Supports `await`, callbacks and promises.",

@@ -5,0 +5,0 @@ "main": "lib/parley.js",

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