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.5.2 to 2.5.3

2

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

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

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

(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:5,micro:1,date:20170408};exports.version=version;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:2,minor:5,micro:3,date:20170527};exports.version=version;
},{}],2:[function(_dereq_,module,exports){

@@ -48,3 +48,3 @@ "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(void 0===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(void 0===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){void 0===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,i=void 0;if(this.pos>0){var r=0;for(o=this.pos-1;o>=0&&(t=this.tokens[o],i=this.text.substr(t.b1,t.e1-t.b1+1),r+=i.length,!(r>n));o--)s=i+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],i=this.text.substr(t.b1,t.e1-t.b1+1),h+=i.length,!(h>n));o++)s+=i;o<this.pos+this.len&&(s+="[...]")}}return s=s.replace(/\r/,"\\r").replace(/\n/,"\\n").replace(/\t/,"\\t")}}]),e}();exports.Token=Token;

},{}],10:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.validate_execute=void 0;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},_slicedToArray=function(){function e(e,t){var r=[],n=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{!n&&l.return&&l.return()}finally{if(o)throw a}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_ducky2Registry2Api=_dereq_("./ducky-2-registry-2-api.js"),errCtx=function(e,t){return""===e?"mismatch at root-level: "+t:'mismatch at path "'+e+'": '+t},validate_execute={exec_spec:function(e,t,r,n){var o=!1;if(null!==t)switch(t.type){case"not":o=this.exec_not(e,t,r,n);break;case"or":o=this.exec_or(e,t,r,n);break;case"hash":o=this.exec_hash(e,t,r,n);break;case"array":o=this.exec_array(e,t,r,n);break;case"regexp":o=this.exec_regexp(e,t,r,n);break;case"primary":o=this.exec_primary(e,t,r,n);break;case"class":o=this.exec_class(e,t,r,n);break;case"any":o=!0;break;default:throw new Error('validate: invalid validation AST: node has unknown type "'+t.type+'"')}return o},exec_not:function(e,t,r,n){var o=null!==n?[]:null,a=this.exec_spec(e,t.op,r,o);return a=!a,a||null===n||o.forEach(function(e){return n.push(e)}),a},exec_or:function(e,t,r,n){var o=null!==n?[[],[]]:[null,null],a=_slicedToArray(o,2),i=a[0],l=a[1],u=this.exec_spec(e,t.op1,r,i),c=this.exec_spec(e,t.op2,r,l),s=u||c;return s||null===n||(i.forEach(function(e){return n.push(e)}),l.forEach(function(e){return n.push(e)})),s},exec_hash:function(e,t,r,n){var o=void 0,a=void 0,i="object"===(void 0===e?"undefined":_typeof(e)),l={},u=void 0;if(i||null===n){if(i){var c=!1;for(u in e)if(Object.hasOwnProperty.call(e,u)&&Object.propertyIsEnumerable.call(e,u)&&"constructor"!==u&&"prototype"!==u){c=!0;break}for(o=0;o<t.elements.length;o++)if(a=t.elements[o],l[a.key]=a.element,a.arity[0]>0&&("@"===a.key&&!c||"@"!==a.key&&void 0===e[a.key])){if(i=!1,null===n)break;"@"===a.key?n.push(errCtx(r,"mandatory element under arbitrary key not found")):n.push(errCtx(r,'mandatory element under key "'+a.key+'" not found'))}}}else n.push('mismatch at path "'+r+'": found type "'+(void 0===e?"undefined":_typeof(e))+'", expected hash');if(i||null!==n){var s=""!==r?".":"";for(u in e)if(Object.hasOwnProperty.call(e,u)&&Object.propertyIsEnumerable.call(e,u)&&"constructor"!==u&&"prototype"!==u&&(void 0===l[u]&&void 0===l["@"]&&null!==n&&n.push(errCtx(r,'element under key "'+u+'" unexpected')),!(void 0!==l[u]&&this.exec_spec(e[u],l[u],""+r+s+u,n)||void 0!==l["@"]&&this.exec_spec(e[u],l["@"],""+r+s+u,n)||(i=!1,null!==n))))break}return i},exec_array:function(e,t,r,n){var o=void 0,a=void 0,i="object"===(void 0===e?"undefined":_typeof(e))&&e instanceof Array;if(i||null===n){if(i){var l=0,u=null;for(o=0;o<t.elements.length;o++){a=t.elements[o];var c=0;for(u=null!==n?[]:null;c<a.arity[1]&&l<e.length&&this.exec_spec(e[l],a.element,r+"["+l+"]",u);)c++,l++;if(c<a.arity[0]){null!==n&&n.push(errCtx(r+"["+l+"]","found only "+c+" elements of array element type #"+o+", expected at least "+a.arity[0]+" elements")),i=!1;break}}!i&&null!==u&&u.length>0?null!==n&&u.forEach(function(e){return n.push(e)}):l<e.length&&(null!==n&&n.push(errCtx(r,"matched only "+l+" elements, but "+e.length+" elements found")),i=!1)}}else n.push(errCtx(r,'found type "'+(void 0===e?"undefined":_typeof(e))+'", expected array'));return i},exec_regexp:function(e,t,r,n){var o=t.regexp.test(e.toString());return o||null===n||n.push(errCtx(r,"value failed to match regular expression "+t.regexp.toString())),o},exec_primary:function(e,t,r,n){var o="null"===t.name&&null===e||(void 0===e?"undefined":_typeof(e))===t.name;return o||null===n||n.push(errCtx(r,'found type "'+(void 0===e?"undefined":_typeof(e))+'", expected primary type "'+t.name+'"')),o},exec_class:function(e,t,r,n){var o=(0,_ducky2Registry2Api.registered)(t.name),a="object"===(void 0===e?"undefined":_typeof(e))&&(Object.prototype.toString.call(e)==="[object "+t.name+"]"||"function"==typeof o&&e instanceof o);return a||null===n||n.push(errCtx(r,'found type "'+(void 0===e?"undefined":_typeof(e))+'", expected class type "'+t.name+'"')),a}};exports.validate_execute=validate_execute;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.validate_execute=void 0;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},_slicedToArray=function(){function e(e,t){var r=[],n=!0,o=!1,a=void 0;try{for(var l,u=e[Symbol.iterator]();!(n=(l=u.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{!n&&u.return&&u.return()}finally{if(o)throw a}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_ducky2Registry2Api=_dereq_("./ducky-2-registry-2-api.js"),errCtx=function(e,t){return""===e?"mismatch at root-level: "+t:'mismatch at path "'+e+'": '+t},validate_execute={exec_spec:function(e,t,r,n){var o=!1;if(null!==t)switch(t.type){case"not":o=this.exec_not(e,t,r,n);break;case"or":o=this.exec_or(e,t,r,n);break;case"hash":o=this.exec_hash(e,t,r,n);break;case"array":o=this.exec_array(e,t,r,n);break;case"regexp":o=this.exec_regexp(e,t,r,n);break;case"primary":o=this.exec_primary(e,t,r,n);break;case"class":o=this.exec_class(e,t,r,n);break;case"any":o=!0;break;default:throw new Error('validate: invalid validation AST: node has unknown type "'+t.type+'"')}return o},exec_not:function(e,t,r,n){var o=null!==n?[]:null,a=this.exec_spec(e,t.op,r,o);return a=!a,a||null===n||o.forEach(function(e){return n.push(e)}),a},exec_or:function(e,t,r,n){var o=null!==n?[[],[]]:[null,null],a=_slicedToArray(o,2),l=a[0],u=a[1],i=this.exec_spec(e,t.op1,r,l),c=this.exec_spec(e,t.op2,r,u),s=i||c;return s||null===n||(l.forEach(function(e){return n.push(e)}),u.forEach(function(e){return n.push(e)})),s},exec_hash:function(e,t,r,n){var o=void 0,a=void 0,l="object"===(void 0===e?"undefined":_typeof(e))&&null!==e,u={},i=void 0;if(l||null===n){if(l){var c=!1;for(i in e)if(Object.hasOwnProperty.call(e,i)&&Object.propertyIsEnumerable.call(e,i)&&"constructor"!==i&&"prototype"!==i){c=!0;break}for(o=0;o<t.elements.length;o++)if(a=t.elements[o],u[a.key]=a.element,a.arity[0]>0&&("@"===a.key&&!c||"@"!==a.key&&void 0===e[a.key])){if(l=!1,null===n)break;"@"===a.key?n.push(errCtx(r,"mandatory element under arbitrary key not found")):n.push(errCtx(r,'mandatory element under key "'+a.key+'" not found'))}}}else null===e?n.push('mismatch at path "'+r+'": found "null", expected hash'):n.push('mismatch at path "'+r+'": found type "'+(void 0===e?"undefined":_typeof(e))+'", expected hash');if(l||null!==n){var s=""!==r?".":"";for(i in e)if(Object.hasOwnProperty.call(e,i)&&Object.propertyIsEnumerable.call(e,i)&&"constructor"!==i&&"prototype"!==i&&(void 0===u[i]&&void 0===u["@"]&&null!==n&&n.push(errCtx(r,'element under key "'+i+'" unexpected')),!(void 0!==u[i]&&this.exec_spec(e[i],u[i],""+r+s+i,n)||void 0!==u["@"]&&this.exec_spec(e[i],u["@"],""+r+s+i,n)||(l=!1,null!==n))))break}return l},exec_array:function(e,t,r,n){var o=void 0,a=void 0,l="object"===(void 0===e?"undefined":_typeof(e))&&e instanceof Array;if(l||null===n){if(l){var u=0,i=null;for(o=0;o<t.elements.length;o++){a=t.elements[o];var c=0;for(i=null!==n?[]:null;c<a.arity[1]&&u<e.length&&this.exec_spec(e[u],a.element,r+"["+u+"]",i);)c++,u++;if(c<a.arity[0]){null!==n&&n.push(errCtx(r+"["+u+"]","found only "+c+" elements of array element type #"+o+", expected at least "+a.arity[0]+" elements")),l=!1;break}}!l&&null!==i&&i.length>0?null!==n&&i.forEach(function(e){return n.push(e)}):u<e.length&&(null!==n&&n.push(errCtx(r,"matched only "+u+" elements, but "+e.length+" elements found")),l=!1)}}else n.push(errCtx(r,'found type "'+(void 0===e?"undefined":_typeof(e))+'", expected array'));return l},exec_regexp:function(e,t,r,n){var o=t.regexp.test(e.toString());return o||null===n||n.push(errCtx(r,"value failed to match regular expression "+t.regexp.toString())),o},exec_primary:function(e,t,r,n){var o="null"===t.name&&null===e||(void 0===e?"undefined":_typeof(e))===t.name;return o||null===n||n.push(errCtx(r,'found type "'+(void 0===e?"undefined":_typeof(e))+'", expected primary type "'+t.name+'"')),o},exec_class:function(e,t,r,n){var o=(0,_ducky2Registry2Api.registered)(t.name),a="object"===(void 0===e?"undefined":_typeof(e))&&(Object.prototype.toString.call(e)==="[object "+t.name+"]"||"function"==typeof o&&e instanceof o);return a||null===n||n.push(errCtx(r,'found type "'+(void 0===e?"undefined":_typeof(e))+'", expected class type "'+t.name+'"')),a}};exports.validate_execute=validate_execute;
},{"./ducky-2-registry-2-api.js":4}],11:[function(_dereq_,module,exports){

@@ -51,0 +51,0 @@ "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 void 0===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);return _ducky4Validate2Parse.validate_parse.parse(t)},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||void 0===a)&&(a=null),_ducky4Validate3Execute.validate_execute.exec_spec(e,t,"",a)},exports.validate=validate;

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

"description": "Duck-Typed Value Handling for JavaScript",
"version": "2.5.2",
"version": "2.5.3",
"license": "MIT",

@@ -28,3 +28,3 @@ "author": {

"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-uglify": "~2.3.0",
"grunt-contrib-uglify": "~3.0.1",
"grunt-contrib-clean": "~1.1.0",

@@ -36,4 +36,4 @@ "grunt-eslint": "~19.0.0",

"grunt-mocha-test": "~0.13.2",
"mocha": "~3.3.0",
"chai": "~3.5.0",
"mocha": "~3.4.2",
"chai": "~4.0.0",
"chai-fuzzy": "~1.6.1",

@@ -40,0 +40,0 @@ "underscore": "~1.8.3",

@@ -82,7 +82,11 @@ /*

let i, el
let valid = (typeof value === "object")
let valid = (typeof value === "object" && value !== null)
let fields = {}
let field
if (!valid && errors !== null)
errors.push(`mismatch at path "${path}": found type "${typeof value}", expected hash`)
if (!valid && errors !== null) {
if (value === null)
errors.push(`mismatch at path "${path}": found "null", expected hash`)
else
errors.push(`mismatch at path "${path}": found type "${typeof value}", expected hash`)
}
else if (valid) {

@@ -89,0 +93,0 @@ /* pass 1: ensure that all mandatory fields exist

@@ -134,2 +134,8 @@ /*

errors = []
expect(validate(null, "{}", errors)).to.be.false
expect(errors).to.have.length(1)
errors = []
expect(validate(null, "(null | {})", errors)).to.be.true
expect(errors).to.have.length(0)
errors = []
expect(validate([ 42, "foo" ], "[ number, boolean ]", errors)).to.be.false

@@ -136,0 +142,0 @@ expect(errors).to.have.length(2)

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