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

args-js

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

args-js - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

10

Args.js

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

"use strict";
var _extractSchemeEl = function(rawSchemeEl) {

@@ -152,10 +154,8 @@ var schemeEl = {};

var Args = function(scheme, args) {
if (scheme === undefined) throw new Error("The scheme has not been passed.");
if (args === undefined) throw new Error("The arguments have not been passed.");
var returns = {};
var err = undefined;
try {
args = args || Args.caller.arguments;
} catch(e) {};
args = args || [];
var a, s;

@@ -162,0 +162,0 @@

@@ -1,1 +0,1 @@

var Args=function(){var e=function(e){var n={};n.defValue=void 0,n.typeValue=void 0;for(var t in e)e.hasOwnProperty(t)&&("_default"===t?n.defValue=e[t]:"_type"===t?n.typeValue=e[t]:n.sname=t);return n.sarg=e[n.sname],n},n=function(e,n,t){return 0!==(n&o.STRING)&&"string"==typeof e?!0:0!==(n&o.FUNCTION)&&"function"==typeof e?!0:0!==(n&o.INT)&&"number"==typeof e&&Math.floor(e)===e?!0:0!==(n&o.FLOAT)&&"number"==typeof e?!0:0!==(n&o.ARRAY)&&e instanceof Array?!0:0!==(n&o.OBJECT)&&"object"==typeof e&&(void 0===t||e instanceof t)?!0:0!==(n&o.ARRAY_BUFFER)&&e.toString().match(/ArrayBuffer/)?!0:0!==(n&o.DATE)&&e instanceof Date?!0:0!==(n&o.BOOL)&&"boolean"==typeof e?!0:0!==(n&o.DOM_EL)&&(e instanceof HTMLElement||void 0!==window.$&&e instanceof window.$)?!0:!1},t=function(e){return 0!=(e&(o.STRING|o.FUNCTION|o.INT|o.FLOAT|o.OBJECT|o.ARRAY_BUFFER|o.DATE|o.BOOL|o.DOM_EL|o.ARRAY))},r=function(e,n){return 0!==(e&o.STRING)?"String":0!==(e&o.FUNCTION)?"Function":0!==(e&o.INT)?"Int":0!==(e&o.FLOAT)?"Float":0!==(e&o.ARRAY)?"Array":0!==(e&o.OBJECT)?void 0!==n?"Object ("+n.toString()+")":"Object":0!==(e&o.ARRAY_BUFFER)?"Arry Buffer":0!==(e&o.DATE)?"Date":0!==(e&o.BOOL)?"Bool":0!==(e&o.DOM_EL)?"DOM Element":"unknown"},a=function(t,r,a){for(var o=!1,u=0;u<r.length;u++)o&=function(e){var r=!1;for(var o in t){var u=t[o];if(o===e.sname&&n(u,e.sarg,e.type)){a[o]=u,r=!0;break}}return r}(e(r[u]));return o},o=function(u,i){var f,l,s={},A=void 0,O=!1;for(f=0,l=0;(f<i.length,l<u.length)&&(f=function(a,f){var l=i[a],d=e(u[f]);if(0!==(d.sarg&o.NotNull))return null===l||void 0===l?(O=!0,A="Argument "+a+" ("+d.sname+") is null or undefined but it must be not null.",a):n(l,d.sarg,d.typeValue)?(s[d.sname]=l,a+1):(O=!0,A=t(d.sarg)?"Argument "+a+" ("+d.sname+") should be type "+r(d.sarg,d.typeValue)+", but it was type "+typeof l+" with value "+l+".":"Argument "+a+" ("+d.sname+") has no valid type specified.",a);if(0!==(d.sarg&o.Optional)){if(null===l||void 0===l)return s[d.sname]=void 0!==d.defValue?d.defValue:l,a+1;if(n(l,d.sarg,d.typeValue))return s[d.sname]=l,a+1;if(void 0!==d.defValue)return s[d.sname]=d.defValue,a}return a}(f,l),!A);l++);var d=f<i.length&&"object"==typeof i[f];if(d)var R=i[f],T=a(R,u,s);if(A&&O&&(!d||!T))throw new Error(A);return s};return o.STRING=1,o.FUNCTION=2,o.INT=4,o.FLOAT=8,o.ARRAY_BUFFER=16,o.OBJECT=32,o.DATE=64,o.BOOL=128,o.DOM_EL=256,o.ARRAY=512,o.Optional=1024,o.NotNull=o.Required=2048,o}();try{module.exports=Args}catch(e){}
var Args=function(){"use strict";var e=function(e){var n={};n.defValue=void 0,n.typeValue=void 0;for(var t in e)e.hasOwnProperty(t)&&("_default"===t?n.defValue=e[t]:"_type"===t?n.typeValue=e[t]:n.sname=t);return n.sarg=e[n.sname],n},n=function(e,n,t){return 0!==(n&a.STRING)&&"string"==typeof e?!0:0!==(n&a.FUNCTION)&&"function"==typeof e?!0:0!==(n&a.INT)&&"number"==typeof e&&Math.floor(e)===e?!0:0!==(n&a.FLOAT)&&"number"==typeof e?!0:0!==(n&a.ARRAY)&&e instanceof Array?!0:0!==(n&a.OBJECT)&&"object"==typeof e&&(void 0===t||e instanceof t)?!0:0!==(n&a.ARRAY_BUFFER)&&e.toString().match(/ArrayBuffer/)?!0:0!==(n&a.DATE)&&e instanceof Date?!0:0!==(n&a.BOOL)&&"boolean"==typeof e?!0:0!==(n&a.DOM_EL)&&(e instanceof HTMLElement||void 0!==window.$&&e instanceof window.$)?!0:!1},t=function(e){return 0!=(e&(a.STRING|a.FUNCTION|a.INT|a.FLOAT|a.OBJECT|a.ARRAY_BUFFER|a.DATE|a.BOOL|a.DOM_EL|a.ARRAY))},r=function(e,n){return 0!==(e&a.STRING)?"String":0!==(e&a.FUNCTION)?"Function":0!==(e&a.INT)?"Int":0!==(e&a.FLOAT)?"Float":0!==(e&a.ARRAY)?"Array":0!==(e&a.OBJECT)?void 0!==n?"Object ("+n.toString()+")":"Object":0!==(e&a.ARRAY_BUFFER)?"Arry Buffer":0!==(e&a.DATE)?"Date":0!==(e&a.BOOL)?"Bool":0!==(e&a.DOM_EL)?"DOM Element":"unknown"},o=function(t,r,o){for(var a=!1,u=0;u<r.length;u++)a&=function(e){var r=!1;for(var a in t){var u=t[a];if(a===e.sname&&n(u,e.sarg,e.type)){o[a]=u,r=!0;break}}return r}(e(r[u]));return a},a=function(u,i){if(void 0===u)throw new Error("The scheme has not been passed.");if(void 0===i)throw new Error("The arguments have not been passed.");var f,l,s={},d=void 0;for(f=0,l=0;(f<i.length,l<u.length)&&(f=function(o,f){var l=i[o];if(u[f]instanceof Array){if(null===l||void 0===l)return d="Argument "+o+" is null or undefined but it must be not null.",o;for(var v=u[f],A=void 0,O=0;O<v.length;O++){var p=e(v[O]);n(l,p.sarg,p.typeValue)&&(A=p.sname)}if(void 0===A){d="Argument "+o+" should be one of: ";for(var O=0;O<v.length;O++){var p=e(v[O]);d+=r(p.sarg,p.typeValue)+", "}return d+="but it was type "+typeof l+" with value "+l+".",o}return s[A]=l,o+1}var p=e(u[f]);if(0!==(p.sarg&a.NotNull))return null===l||void 0===l?(d="Argument "+o+" ("+p.sname+") is null or undefined but it must be not null.",o):n(l,p.sarg,p.typeValue)?(s[p.sname]=l,o+1):(d=t(p.sarg)?"Argument "+o+" ("+p.sname+") should be type "+r(p.sarg,p.typeValue)+", but it was type "+typeof l+" with value "+l+".":"Argument "+o+" ("+p.sname+") has no valid type specified.",o);if(0!==(p.sarg&a.Optional)){if(null===l||void 0===l)return s[p.sname]=void 0!==p.defValue?p.defValue:l,o+1;if(n(l,p.sarg,p.typeValue))return s[p.sname]=l,o+1;if(void 0!==p.defValue)return s[p.sname]=p.defValue,o}return o}(f,l),!d);l++);var v=f<i.length&&"object"==typeof i[f];if(v)var A=i[f],O=o(A,u,s);if(d&&(!v||!O))throw new Error(d);return s};return a.STRING=1,a.FUNCTION=2,a.INT=4,a.FLOAT=8,a.ARRAY_BUFFER=16,a.OBJECT=32,a.DATE=64,a.BOOL=128,a.DOM_EL=256,a.ARRAY=512,a.Optional=1024,a.NotNull=a.Required=2048,a}();try{module.exports=Args}catch(e){}
{
"name": "args-js",
"version": "0.7.0",
"version": "0.8.0",
"description": "Create javascript functions with optional, default and named paramaters.",

@@ -5,0 +5,0 @@ "keywords": ["function", "args", "arguments", "paramaters", "api"],

#Args.js
Args.js lets you easily create functions with optional paramaters, default paramaters, paramater groups and named paramaters. It checks types and will trigger exceptions if a function is called incorrectly.
Args.js lets you easily create functions with optional parameters, default parameters, parameter groups and named parameters. It checks types and will trigger exceptions if a function is called incorrectly.
See [the homepage](http://autographer.github.io/args.js/) for more details.
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