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

babel-runtime-named-params

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-runtime-named-params - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

2

lib/babel-runtime-named-params.browser.js

@@ -30,4 +30,4 @@ /*

},{}],2:[function(_dereq_,module,exports){
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},funcParams=_dereq_("func-params");function callFunctionWithNamedParameters(e,r,t,n){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if("function"!=typeof r)throw new Error("invalid function parameter");if(!("object"===(void 0===t?"undefined":_typeof(t))&&t instanceof Array))throw new Error("invalid positional-parameter parameter");if("object"!==(void 0===n?"undefined":_typeof(n)))throw new Error("invalid named-parameter parameter");for(var a=funcParams(r,o),i=new Array(a.length),f=new Array(a.length),c=0;c<a.length;c++)i[c]=void 0,f[c]=!1;var p=a.findIndex(function(e){return e.match(/^(?:opt(?:ion)?|setting)s?$/)});Object.keys(n).forEach(function(e){var r=a.indexOf(e);if(r<0&&p>=0)f[p]||(i[p]={}),i[p][e]=n[e],f[p]=!0;else if(r>=0&&r===p){if("object"!==_typeof(n[e]))throw new Error('invalid type of option-style named parameter "'+e+'" (expected object)');f[p]||(i[p]={}),i[p]=Object.assign({},n[e],i[p]),f[p]=!0}else{if(!(r>=0))throw new Error('unknown named parameter "'+e+'"');i[r]=n[e],f[r]=!0}});for(var l=0,m=0;m<t.length;m++){for(;l<a.length&&f[l];)l++;i[l++]=t[m]}return r.apply(e,i)}module.exports=callFunctionWithNamedParameters;
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},funcParams=_dereq_("func-params");function callFunctionWithNamedParameters(e,t,o,r){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if("function"!=typeof t)throw new Error("invalid function parameter");if(!("object"===(void 0===o?"undefined":_typeof(o))&&o instanceof Array))throw new Error("invalid positional-parameter parameter");if("object"!==(void 0===r?"undefined":_typeof(r)))throw new Error("invalid named-parameter parameter");if("object"!==(void 0===n?"undefined":_typeof(n)))throw new Error("invalid options parameter");n=Object.assign({},{options:!0,caching:!0},n);for(var i=funcParams(t,n.caching),a=new Array(i.length),f=new Array(i.length),c=0;c<i.length;c++)a[c]=void 0,f[c]=!1;var p=n.options?i.findIndex(function(e){return e.match(/^(?:opt(?:ion)?|setting)s?$/)}):-1;Object.keys(r).forEach(function(e){var t=i.indexOf(e);if(n.options&&t<0&&p>=0)f[p]||(a[p]={}),a[p][e]=r[e],f[p]=!0;else if(n.options&&t>=0&&t===p){if("object"!==_typeof(r[e]))throw new Error('invalid type of option-style named parameter "'+e+'" (expected object)');f[p]||(a[p]={}),a[p]=Object.assign({},r[e],a[p]),f[p]=!0}else{if(!(t>=0))throw new Error('unknown named parameter "'+e+'"');a[t]=r[e],f[t]=!0}});for(var l=0,s=0;s<o.length;s++){for(;l<i.length&&f[l];)l++;a[l++]=o[s]}return t.apply(e,a)}module.exports=callFunctionWithNamedParameters;
},{"func-params":1}]},{},[2])(2)
});

@@ -98,3 +98,3 @@ /*

function callFunctionWithNamedParameters(ctx, fn, pp, np) {
var caching = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};

@@ -105,5 +105,12 @@ /* sanity check arguments */

if (!((typeof np === "undefined" ? "undefined" : _typeof(np)) === "object")) throw new Error("invalid named-parameter parameter");
if (!((typeof options === "undefined" ? "undefined" : _typeof(options)) === "object")) throw new Error("invalid options parameter");
/* determine options */
options = Object.assign({}, {
options: true,
caching: true
}, options);
/* determine function parameter names */
var names = funcParams(fn, caching);
var names = funcParams(fn, options.caching);

@@ -119,5 +126,5 @@ /* initialize function arguments */

/* detect special options argument */
var optIndex = names.findIndex(function (name) {
var optIndex = options.options ? names.findIndex(function (name) {
return name.match(/^(?:opt(?:ion)?|setting)s?$/);
});
}) : -1;

@@ -127,7 +134,7 @@ /* process named parameters */

var i = names.indexOf(name);
if (i < 0 && optIndex >= 0) {
if (options.options && i < 0 && optIndex >= 0) {
if (!mask[optIndex]) args[optIndex] = {};
args[optIndex][name] = np[name];
mask[optIndex] = true;
} else if (i >= 0 && i === optIndex) {
} else if (options.options && i >= 0 && i === optIndex) {
if (_typeof(np[name]) !== "object") throw new Error("invalid type of option-style named parameter \"" + name + "\" (expected object)");

@@ -134,0 +141,0 @@ if (!mask[optIndex]) args[optIndex] = {};

@@ -5,3 +5,3 @@ {

"description": "Babel Run-Time for Named Function Parameters",
"version": "0.9.1",
"version": "0.9.2",
"license": "MIT",

@@ -8,0 +8,0 @@ "author": {

@@ -20,3 +20,3 @@

It exports a single trampoline function
`T(ctx: any, fn: Function, pp: any[], np: Object, caching?: boolean): any`
`T(ctx: any, fn: Function, pp: any[], np: Object, options?: boolean, caching?: boolean): any`
which calls `fn` (bound to context object `ctx`) with an argument list

@@ -23,0 +23,0 @@ based on the positional parameters in `pp` and the named parameters in `np`.

@@ -29,3 +29,3 @@ /*

/* the API function */
function callFunctionWithNamedParameters (ctx, fn, pp, np, caching = true) {
function callFunctionWithNamedParameters (ctx, fn, pp, np, options = {}) {
/* sanity check arguments */

@@ -38,5 +38,13 @@ if (!(typeof fn === "function"))

throw new Error("invalid named-parameter parameter")
if (!(typeof options === "object"))
throw new Error("invalid options parameter")
/* determine options */
options = Object.assign({}, {
options: true,
caching: true
}, options)
/* determine function parameter names */
let names = funcParams(fn, caching)
let names = funcParams(fn, options.caching)

@@ -52,4 +60,4 @@ /* initialize function arguments */

/* detect special options argument */
let optIndex = names.findIndex((name) =>
name.match(/^(?:opt(?:ion)?|setting)s?$/))
let optIndex = options.options ? names.findIndex((name) =>
name.match(/^(?:opt(?:ion)?|setting)s?$/)) : -1

@@ -59,3 +67,3 @@ /* process named parameters */

let i = names.indexOf(name)
if (i < 0 && optIndex >= 0) {
if (options.options && i < 0 && optIndex >= 0) {
if (!mask[optIndex])

@@ -66,3 +74,3 @@ args[optIndex] = {}

}
else if (i >= 0 && i === optIndex) {
else if (options.options && i >= 0 && i === optIndex) {
if (typeof np[name] !== "object")

@@ -69,0 +77,0 @@ throw new Error(`invalid type of option-style named parameter "${name}" (expected object)`)

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