New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ducky

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ducky - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

2

bower.json
{
"name": "ducky",
"version": "2.2.2",
"version": "2.3.0",
"description": "Duck-Typed Value Handling for JavaScript",

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

@@ -49,3 +49,3 @@ /*

]}],
"babelify"
[ "babelify", { presets: [ "es2015" ] } ]
],

@@ -75,3 +75,3 @@ plugin: [

]}],
"babelify"
[ "babelify", { presets: [ "es2015" ] } ]
],

@@ -78,0 +78,0 @@ plugin: [

@@ -26,5 +26,5 @@ /*!

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Ducky = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:2,minor:2,micro:2,date:20150801};exports.version=version;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:2,minor:3,micro:0,date:20151212};exports.version=version;
},{}],2:[function(_dereq_,module,exports){
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,s,n){return s&&e(t.prototype,s),n&&e(t,n),t}}(),Token=function(){function e(){_classCallCheck(this,e),this.name="",this.text="",this.tokens=[],this.pos=0,this.len=0}return _createClass(e,[{key:"setName",value:function(e){this.name=e}},{key:"setText",value:function(e){this.text=e}},{key:"addToken",value:function(e,t,s,n,o){this.tokens.push({b1:e,b2:t,e2:s,e1:n,symbol:o}),this.len++}},{key:"peek",value:function(e){if("undefined"==typeof e&&(e=0),e>=this.len)throw new Error(this.name+": parse error: not enough tokens");return this.tokens[this.pos+e].symbol}},{key:"skip",value:function(e){if("undefined"==typeof e&&(e=1),e>this.len)throw new Error(this.name+": parse error: not enough tokens available to skip: "+this.ctx());this.pos+=e,this.len-=e}},{key:"consume",value:function(e){if(this.len<=0)throw new Error(this.name+": parse error: no more tokens available to consume: "+this.ctx());if(this.tokens[this.pos].symbol!==e)throw new Error(this.name+': parse error: expected token symbol "'+e+'": '+this.ctx());this.pos++,this.len--}},{key:"ctx",value:function t(e){"undefined"==typeof e&&(e=78);var s=this.tokens[this.pos],t="<"+this.text.substr(s.b2,s.e2-s.b2+1)+">";t=this.text.substr(s.b1,s.b2-s.b1)+t,t+=this.text.substr(s.e2+1,s.e1-s.e2);var n=e-t.length;if(n>0){n=Math.floor(n/2);var o=void 0,i=void 0;if(this.pos>0){var r=0;for(o=this.pos-1;o>=0&&(s=this.tokens[o],i=this.text.substr(s.b1,s.e1-s.b1+1),r+=i.length,!(r>n));o--)t=i+t;o>0&&(t="[...]"+t)}if(this.len>1){var h=0;for(o=this.pos+1;o<this.pos+this.len&&(s=this.tokens[o],i=this.text.substr(s.b1,s.e1-s.b1+1),h+=i.length,!(h>n));o++)t+=i;o<this.pos+this.len&&(t+="[...]")}}return t=t.replace(/\r/,"\\r").replace(/\n/,"\\n").replace(/\t/,"\\t")}}]),e}();exports.Token=Token;
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,s,n){return s&&e(t.prototype,s),n&&e(t,n),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var Token=function(){function e(){_classCallCheck(this,e),this.name="",this.text="",this.tokens=[],this.pos=0,this.len=0}return _createClass(e,[{key:"setName",value:function(e){this.name=e}},{key:"setText",value:function(e){this.text=e}},{key:"addToken",value:function(e,t,s,n,o){this.tokens.push({b1:e,b2:t,e2:s,e1:n,symbol:o}),this.len++}},{key:"peek",value:function(e){if("undefined"==typeof e&&(e=0),e>=this.len)throw new Error(this.name+": parse error: not enough tokens");return this.tokens[this.pos+e].symbol}},{key:"skip",value:function(e){if("undefined"==typeof e&&(e=1),e>this.len)throw new Error(this.name+": parse error: not enough tokens available to skip: "+this.ctx());this.pos+=e,this.len-=e}},{key:"consume",value:function(e){if(this.len<=0)throw new Error(this.name+": parse error: no more tokens available to consume: "+this.ctx());if(this.tokens[this.pos].symbol!==e)throw new Error(this.name+': parse error: expected token symbol "'+e+'": '+this.ctx());this.pos++,this.len--}},{key:"ctx",value:function(e){"undefined"==typeof e&&(e=78);var t=this.tokens[this.pos],s="<"+this.text.substr(t.b2,t.e2-t.b2+1)+">";s=this.text.substr(t.b1,t.b2-t.b1)+s,s+=this.text.substr(t.e2+1,t.e1-t.e2);var n=e-s.length;if(n>0){n=Math.floor(n/2);var o=void 0,r=void 0;if(this.pos>0){var i=0;for(o=this.pos-1;o>=0&&(t=this.tokens[o],r=this.text.substr(t.b1,t.e1-t.b1+1),i+=r.length,!(i>n));o--)s=r+s;o>0&&(s="[...]"+s)}if(this.len>1){var h=0;for(o=this.pos+1;o<this.pos+this.len&&(t=this.tokens[o],r=this.text.substr(t.b1,t.e1-t.b1+1),h+=r.length,!(h>n));o++)s+=r;o<this.pos+this.len&&(s+="[...]")}}return s=s.replace(/\r/,"\\r").replace(/\n/,"\\n").replace(/\t/,"\\t")}}]),e}();exports.Token=Token;
},{}],3:[function(_dereq_,module,exports){

@@ -36,21 +36,21 @@ (function (global){

},{}],4:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _ducky2Registry1DataJs=_dereq_("./ducky-2-registry-1-data.js"),register=function(e,r){if(2!==arguments.length)throw new Error("register: invalid number of arguments: "+arguments.length+" (exactly 2 expected)");if("string"!=typeof e)throw new Error('register: invalid name argument: "'+e+'" (string expected)');if("function"!=typeof r)throw new Error('register: invalid type argument: "'+r+'" (function object expected)');if("undefined"!=typeof _ducky2Registry1DataJs.registry[e])throw new Error('register: type already registered under name: "'+e+'"');_ducky2Registry1DataJs.registry[e]=r},unregister=function(e){if(1!==arguments.length)throw new Error("unregister: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('unregister: invalid name argument: "'+e+'" (string expected)');if("undefined"==typeof _ducky2Registry1DataJs.registry[e])throw new Error('unregister: no type registered under name: "'+e+'"');delete _ducky2Registry1DataJs.registry[e]},registered=function(e){if(1!==arguments.length)throw new Error("registered: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('registered: invalid name argument: "'+e+'" (string expected)');return _ducky2Registry1DataJs.registry[e]};exports.registered=registered,exports.register=register,exports.unregister=unregister;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.unregister=exports.register=exports.registered=void 0;var _ducky2Registry1Data=_dereq_("./ducky-2-registry-1-data.js"),register=function(e,r){if(2!==arguments.length)throw new Error("register: invalid number of arguments: "+arguments.length+" (exactly 2 expected)");if("string"!=typeof e)throw new Error('register: invalid name argument: "'+e+'" (string expected)');if("function"!=typeof r)throw new Error('register: invalid type argument: "'+r+'" (function object expected)');if("undefined"!=typeof _ducky2Registry1Data.registry[e])throw new Error('register: type already registered under name: "'+e+'"');_ducky2Registry1Data.registry[e]=r},unregister=function(e){if(1!==arguments.length)throw new Error("unregister: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('unregister: invalid name argument: "'+e+'" (string expected)');if("undefined"==typeof _ducky2Registry1Data.registry[e])throw new Error('unregister: no type registered under name: "'+e+'"');delete _ducky2Registry1Data.registry[e]},registered=function(e){if(1!==arguments.length)throw new Error("registered: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('registered: invalid name argument: "'+e+'" (string expected)');return _ducky2Registry1Data.registry[e]};exports.registered=registered,exports.register=register,exports.unregister=unregister;
},{"./ducky-2-registry-1-data.js":3}],5:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var select_compile=function(e){for(var s=[],l=0,r=void 0,t=e;""!==t;){if(null!==(r=t.match(/^\s*(?:\.)?\s*([a-zA-Z$0-9_][a-zA-Z$0-9_:-]*)/)))s.push(r[1]);else if(null!==(r=t.match(/^\s*\[\s*(\d+|\*{1,2})\s*\]/)))s.push(r[1]);else if(null!==(r=t.match(/^\s*\[\s*"((?:\\"|.)*?)"\s*\]/)))s.push(r[1].replace(/\\"/g,'"'));else{if(null===(r=t.match(/^\s*\[\s*'((?:\\'|.)*?)'\s*\]/))){if(null!==(r=t.match(/^\s+$/)))break;throw new Error("select: parse error: invalid character at: "+e.substr(0,l)+"<"+t.substr(0,1)+">"+t.substr(1))}s.push(r[1].replace(/\\'/g,"'"))}l+=r[0].length,t=t.substr(r[0].length)}return s};exports.select_compile=select_compile;
},{}],6:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var select_execute=function(e,t){if(0===t.length){if(3===arguments.length)throw new Error("select: cannot set value on empty path");return e}for(var r=0;r<t.length-1;){if("object"!=typeof e)throw new Error("select: cannot further dereference: no more intermediate objects in path");e=e[t[r++]]}if("object"!=typeof e)throw new Error("select: cannot further dereference: no object at end of path");var n=e[t[r]];if(3===arguments.length){var o=arguments[2];void 0===o?e instanceof Array?e.splice(parseInt(t[r],10),1):delete e[t[r]]:e[t[r]]=o}return n};exports.select_execute=select_execute;
"use strict";function _typeof(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}Object.defineProperty(exports,"__esModule",{value:!0});var select_execute=function(e,t){if(0===t.length){if(3===arguments.length)throw new Error("select: cannot set value on empty path");return e}for(var n=0;n<t.length-1;){if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("select: cannot further dereference: no more intermediate objects in path");e=e[t[n++]]}if("object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error("select: cannot further dereference: no object at end of path");var r=e[t[n]];if(3===arguments.length){var o=arguments[2];void 0===o?e instanceof Array?e.splice(parseInt(t[n],10),1):delete e[t[n]]:e[t[n]]=o}return r};exports.select_execute=select_execute;
},{}],7:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _ducky3Select1CompileJs=_dereq_("./ducky-3-select-1-compile.js"),_ducky3Select2ExecuteJs=_dereq_("./ducky-3-select-2-execute.js"),select_cache={},select=function(e,t,r){if(arguments.length<2)throw new Error("select: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("select: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");if("string"!=typeof t)throw new Error('select: invalid specification argument: "'+t+'" (string expected)');var c=select_cache[t];return"undefined"==typeof c&&(c=_ducky3Select1CompileJs.select_compile(t),select_cache[t]=c),2===arguments.length?_ducky3Select2ExecuteJs.select_execute(e,c):_ducky3Select2ExecuteJs.select_execute(e,c,r)};select.compile=function(e){if(1!==arguments.length)throw new Error("select: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('select: invalid specification argument: "'+e+'" (string expected)');return _ducky3Select1CompileJs.select_compile.apply(void 0,arguments)},select.execute=function(e,t){if(arguments.length<2)throw new Error("select: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("select: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");if(!("object"==typeof t&&t instanceof Array))throw new Error('select: invalid path argument: "'+t+'" (array expected)');return _ducky3Select2ExecuteJs.select_execute.apply(void 0,arguments)},exports.select=select;
"use strict";function _typeof(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.select=void 0;var _ducky3Select1Compile=_dereq_("./ducky-3-select-1-compile.js"),_ducky3Select2Execute=_dereq_("./ducky-3-select-2-execute.js"),select_cache={},select=function(e,t,r){if(arguments.length<2)throw new Error("select: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("select: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");if("string"!=typeof t)throw new Error('select: invalid specification argument: "'+t+'" (string expected)');var n=select_cache[t];return"undefined"==typeof n&&(n=(0,_ducky3Select1Compile.select_compile)(t),select_cache[t]=n),2===arguments.length?(0,_ducky3Select2Execute.select_execute)(e,n):(0,_ducky3Select2Execute.select_execute)(e,n,r)};select.compile=function(e){if(1!==arguments.length)throw new Error("select: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('select: invalid specification argument: "'+e+'" (string expected)');return _ducky3Select1Compile.select_compile.apply(void 0,arguments)},select.execute=function(e,t){if(arguments.length<2)throw new Error("select: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("select: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");if(!("object"===("undefined"==typeof t?"undefined":_typeof(t))&&t instanceof Array))throw new Error('select: invalid path argument: "'+t+'" (array expected)');return _ducky3Select2Execute.select_execute.apply(void 0,arguments)},exports.select=select;
},{"./ducky-3-select-1-compile.js":5,"./ducky-3-select-2-execute.js":6}],8:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _ducky1UtilJs=_dereq_("./ducky-1-util.js"),validate_tokenize=function(e){var t=new _ducky1UtilJs.Token;t.setName("validate"),t.setText(e);for(var r=void 0,n=0;""!==e;){if(r=e.match(/^(\s*)([^{}\[\]:,?*+()!|\s]+|[{}\[\]:,?*+()!|])(\s*)/),null===r)throw new Error('validate: parse error: cannot further canonicalize: "'+e+'"');t.addToken(n,n+r[1].length,n+r[1].length+r[2].length-1,n+r[0].length-1,r[2]),e=e.substr(r[0].length),n+=r[0].length}return t};exports.validate_tokenize=validate_tokenize;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.validate_tokenize=void 0;var _ducky1Util=_dereq_("./ducky-1-util.js"),validate_tokenize=function(e){var t=new _ducky1Util.Token;t.setName("validate"),t.setText(e);for(var r=void 0,a=0;""!==e;){if(r=e.match(/^(\s*)([^{}\[\]:,?*+()!|\s]+|[{}\[\]:,?*+()!|])(\s*)/),null===r)throw new Error('validate: parse error: cannot further canonicalize: "'+e+'"');t.addToken(a,a+r[1].length,a+r[1].length+r[2].length-1,a+r[0].length-1,r[2]),e=e.substr(r[0].length),a+=r[0].length}return t};exports.validate_tokenize=validate_tokenize;
},{"./ducky-1-util.js":2}],9:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var validate_parse={parse_spec:function(e){if(e.len<=0)return null;var r=void 0,a=e.peek();if("!"===a)r=this.parse_not(e);else if("("===a)r=this.parse_group(e);else if("{"===a)r=this.parse_hash(e);else if("["===a)r=this.parse_array(e);else if(a.match(/^(?:null|undefined|boolean|number|string|function|object)$/))r=this.parse_primary(e);else if("any"===a)r=this.parse_any(e);else{if(!a.match(/^[_a-zA-Z$][_a-zA-Z$0-9]*(?:\.[_a-zA-Z$][_a-zA-Z$0-9]*)*$/))throw new Error('validate: parse error: invalid token symbol: "'+e.ctx()+'"');r=this.parse_class(e)}return r},parse_not:function(e){e.consume("!");var r=this.parse_spec(e);return r={type:"not",op:r}},parse_group:function(e){e.consume("(");for(var r=this.parse_spec(e);"|"===e.peek();){e.consume("|");var a=this.parse_spec(e);r={type:"or",op1:r,op2:a}}return e.consume(")"),r},parse_hash:function(e){e.consume("{");for(var r=[];"}"!==e.peek();){var a=this.parse_key(e),s=this.parse_arity(e,"?");e.consume(":");var t=this.parse_spec(e);if(r.push({type:"element",key:a,arity:s,element:t}),","!==e.peek())break;e.skip()}var p={type:"hash",elements:r};return e.consume("}"),p},parse_array:function(e){e.consume("[");for(var r=[];"]"!==e.peek();){var a=this.parse_spec(e),s=this.parse_arity(e,"?*+");if(r.push({type:"element",element:a,arity:s}),","!==e.peek())break;e.skip()}var t={type:"array",elements:r};return e.consume("]"),t},parse_primary:function(e){var r=e.peek();if(!r.match(/^(?:null|undefined|boolean|number|string|function|object)$/))throw new Error('validate: parse error: invalid primary type "'+r+'"');return e.skip(),{type:"primary",name:r}},parse_any:function(e){var r=e.peek();if("any"!==r)throw new Error('validate: parse error: invalid any type "'+r+'"');return e.skip(),{type:"any"}},parse_class:function(e){var r=e.peek();if(!r.match(/^[_a-zA-Z$][_a-zA-Z$0-9]*(?:\.[_a-zA-Z$][_a-zA-Z$0-9]*)*$/))throw new Error('validate: parse error: invalid class type "'+r+'"');return e.skip(),{type:"class",name:r}},parse_arity:function(e,r){var a=[1,1];if(e.len>=5&&"{"===e.peek(0)&&e.peek(1).match(/^[0-9]+$/)&&","===e.peek(2)&&e.peek(3).match(/^(?:[0-9]+|oo)$/)&&"}"===e.peek(4))a=[parseInt(e.peek(1),10),"oo"===e.peek(3)?Number.MAX_VALUE:parseInt(e.peek(3),10)],e.skip(5);else if(e.len>=1&&1===e.peek().length&&r.indexOf(e.peek())>=0){var s=e.peek();switch(s){case"?":a=[0,1];break;case"*":a=[0,Number.MAX_VALUE];break;case"+":a=[1,Number.MAX_VALUE]}e.skip()}return a},parse_key:function(e){var r=e.peek();if(!r.match(/^(?:[_a-zA-Z$][_a-zA-Z$0-9]*|@)$/))throw new Error('validate: parse error: invalid key "'+r+'"');return e.skip(),r}};exports.validate_parse=validate_parse;
},{}],10:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function e(e,t){var n=[],r=!0,a=!1,l=void 0;try{for(var o,c=e[Symbol.iterator]();!(r=(o=c.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(u){a=!0,l=u}finally{try{!r&&c["return"]&&c["return"]()}finally{if(a)throw l}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_ducky2Registry2ApiJs=_dereq_("./ducky-2-registry-2-api.js"),validate_execute={exec_spec:function(e,t,n,r){var a=!1;if(null!==t)switch(t.type){case"not":a=this.exec_not(e,t,n,r);break;case"or":a=this.exec_or(e,t,n,r);break;case"hash":a=this.exec_hash(e,t,n,r);break;case"array":a=this.exec_array(e,t,n,r);break;case"primary":a=this.exec_primary(e,t,n,r);break;case"class":a=this.exec_class(e,t,n,r);break;case"any":a=!0;break;default:throw new Error('validate: invalid validation AST: node has unknown type "'+t.type+'"')}return a},exec_not:function(e,t,n,r){var a=null!==r?[]:null,l=this.exec_spec(e,t.op,n,a);return l=!l,l||null===r||a.forEach(function(e){return r.push(e)}),l},exec_or:function(e,t,n,r){var a=null!==r?[[],[]]:[null,null],l=_slicedToArray(a,2),o=l[0],c=l[1],u=this.exec_spec(e,t.op1,n,o),i=this.exec_spec(e,t.op2,n,c),s=u||i;return s||null===r||(o.forEach(function(e){return r.push(e)}),c.forEach(function(e){return r.push(e)})),s},exec_hash:function(e,t,n,r){var a=void 0,l=void 0,o="object"==typeof e,c={},u=void 0;if(o||null===r){if(o){var i=!1;for(u in e)if(Object.hasOwnProperty.call(e,u)&&Object.propertyIsEnumerable.call(e,u)&&"constructor"!==u&&"prototype"!==u){i=!0;break}for(a=0;a<t.elements.length;a++)if(l=t.elements[a],c[l.key]=l.element,l.arity[0]>0&&("@"===l.key&&!i||"@"!==l.key&&"undefined"==typeof e[l.key])){if(o=!1,null===r)break;"@"===l.key?r.push('mismatch at path "'+n+'": mandatory element under arbitrary key not found'):r.push('mismatch at path "'+n+'": mandatory element under key "'+l.key+'" not found')}}}else r.push('mismatch at path "'+n+'": found type "'+typeof e+'", expected hash');if(o||null!==r){var s=""!==n?".":"";for(u in e)if(Object.hasOwnProperty.call(e,u)&&Object.propertyIsEnumerable.call(e,u)&&"constructor"!==u&&"prototype"!==u&&("undefined"==typeof c[u]&&"undefined"==typeof c["@"]&&null!==r&&r.push('mismatch at path "'+n+'": element under key "'+u+'" unexpected'),!("undefined"!=typeof c[u]&&this.exec_spec(e[u],c[u],""+n+s+u,r)||"undefined"!=typeof c["@"]&&this.exec_spec(e[u],c["@"],""+n+s+u,r)||(o=!1,null!==r))))break}return o},exec_array:function(e,t,n,r){var a=void 0,l=void 0,o="object"==typeof e&&e instanceof Array;if(o||null===r){if(o){var c=0,u=null;for(a=0;a<t.elements.length;a++){l=t.elements[a];var i=0;for(u=null!==r?[]:null;i<l.arity[1]&&c<e.length&&this.exec_spec(e[c],l.element,n+"["+c+"]",u);)i++,c++;if(i<l.arity[0]){null!==r&&r.push('mismatch at path "'+n+"["+c+']": '+("found only "+i+" elements of array element type #"+a+", ")+("expected at least "+l.arity[0]+" elements")),o=!1;break}}!o&&null!==u&&u.length>0?null!==r&&u.forEach(function(e){return r.push(e)}):c<e.length&&(null!==r&&r.push('mismatch at path "'+n+'": matched only '+c+" elements, "+("but "+e.length+" elements found")),o=!1)}}else r.push('mismatch at path "'+n+'": found type "'+typeof e+'", expected array');return o},exec_primary:function(e,t,n,r){var a="null"===t.name&&null===e||typeof e===t.name;return a||null===r||r.push('mismatch at path "'+n+'": found type "'+typeof e+'", expected primary type "'+t.name+'"'),a},exec_class:function(e,t,n,r){var a=_ducky2Registry2ApiJs.registered(t.name),l="object"==typeof e&&(Object.prototype.toString.call(e)==="[object "+t.name+"]"||"function"==typeof a&&e instanceof a);return l||null===r||r.push('mismatch at path "'+n+'": found type "'+typeof e+'", expected class type "'+t.name+'"'),l}};exports.validate_execute=validate_execute;
"use strict";function _typeof(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var _slicedToArray=function(){function e(e,t){var n=[],r=!0,a=!1,o=void 0;try{for(var u,i=e[Symbol.iterator]();!(r=(u=i.next()).done)&&(n.push(u.value),!t||n.length!==t);r=!0);}catch(l){a=!0,o=l}finally{try{!r&&i["return"]&&i["return"]()}finally{if(a)throw o}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.validate_execute=void 0;var _ducky2Registry2Api=_dereq_("./ducky-2-registry-2-api.js"),validate_execute={exec_spec:function(e,t,n,r){var a=!1;if(null!==t)switch(t.type){case"not":a=this.exec_not(e,t,n,r);break;case"or":a=this.exec_or(e,t,n,r);break;case"hash":a=this.exec_hash(e,t,n,r);break;case"array":a=this.exec_array(e,t,n,r);break;case"primary":a=this.exec_primary(e,t,n,r);break;case"class":a=this.exec_class(e,t,n,r);break;case"any":a=!0;break;default:throw new Error('validate: invalid validation AST: node has unknown type "'+t.type+'"')}return a},exec_not:function(e,t,n,r){var a=null!==r?[]:null,o=this.exec_spec(e,t.op,n,a);return o=!o,o||null===r||a.forEach(function(e){return r.push(e)}),o},exec_or:function(e,t,n,r){var a=null!==r?[[],[]]:[null,null],o=_slicedToArray(a,2),u=o[0],i=o[1],l=this.exec_spec(e,t.op1,n,u),c=this.exec_spec(e,t.op2,n,i),f=l||c;return f||null===r||(u.forEach(function(e){return r.push(e)}),i.forEach(function(e){return r.push(e)})),f},exec_hash:function(e,t,n,r){var a=void 0,o=void 0,u="object"===("undefined"==typeof e?"undefined":_typeof(e)),i={},l=void 0;if(u||null===r){if(u){var c=!1;for(l in e)if(Object.hasOwnProperty.call(e,l)&&Object.propertyIsEnumerable.call(e,l)&&"constructor"!==l&&"prototype"!==l){c=!0;break}for(a=0;a<t.elements.length;a++)if(o=t.elements[a],i[o.key]=o.element,o.arity[0]>0&&("@"===o.key&&!c||"@"!==o.key&&"undefined"==typeof e[o.key])){if(u=!1,null===r)break;"@"===o.key?r.push('mismatch at path "'+n+'": mandatory element under arbitrary key not found'):r.push('mismatch at path "'+n+'": mandatory element under key "'+o.key+'" not found')}}}else r.push('mismatch at path "'+n+'": found type "'+("undefined"==typeof e?"undefined":_typeof(e))+'", expected hash');if(u||null!==r){var f=""!==n?".":"";for(l in e)if(Object.hasOwnProperty.call(e,l)&&Object.propertyIsEnumerable.call(e,l)&&"constructor"!==l&&"prototype"!==l&&("undefined"==typeof i[l]&&"undefined"==typeof i["@"]&&null!==r&&r.push('mismatch at path "'+n+'": element under key "'+l+'" unexpected'),!("undefined"!=typeof i[l]&&this.exec_spec(e[l],i[l],""+n+f+l,r)||"undefined"!=typeof i["@"]&&this.exec_spec(e[l],i["@"],""+n+f+l,r)||(u=!1,null!==r))))break}return u},exec_array:function(e,t,n,r){var a=void 0,o=void 0,u="object"===("undefined"==typeof e?"undefined":_typeof(e))&&e instanceof Array;if(u||null===r){if(u){var i=0,l=null;for(a=0;a<t.elements.length;a++){o=t.elements[a];var c=0;for(l=null!==r?[]:null;c<o.arity[1]&&i<e.length&&this.exec_spec(e[i],o.element,n+"["+i+"]",l);)c++,i++;if(c<o.arity[0]){null!==r&&r.push('mismatch at path "'+n+"["+i+']": '+("found only "+c+" elements of array element type #"+a+", ")+("expected at least "+o.arity[0]+" elements")),u=!1;break}}!u&&null!==l&&l.length>0?null!==r&&l.forEach(function(e){return r.push(e)}):i<e.length&&(null!==r&&r.push('mismatch at path "'+n+'": matched only '+i+" elements, "+("but "+e.length+" elements found")),u=!1)}}else r.push('mismatch at path "'+n+'": found type "'+("undefined"==typeof e?"undefined":_typeof(e))+'", expected array');return u},exec_primary:function(e,t,n,r){var a="null"===t.name&&null===e||("undefined"==typeof e?"undefined":_typeof(e))===t.name;return a||null===r||r.push('mismatch at path "'+n+'": found type "'+("undefined"==typeof e?"undefined":_typeof(e))+'", expected primary type "'+t.name+'"'),a},exec_class:function(e,t,n,r){var a=(0,_ducky2Registry2Api.registered)(t.name),o="object"===("undefined"==typeof e?"undefined":_typeof(e))&&(Object.prototype.toString.call(e)==="[object "+t.name+"]"||"function"==typeof a&&e instanceof a);return o||null===r||r.push('mismatch at path "'+n+'": found type "'+("undefined"==typeof e?"undefined":_typeof(e))+'", expected class type "'+t.name+'"'),o}};exports.validate_execute=validate_execute;
},{"./ducky-2-registry-2-api.js":4}],11:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _ducky4Validate1TokenizeJs=_dereq_("./ducky-4-validate-1-tokenize.js"),_ducky4Validate2ParseJs=_dereq_("./ducky-4-validate-2-parse.js"),_ducky4Validate3ExecuteJs=_dereq_("./ducky-4-validate-3-execute.js"),validate_cache={},validate=function e(t,a,i){if(arguments.length<2)throw new Error("validate: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("validate: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");if("string"!=typeof a)throw new Error('validate: invalid specification argument: "'+a+'" (string expected)');var r=validate_cache[a];return"undefined"==typeof r&&(r=e.compile(a),validate_cache[a]=r),e.execute(t,r,i)};validate.compile=function(e){if(1!==arguments.length)throw new Error("validate: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('validate: invalid specification argument: "'+e+'" (string expected)');var t=_ducky4Validate1TokenizeJs.validate_tokenize(e),a=_ducky4Validate2ParseJs.validate_parse.parse_spec(t);return a},validate.execute=function(e,t,a){if(arguments.length<2)throw new Error("validate: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("validate: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");return(arguments.length<3||"undefined"==typeof a)&&(a=null),_ducky4Validate3ExecuteJs.validate_execute.exec_spec(e,t,"",a)},exports.validate=validate;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.validate=void 0;var _ducky4Validate1Tokenize=_dereq_("./ducky-4-validate-1-tokenize.js"),_ducky4Validate2Parse=_dereq_("./ducky-4-validate-2-parse.js"),_ducky4Validate3Execute=_dereq_("./ducky-4-validate-3-execute.js"),validate_cache={},validate=function e(t,a,i){if(arguments.length<2)throw new Error("validate: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("validate: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");if("string"!=typeof a)throw new Error('validate: invalid specification argument: "'+a+'" (string expected)');var r=validate_cache[a];return"undefined"==typeof r&&(r=e.compile(a),validate_cache[a]=r),e.execute(t,r,i)};validate.compile=function(e){if(1!==arguments.length)throw new Error("validate: invalid number of arguments: "+arguments.length+" (exactly 1 expected)");if("string"!=typeof e)throw new Error('validate: invalid specification argument: "'+e+'" (string expected)');var t=(0,_ducky4Validate1Tokenize.validate_tokenize)(e),a=_ducky4Validate2Parse.validate_parse.parse_spec(t);return a},validate.execute=function(e,t,a){if(arguments.length<2)throw new Error("validate: invalid number of arguments: "+arguments.length+" (minimum of 2 expected)");if(arguments.length>3)throw new Error("validate: invalid number of arguments: "+arguments.length+" (maximum of 3 expected)");return(arguments.length<3||"undefined"==typeof a)&&(a=null),_ducky4Validate3Execute.validate_execute.exec_spec(e,t,"",a)},exports.validate=validate;
},{"./ducky-4-validate-1-tokenize.js":8,"./ducky-4-validate-2-parse.js":9,"./ducky-4-validate-3-execute.js":10}],12:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _ducky4Validate4ApiJs=_dereq_("./ducky-4-validate-4-api.js"),params_is_name_based=function(e,r){var a=!1;if(1===e.length&&"object"==typeof e[0]){a=!0;for(var i in e[0])Object.hasOwnProperty.call(e[0],i)||"undefined"==typeof r[i]&&(a=!1)}return a},params_check_validity=function(e,r,a,i,t){if("undefined"!=typeof i&&!_ducky4Validate4ApiJs.validate(a,i))throw new Error(e+': parameter "'+r+'" has '+(t+" "+JSON.stringify(a)+', which does not validate against "'+i+'"'))},params=function e(r,a,i){var e={},t=void 0;for(t in i)Object.hasOwnProperty.call(i,t)&&"undefined"!=typeof i[t].def&&("undefined"!=typeof i[t].valid&&params_check_validity(r,t,i[t].def,i[t].valid,"default value"),e[t]=i[t].def);if(params_is_name_based(a,i)){a=a[0];for(t in a)if(Object.hasOwnProperty.call(a,t)){if("undefined"==typeof i[t])throw new Error(r+': unknown parameter "'+t+'"');params_check_validity(r,t,a[t],i[t].valid,"value"),e[t]=a[t]}for(t in i)if(Object.hasOwnProperty.call(i,t)&&"undefined"!=typeof i[t].req&&i[t].req&&"undefined"==typeof a[t])throw new Error(r+': required parameter "'+t+'" missing')}else{var n=0,d=0,o={};for(t in i)Object.hasOwnProperty.call(i,t)&&"undefined"!=typeof i[t].pos&&(o[i[t].pos]=t,"number"==typeof i[t].pos&&n++,"undefined"!=typeof i[t].req&&i[t].req&&d++);if(a.length<d)throw new Error(r+": invalid number of arguments (at least "+d+" required)");for(var f=0;n>f&&f<a.length;)params_check_validity(r,o[f],a[f],i[o[f]].valid,"value"),e[o[f]]=a[f],f++;if(f<a.length){if("undefined"==typeof o["..."])throw new Error(r+": too many arguments provided");for(var p=[];f<a.length;)p.push(a[f++]);params_check_validity(r,o["..."],p,i[o["..."]].valid,"value"),e[o["..."]]=p}}return e};exports.params=params;
"use strict";function _typeof(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.params=void 0;var _ducky4Validate4Api=_dereq_("./ducky-4-validate-4-api.js"),params_is_name_based=function(e,r){var a=!1;if(1===e.length&&"object"===_typeof(e[0])){a=!0;for(var t in e[0])Object.hasOwnProperty.call(e[0],t)||"undefined"==typeof r[t]&&(a=!1)}return a},params_check_validity=function(e,r,a,t,i){if("undefined"!=typeof t&&!(0,_ducky4Validate4Api.validate)(a,t))throw new Error(e+': parameter "'+r+'" has '+(i+" "+JSON.stringify(a)+', which does not validate against "'+t+'"'))},params=function e(r,a,t){var e={},i=void 0;for(i in t)Object.hasOwnProperty.call(t,i)&&"undefined"!=typeof t[i].def&&("undefined"!=typeof t[i].valid&&params_check_validity(r,i,t[i].def,t[i].valid,"default value"),e[i]=t[i].def);if(params_is_name_based(a,t)){a=a[0];for(i in a)if(Object.hasOwnProperty.call(a,i)){if("undefined"==typeof t[i])throw new Error(r+': unknown parameter "'+i+'"');params_check_validity(r,i,a[i],t[i].valid,"value"),e[i]=a[i]}for(i in t)if(Object.hasOwnProperty.call(t,i)&&"undefined"!=typeof t[i].req&&t[i].req&&"undefined"==typeof a[i])throw new Error(r+': required parameter "'+i+'" missing')}else{var n=0,o=0,d={};for(i in t)Object.hasOwnProperty.call(t,i)&&"undefined"!=typeof t[i].pos&&(d[t[i].pos]=i,"number"==typeof t[i].pos&&n++,"undefined"!=typeof t[i].req&&t[i].req&&o++);if(a.length<o)throw new Error(r+": invalid number of arguments (at least "+o+" required)");for(var f=0;n>f&&f<a.length;)params_check_validity(r,d[f],a[f],t[d[f]].valid,"value"),e[d[f]]=a[f],f++;if(f<a.length){if("undefined"==typeof d["..."])throw new Error(r+": too many arguments provided");for(var p=[];f<a.length;)p.push(a[f++]);params_check_validity(r,d["..."],p,t[d["..."]].valid,"value"),e[d["..."]]=p}}return e};exports.params=params;
},{"./ducky-4-validate-4-api.js":11}],13:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _ducky0VersionJs=_dereq_("./ducky-0-version.js"),_ducky2Registry2ApiJs=_dereq_("./ducky-2-registry-2-api.js"),_ducky3Select3ApiJs=_dereq_("./ducky-3-select-3-api.js"),_ducky4Validate4ApiJs=_dereq_("./ducky-4-validate-4-api.js"),_ducky5ParamsJs=_dereq_("./ducky-5-params.js");exports.version=_ducky0VersionJs.version,exports.register=_ducky2Registry2ApiJs.register,exports.unregister=_ducky2Registry2ApiJs.unregister,exports.select=_ducky3Select3ApiJs.select,exports.validate=_ducky4Validate4ApiJs.validate,exports.params=_ducky5ParamsJs.params;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.params=exports.validate=exports.select=exports.unregister=exports.register=exports.version=void 0;var _ducky0Version=_dereq_("./ducky-0-version.js"),_ducky2Registry2Api=_dereq_("./ducky-2-registry-2-api.js"),_ducky3Select3Api=_dereq_("./ducky-3-select-3-api.js"),_ducky4Validate4Api=_dereq_("./ducky-4-validate-4-api.js"),_ducky5Params=_dereq_("./ducky-5-params.js");exports.version=_ducky0Version.version,exports.register=_ducky2Registry2Api.register,exports.unregister=_ducky2Registry2Api.unregister,exports.select=_ducky3Select3Api.select,exports.validate=_ducky4Validate4Api.validate,exports.params=_ducky5Params.params;
},{"./ducky-0-version.js":1,"./ducky-2-registry-2-api.js":4,"./ducky-3-select-3-api.js":7,"./ducky-4-validate-4-api.js":11,"./ducky-5-params.js":12}]},{},[13])(13)

@@ -57,0 +57,0 @@ });

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

"description": "Duck-Typed Value Handling for JavaScript",
"version": "2.2.2",
"version": "2.3.0",
"license": "MIT",

@@ -27,15 +27,16 @@ "author": {

"grunt-cli": "~0.1.13",
"grunt-contrib-jshint": "~0.11.2",
"grunt-contrib-uglify": "~0.9.1",
"grunt-contrib-clean": "~0.6.0",
"grunt-eslint": "~17.0.0",
"babel-eslint": "~4.0.5",
"grunt-browserify": "~4.0.0",
"grunt-contrib-jshint": "~0.11.3",
"grunt-contrib-uglify": "~0.11.0",
"grunt-contrib-clean": "~0.7.0",
"grunt-eslint": "~17.3.1",
"babel-eslint": "~4.1.6",
"grunt-browserify": "~4.0.1",
"grunt-mocha-test": "~0.12.7",
"mocha": "~2.2.5",
"chai": "~3.2.0",
"chai-fuzzy": "~1.5.0",
"mocha": "~2.3.4",
"chai": "~3.4.1",
"chai-fuzzy": "~1.6.0",
"underscore": "~1.8.3",
"babelify": "~6.1.3",
"minifyify": "~7.0.3",
"babelify": "~7.2.0",
"babel-preset-es2015": "~6.3.13",
"minifyify": "~7.1.0",
"browserify-replace": "~0.9.0",

@@ -42,0 +43,0 @@ "browserify-header": "~0.9.2",

@@ -87,8 +87,8 @@ /*

/* the current token itself */
let ctx = "<" + this.text.substr(tok.b2, tok.e2 - tok.b2 + 1) + ">"
ctx = this.text.substr(tok.b1, tok.b2 - tok.b1) + ctx
ctx = ctx + this.text.substr(tok.e2 + 1, tok.e1 - tok.e2)
let context = "<" + this.text.substr(tok.b2, tok.e2 - tok.b2 + 1) + ">"
context = this.text.substr(tok.b1, tok.b2 - tok.b1) + context
context = context + this.text.substr(tok.e2 + 1, tok.e1 - tok.e2)
/* the previous and following token(s) */
let k = (width - ctx.length)
let k = (width - context.length)
if (k > 0) {

@@ -106,6 +106,6 @@ k = Math.floor(k / 2)

break
ctx = str + ctx
context = str + context
}
if (i > 0)
ctx = "[...]" + ctx
context = "[...]" + context
}

@@ -121,6 +121,6 @@ if (this.len > 1) {

break
ctx = ctx + str
context = context + str
}
if (i < this.pos + this.len)
ctx = ctx + "[...]"
context = context + "[...]"
}

@@ -130,6 +130,6 @@ }

/* place everything on a single line through escape sequences */
ctx = ctx.replace(/\r/, "\\r")
.replace(/\n/, "\\n")
.replace(/\t/, "\\t")
return ctx
context = context.replace(/\r/, "\\r")
.replace(/\n/, "\\n")
.replace(/\t/, "\\t")
return context
}

@@ -136,0 +136,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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