Comparing version
{ | ||
"name": "ducky", | ||
"version": "2.6.0", | ||
"version": "2.6.1", | ||
"description": "Duck-Typed Value Handling for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "./lib/ducky.browser.js", |
{ | ||
"ecmaFeatures": {}, | ||
"parser": "babel-eslint", | ||
@@ -4,0 +3,0 @@ "env": { |
@@ -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:6,micro:0,date:20170618};exports.version=version; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version={major:2,minor:6,micro:1,date:20170716};exports.version=version; | ||
},{}],2:[function(_dereq_,module,exports){ | ||
@@ -44,3 +44,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; | ||
},{"./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}),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 n=void 0,r=0;""!==e;){if(n=e.match(/^(\s*)([^{}\[\]:,?*+()!|\/\s]+|[{}\[\]:,?*+()!|\/])(\s*)/),null===n)throw new Error('validate: parse error: cannot further canonicalize: "'+e+'"');t.addToken(r,r+n[1].length,r+n[1].length+n[2].length-1,r+n[0].length-1,n[2]),e=e.substr(n[0].length),r+=n[0].length}return t.addToken(r,r,r,r,null),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 n=void 0,r=0;""!==e;){if(n=e.match(/^(\s*)([^\\{}\[\]:,?*+()!|\/\s]+|[\\{}\[\]:,?*+()!|\/])(\s*)/),null===n)throw new Error('validate: parse error: cannot further canonicalize: "'+e+'"');t.addToken(r,r+n[1].length,r+n[1].length+n[2].length-1,r+n[0].length-1,n[2]),e=e.substr(n[0].length),r+=n[0].length}return t.addToken(r,r,r,r,null),t};exports.validate_tokenize=validate_tokenize; | ||
},{"./ducky-1-util.js":2}],9:[function(_dereq_,module,exports){ | ||
@@ -47,0 +47,0 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var validate_parse={parse:function(e){if(e.len<=0)return null;var r=this.parse_spec(e);if(null!==e.peek())throw new Error('validate: parse error: unexpected token (expected end-of-string): "'+e.ctx()+'"');return r},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)r=this.parse_regexp(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("|");r={type:"or",op1:r,op2:this.parse_spec(e)}}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 p=this.parse_spec(e);if(r.push({type:"element",key:a,arity:s,element:p}),","!==e.peek())break;e.skip()}var t={type:"hash",elements:r};return e.consume("}"),t},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 p={type:"array",elements:r};return e.consume("]"),p},parse_regexp:function(e){e.consume("/");for(var r="";e.len>=1&&"/"!==e.peek(0);)e.len>=2&&"\\"===e.peek(0)&&"/"===e.peek(1)?(r+=e.peek(1),e.skip(2)):(r+=e.peek(0),e.skip(1));e.consume("/");var a=void 0;try{a=new RegExp(r)}catch(e){throw new Error('validate: parse error: invalid regular expression "'+r+'": '+e.message)}return{type:"regexp",regexp:a}},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>=3&&"{"===e.peek(0)&&e.peek(1).match(/^[0-9]+$/)&&"}"===e.peek(2))a=[parseInt(e.peek(1),10),parseInt(e.peek(1),10)],e.skip(3);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; |
@@ -5,3 +5,3 @@ { | ||
"description": "Duck-Typed Value Handling for JavaScript", | ||
"version": "2.6.0", | ||
"version": "2.6.1", | ||
"license": "MIT", | ||
@@ -33,7 +33,7 @@ "author": { | ||
"babel-eslint": "~7.2.3", | ||
"estraverse-fb": "~1.3.1", | ||
"estraverse-fb": "~1.3.2", | ||
"grunt-browserify": "~5.0.0", | ||
"grunt-mocha-test": "~0.13.2", | ||
"mocha": "~3.4.2", | ||
"chai": "~4.0.2", | ||
"chai": "~4.1.0", | ||
"chai-fuzzy": "~1.6.1", | ||
@@ -40,0 +40,0 @@ "underscore": "~1.8.3", |
@@ -38,3 +38,3 @@ /* | ||
while (spec !== "") { | ||
m = spec.match(/^(\s*)([^{}\[\]:,?*+()!|/\s]+|[{}\[\]:,?*+()!|/])(\s*)/) | ||
m = spec.match(/^(\s*)([^\\{}\[\]:,?*+()!|/\s]+|[\\{}\[\]:,?*+()!|/])(\s*)/) | ||
if (m === null) | ||
@@ -41,0 +41,0 @@ throw new Error(`validate: parse error: cannot further canonicalize: "${spec}"`) |
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
306473
03449
-0.03%