Socket
Socket
Sign inDemoInstall

bcx-expression-evaluator

Package Overview
Dependencies
0
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.2.0

9

CHANGELOG.md

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

# [1.2.0](https://github.com/buttonwoodcx/bcx-expression-evaluator/compare/v1.1.0...v1.2.0) (2020-05-12)
### Features
* migrate from rollup to ncc ([5c46238](https://github.com/buttonwoodcx/bcx-expression-evaluator/commit/5c4623894c56e856217933234a1af19c724bb96f))
# [1.1.0](https://github.com/buttonwoodcx/bcx-expression-evaluator/compare/v1.0.1...v1.1.0) (2019-10-14)

@@ -2,0 +11,0 @@

2

dist/index.js

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).BcxExpressionEvaluator={})}(this,(function(t){"use strict";function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var s=function(){function t(t,e){this.index=t,this.text=e}var e=t.prototype;return e.withOp=function(t){return this.opKey=t,this},e.withGetterSetter=function(t){return this.key=t,this},e.withValue=function(t){return this.value=t,this},e.toString=function(){return"Token("+this.text+")"},t}(),a=function(){function t(){}return t.prototype.lex=function(t,e){for(var i=new c(t,e),n=[],r=i.scanToken();r;)n.push(r),r=i.scanToken();return n},t}(),o=0,h=2,c=function(){function t(t,e){void 0===e&&(e={}),this.input=t,this.length=t.length,this.peek=0,this.index=-1,this.stringInterpolationMode=e.stringInterpolationMode||!1;var i=this.stringInterpolationMode?h:o;this.contextStack=[i],this.advance()}var e=t.prototype;return e.scanToken=function(){var t,e=this.index;if(this.context!==h){for(;this.peek<=g;){if(++this.index>=this.length)return this.peek=p,null;this.peek=this.input.charCodeAt(this.index)}if(ht(this.peek))return this.scanIdentifier();if(ct(this.peek))return this.scanNumber(this.index);switch(this.peek){case M:return this.advance(),ct(this.peek)?this.scanNumber(e):new s(e,".");case rt:return this.contextStack.push(1),this.scanCharacter(e,String.fromCharCode(this.peek));case at:return this.contextStack.pop(),this.scanCharacter(e,String.fromCharCode(this.peek));case m:case A:case V:case W:case E:case P:case R:return this.scanCharacter(e,String.fromCharCode(this.peek));case S:case k:return this.scanString();case I:case j:case O:case L:case C:case J:case U:return this.scanOperator(e,String.fromCharCode(this.peek));case $:case _:case w:case T:return this.scanComplexOperator(e,T,String.fromCharCode(this.peek),"=");case b:return this.scanComplexOperator(e,b,"&","&");case st:return this.scanComplexOperator(e,st,"|","|");case z:return this.contextStack.push(h),this.scanCharacter(e,String.fromCharCode(this.peek));case ot:for(;(t=this.peek)>=l&&t<=g||t===ot;)this.advance();return this.scanToken()}var i=String.fromCharCode(this.peek);return this.error("Unexpected character ["+i+"]"),null}if(this.peek===z)return this.isRootLevelOfStringInterpolationMode?this.scanString():(this.contextStack.pop(),this.scanCharacter(e,String.fromCharCode(this.peek)));if(this.isStartOfInterpolation()){var n=this.scanStartOfInterpolation();return this.contextStack.push(3),n}return this.peek?this.scanString():void 0},e.scanCharacter=function(t,e){return lt(this.peek===e.charCodeAt(0)),this.advance(),new s(t,e)},e.scanOperator=function(t,e){return lt(this.peek===e.charCodeAt(0)),lt(-1!==u.indexOf(e)),this.advance(),new s(t,e).withOp(e)},e.scanComplexOperator=function(t,e,i,n){lt(this.peek===i.charCodeAt(0)),this.advance();var r=i;return this.peek===e&&(this.advance(),r+=n),this.peek===e&&(this.advance(),r+=n),lt(-1!==u.indexOf(r)),new s(t,r).withOp(r)},e.scanIdentifier=function(){lt(ht(this.peek));var t,e=this.index;for(this.advance();t=this.peek,D<=t&&t<=nt||B<=t&&t<=K||N<=t&&t<=q||t===Z||t===y;)this.advance();var i=this.input.substring(e,this.index),n=new s(e,i);return-1!==u.indexOf(i)?n.withOp(i):n.withGetterSetter(i),n},e.scanNumber=function(t){lt(ct(this.peek));var e,i=this.index===t;for(this.advance();;){if(!ct(this.peek))if(this.peek===M)i=!1;else{if((e=this.peek)!==H&&e!==F)break;this.advance(),ut(this.peek)&&this.advance(),ct(this.peek)||this.error("Invalid exponent",-1),i=!1}this.advance()}var n=this.input.substring(t,this.index),r=i?parseInt(n,10):parseFloat(n);return new s(t,n).withValue(r)},e.scanString=function(){this.context!==h&&lt(this.peek===S||this.peek===k);var t,e,i=this.index;this.context!==h?(t=this.peek,this.advance()):t=this.isRootLevelOfStringInterpolationMode?p:z;for(var n=this.index;this.peek!==t&&!this.isStartOfInterpolation();)if(this.peek===G){e||(e=[]),e.push(this.input.substring(n,this.index)),this.advance();var r=void 0;if(this.peek===et){var a=this.input.substring(this.index+1,this.index+5);/[A-Z0-9]{4}/.test(a)||this.error("Invalid unicode escape [\\u"+a+"]"),r=parseInt(a,16);for(var o=0;o<5;++o)this.advance()}else r=pt(this.peek),this.advance();e.push(String.fromCharCode(r)),n=this.index}else t!==p&&this.peek===p?this.error("Unterminated quote"):this.advance();var c=this.input.substring(n,this.index);this.context!==h&&this.advance();var u=this.input.substring(i,this.index),l=c;return null!=e&&(e.push(c),l=e.join("")),new s(i,u).withValue(l)},e.scanStartOfInterpolation=function(){lt(this.isStartOfInterpolation());var t=this.index;return this.advance(),this.advance(),new s(t,"${")},e.advance=function(){++this.index>=this.length?this.peek=p:this.peek=this.input.charCodeAt(this.index)},e.error=function(t,e){void 0===e&&(e=0);var i=this.index+e;throw new Error("Lexer Error: "+t+" at column "+i+" in expression ["+this.input+"]")},e.isStartOfInterpolation=function(){if(this.context===h)return this.peek===y&&this.input.charCodeAt(this.index+1)===rt},i(t,[{key:"context",get:function(){return this.contextStack[this.contextStack.length-1]}},{key:"isRootLevelOfStringInterpolationMode",get:function(){return this.stringInterpolationMode&&1===this.contextStack.length}}]),t}(),u=["undefined","null","true","false","+","-","*","/","%","^","=","==","===","!=","!==","<",">","<=",">=","&&","||","&","|","!","?"],p=0,l=9,f=10,v=11,d=12,x=13,g=32,w=33,k=34,y=36,C=37,b=38,S=39,m=40,A=41,O=42,I=43,E=44,j=45,M=46,L=47,P=58,R=59,$=60,T=61,_=62,U=63,N=48,q=57,B=65,F=69,K=90,V=91,G=92,W=93,J=94,Z=95,z=96,D=97,H=101,Q=102,X=110,Y=114,tt=116,et=117,it=118,nt=122,rt=123,st=124,at=125,ot=160;function ht(t){return D<=t&&t<=nt||B<=t&&t<=K||t===Z||t===y}function ct(t){return N<=t&&t<=q}function ut(t){return t===j||t===I}function pt(t){switch(t){case X:return f;case Q:return d;case Y:return x;case tt:return l;case it:return v;default:return t}}function lt(t,e){if(!t)throw e||"Assertion failed"}var ft=function(){function t(t){this.buffer=t}t.unparse=function(e){var i=[],n=new t(i);return e.accept(n),i.join("")};var e=t.prototype;return e.write=function(t){this.buffer.push(t)},e.writeArgs=function(t){this.write("(");for(var e=0,i=t.length;e<i;++e)0!==e&&this.write(","),t[e].accept(this);this.write(")")},e.visitAssign=function(t){t.target.accept(this),this.write("="),t.value.accept(this)},e.visitConditional=function(t){t.condition.accept(this),this.write("?"),t.yes.accept(this),this.write(":"),t.no.accept(this)},e.visitAccessThis=function(t){if(0!==t.ancestor){this.write("$parent");for(var e=t.ancestor-1;e--;)this.write(".$parent")}else this.write("$this")},e.visitAccessScope=function(t){for(var e=t.ancestor;e--;)this.write("$parent.");this.write(t.name)},e.visitAccessMember=function(t){t.object.accept(this),this.write("."+t.name)},e.visitAccessKeyed=function(t){t.object.accept(this),this.write("["),t.key.accept(this),this.write("]")},e.visitCallScope=function(t){for(var e=t.ancestor;e--;)this.write("$parent.");this.write(t.name),this.writeArgs(t.args)},e.visitCallFunction=function(t){t.func.accept(this),this.writeArgs(t.args)},e.visitCallMember=function(t){t.object.accept(this),this.write("."+t.name),this.writeArgs(t.args)},e.visitPrefix=function(t){this.write("("+t.operation),t.expression.accept(this),this.write(")")},e.visitBinary=function(t){t.left.accept(this),this.write(t.operation),t.right.accept(this)},e.visitLiteralPrimitive=function(t){this.write(""+t.value)},e.visitLiteralArray=function(t){var e=t.elements;this.write("[");for(var i=0,n=e.length;i<n;++i)0!==i&&this.write(","),e[i].accept(this);this.write("]")},e.visitLiteralObject=function(t){var e=t.keys,i=t.values;this.write("{");for(var n=0,r=e.length;n<r;++n)0!==n&&this.write(","),this.write("'"+e[n]+"':"),i[n].accept(this);this.write("}")},e.visitLiteralString=function(t){var e=t.value.replace(/'/g,"'");this.write("'"+e+"'")},e.visitStringInterpolation=function(t){var e=t.parts;this.write("(''");for(var i=0,n=e.length;i<n;++i){e[i];this.write("+("),e[i].accept(this),this.write(")")}this.write(")")},t}();function vt(t,e){var i=typeof t;return("object"===i||"function"===i)&&e in t}function dt(t,e){return{bindingContext:t,parentOverrideContext:e||null}}function xt(t,e,i){var n=e.overrideContext;if(i){for(;i&&n;)i--,n=n.parentOverrideContext;if(i||!n)return;return vt(n,t)?n:n.bindingContext}for(;n&&!vt(n,t)&&(!n.bindingContext||!vt(n.bindingContext,t));)n=n.parentOverrideContext;return n?vt(n,t)?n:n.bindingContext:e.bindingContext||e.overrideContext}function gt(t,e){return e?{bindingContext:t,overrideContext:dt(t,dt(e))}:{bindingContext:t,overrideContext:dt(t)}}var wt=function(){function t(){this.isAssignable=!1}var e=t.prototype;return e.evaluate=function(t,e){throw new Error('Binding expression "'+this+'" cannot be evaluated.')},e.evaluateWith=function(t,e,i){return this.evaluate(gt(t,e),i)},e.assign=function(t,e){throw new Error('Binding expression "'+this+'" cannot be assigned to.')},e.toString=function(){return"undefined"==typeof FEATURE_NO_UNPARSER?ft.unparse(this):Object.prototype.toString.call(this)},t}(),kt=function(t){function e(e,i){var n;return(n=t.call(this)||this).target=e,n.value=i,n.isAssignable=!0,n}r(e,t);var i=e.prototype;return i.evaluate=function(t){return this.target.assign(t,this.value.evaluate(t))},i.accept=function(t){t.visitAssign(this)},i.assign=function(t,e){this.value.assign(t,e),this.target.assign(t,e)},e}(wt),yt=function(t){function e(e,i,n){var r;return(r=t.call(this)||this).condition=e,r.yes=i,r.no=n,r}r(e,t);var i=e.prototype;return i.evaluate=function(t){return this.condition.evaluate(t)?this.yes.evaluate(t):this.no.evaluate(t)},i.accept=function(t){return t.visitConditional(this)},e}(wt),Ct=function(t){function e(e){var i;return(i=t.call(this)||this).ancestor=e,i}r(e,t);var i=e.prototype;return i.evaluate=function(t){for(var e=t.overrideContext,i=this.ancestor;i--&&e;)e=e.parentOverrideContext;return i<1&&e?e.bindingContext:void 0},i.accept=function(t){return t.visitAccessThis(this)},e}(wt),bt=function(t){function e(e,i){var n;return(n=t.call(this)||this).name=e,n.ancestor=i,n.isAssignable=!0,n}r(e,t);var i=e.prototype;return i.evaluate=function(t){return xt(this.name,t,this.ancestor)[this.name]},i.assign=function(t,e){var i=xt(this.name,t,this.ancestor);return i?i[this.name]=e:void 0},i.accept=function(t){return t.visitAccessScope(this)},e}(wt),St=function(t){function e(e,i){var n;return(n=t.call(this)||this).object=e,n.name=i,n.isAssignable=!0,n}r(e,t);var i=e.prototype;return i.evaluate=function(t){var e=this.object.evaluate(t);return null==e?e:e[this.name]},i.assign=function(t,e){var i=this.object.evaluate(t);return null==i&&(i={},this.object.assign(t,i)),i[this.name]=e,e},i.accept=function(t){return t.visitAccessMember(this)},e}(wt),mt=function(t){function e(e,i){var n;return(n=t.call(this)||this).object=e,n.key=i,n.isAssignable=!0,n}r(e,t);var i=e.prototype;return i.evaluate=function(t){return function(t,e){if(Array.isArray(t))return t[parseInt(e,10)];if(t)return t[e];if(null==t)return;return t[e]}(this.object.evaluate(t),this.key.evaluate(t))},i.assign=function(t,e){return function(t,e,i){if(Array.isArray(t)){var n=parseInt(e,10);t.length<=n&&(t.length=n+1),t[n]=i}else t[e]=i;return i}(this.object.evaluate(t),this.key.evaluate(t),e)},i.accept=function(t){return t.visitAccessKeyed(this)},e}(wt),At=function(t){function e(e,i,n){var r;return(r=t.call(this)||this).name=e,r.args=i,r.ancestor=n,r}r(e,t);var i=e.prototype;return i.evaluate=function(t,e){var i=Tt(t,this.args),n=xt(this.name,t,this.ancestor),r=_t(n,this.name,e);if(r)return r.apply(n,i)},i.accept=function(t){return t.visitCallScope(this)},e}(wt),Ot=function(t){function e(e,i,n){var r;return(r=t.call(this)||this).object=e,r.name=i,r.args=n,r}r(e,t);var i=e.prototype;return i.evaluate=function(t,e){var i=this.object.evaluate(t),n=Tt(t,this.args),r=_t(i,this.name,e);if(r)return r.apply(i,n)},i.accept=function(t){return t.visitCallMember(this)},e}(wt),It=function(t){function e(e,i){var n;return(n=t.call(this)||this).func=e,n.args=i,n}r(e,t);var i=e.prototype;return i.evaluate=function(t,e){var i=this.func.evaluate(t);if("function"==typeof i)return i.apply(null,Tt(t,this.args));if(e||null!=i)throw new Error(this.func+" is not a function")},i.accept=function(t){return t.visitCallFunction(this)},e}(wt),Et=function(t){function e(e,i,n){var r;return(r=t.call(this)||this).operation=e,r.left=i,r.right=n,r}r(e,t);var i=e.prototype;return i.evaluate=function(t){var e=this.left.evaluate(t);switch(this.operation){case"&&":return e&&this.right.evaluate(t);case"||":return e||this.right.evaluate(t)}var i=this.right.evaluate(t);switch(this.operation){case"==":return e==i;case"===":return e===i;case"!=":return e!=i;case"!==":return e!==i}if(null===e||null===i||void 0===e||void 0===i)switch(this.operation){case"+":return null!=e?e:null!=i?i:0;case"-":return null!=e?e:null!=i?0-i:0}switch(this.operation){case"+":return function(t,e){if(null!==t&&null!==e)return"string"==typeof t&&"string"!=typeof e?t+e.toString():"string"!=typeof t&&"string"==typeof e?t.toString()+e:t+e;if(null!==t)return t;if(null!==e)return e;return 0}(e,i);case"-":return e-i;case"*":return e*i;case"/":return e/i;case"%":return e%i;case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i;case"^":return e^i;case"&":return e&i;case"|":return e|i;case"<<":return e<<i;case">>":return e>>i;case">>>":return e>>>i}throw new Error("Internal error ["+this.operation+"] not handled")},i.accept=function(t){return t.visitBinary(this)},e}(wt),jt=function(t){function e(e,i){var n;return(n=t.call(this)||this).operation=e,n.expression=i,n}r(e,t);var i=e.prototype;return i.evaluate=function(t){return!this.expression.evaluate(t)},i.accept=function(t){return t.visitPrefix(this)},e}(wt),Mt=function(t){function e(e){var i;return(i=t.call(this)||this).value=e,i}r(e,t);var i=e.prototype;return i.evaluate=function(t){return this.value},i.accept=function(t){return t.visitLiteralPrimitive(this)},e}(wt),Lt=function(t){function e(e){var i;return(i=t.call(this)||this).value=e,i}r(e,t);var i=e.prototype;return i.evaluate=function(t){return this.value},i.accept=function(t){return t.visitLiteralString(this)},e}(wt),Pt=function(t){function e(e){var i;return(i=t.call(this)||this).elements=e,i}r(e,t);var i=e.prototype;return i.evaluate=function(t){for(var e=this.elements,i=[],n=0,r=e.length;n<r;++n)i[n]=e[n].evaluate(t);return i},i.accept=function(t){return t.visitLiteralArray(this)},e}(wt),Rt=function(t){function e(e,i){var n;return(n=t.call(this)||this).keys=e,n.values=i,n}r(e,t);var i=e.prototype;return i.evaluate=function(t){for(var e={},i=this.keys,n=this.values,r=0,s=i.length;r<s;++r)e[i[r]]=n[r].evaluate(t);return e},i.accept=function(t){return t.visitLiteralObject(this)},e}(wt),$t=function(t){function e(e){var i;return(i=t.call(this)||this).parts=e,i}r(e,t);var i=e.prototype;return i.evaluate=function(t){for(var e=this.parts,i="",n=0,r=e.length;n<r;++n)i+=e[n].evaluate(t);return i},i.accept=function(t){return t.visitStringInterpolation(this)},e}(wt);function Tt(t,e){for(var i=e.length,n=[],r=0;r<i;r++)n[r]=e[r].evaluate(t);return n}function _t(t,e,i){var n=null==t?null:t[e];if("function"==typeof n)return n;if(!i&&null==n)return null;throw new Error(e+" is not a function")}var Ut=new s(-1,null),Nt=function(){function t(){this.cache={},this.lexer=new a}return t.prototype.parse=function(t,e){void 0===e&&(e={});var i=(t=t||"")+":"+JSON.stringify(e);if(!this.cache[i]){var n=new qt(this.lexer,t,e);this.cache[i]=n.parseExpression();for(var r="",s=0,a=n.tokens.length;s<a;++s)r+=n.tokens[s].text;this.cache[i].toString=function(){return r}}return this.cache[i]},t}(),qt=function(){function t(t,e,i){void 0===i&&(i={}),this.rejectAssignment=i.rejectAssignment||!1,this.stringInterpolationMode=i.stringInterpolationMode||!1,this.index=0,this.input=e,this.tokens=t.lex(e,{stringInterpolationMode:this.stringInterpolationMode})}var e=t.prototype;return e.parseExpression=function(){if(0===this.index&&this.stringInterpolationMode)return this.parseStringInterpolation(!0);for(var t=this.peek.index,e=this.parseConditional();"="===this.peek.text;){if(this.rejectAssignment&&this.error("assignment is not allowed"),!e.isAssignable){var i=this.index<this.tokens.length?this.peek.index:this.input.length,n=this.input.substring(t,i);this.error("Expression "+n+" is not assignable")}this.expect("="),e=new kt(e,this.parseConditional())}return e},e.parseConditional=function(){var t=this.peek.index,e=this.parseLogicalOr();if(this.optional("?")){var i=this.parseExpression();if(!this.optional(":")){var n=this.index<this.tokens.length?this.peek.index:this.input.length,r=this.input.substring(t,n);this.error("Conditional expression "+r+" requires all 3 expressions")}var s=this.parseExpression();e=new yt(e,i,s)}return e},e.parseLogicalOr=function(){for(var t=this.parseLogicalAnd();this.optional("||");)t=new Et("||",t,this.parseLogicalAnd());return t},e.parseLogicalAnd=function(){for(var t=this.parseEquality();this.optional("&&");)t=new Et("&&",t,this.parseEquality());return t},e.parseEquality=function(){for(var t=this.parseRelational();;)if(this.optional("=="))t=new Et("==",t,this.parseRelational());else if(this.optional("!="))t=new Et("!=",t,this.parseRelational());else if(this.optional("==="))t=new Et("===",t,this.parseRelational());else{if(!this.optional("!=="))return t;t=new Et("!==",t,this.parseRelational())}},e.parseRelational=function(){for(var t=this.parseAdditive();;)if(this.optional("<"))t=new Et("<",t,this.parseAdditive());else if(this.optional(">"))t=new Et(">",t,this.parseAdditive());else if(this.optional("<="))t=new Et("<=",t,this.parseAdditive());else{if(!this.optional(">="))return t;t=new Et(">=",t,this.parseAdditive())}},e.parseAdditive=function(){for(var t=this.parseMultiplicative();;)if(this.optional("+"))t=new Et("+",t,this.parseMultiplicative());else{if(!this.optional("-"))return t;t=new Et("-",t,this.parseMultiplicative())}},e.parseMultiplicative=function(){for(var t=this.parsePrefix();;)if(this.optional("*"))t=new Et("*",t,this.parsePrefix());else if(this.optional("%"))t=new Et("%",t,this.parsePrefix());else{if(!this.optional("/"))return t;t=new Et("/",t,this.parsePrefix())}},e.parsePrefix=function(){return this.optional("+")?this.parsePrefix():this.optional("-")?new Et("-",new Mt(0),this.parsePrefix()):this.optional("!")?new jt("!",this.parsePrefix()):this.parseAccessOrCallMember()},e.parseAccessOrCallMember=function(){for(var t=this.parsePrimary();;)if(this.optional(".")){var e=this.peek.text;if(this.advance(),this.optional("(")){var i=this.parseExpressionList(")");this.expect(")"),t=t instanceof Ct?new At(e,i,t.ancestor):new Ot(t,e,i)}else t=t instanceof Ct?new bt(e,t.ancestor):new St(t,e)}else if(this.optional("[")){var n=this.parseExpression();this.expect("]"),t=new mt(t,n)}else{if(!this.optional("("))return t;var r=this.parseExpressionList(")");this.expect(")"),t=new It(t,r)}},e.parseStringInterpolation=function(t){for(var e=[];t?this.peek!==Ut:this.peek!==Ut&&"`"!==this.peek.text;)if(this.optional("${")){var i=this.parseExpression();this.expect("}"),e.push(i)}else if("string"==typeof this.peek.value){var n=this.peek.value;this.advance(),e.push(new Lt(n))}return new $t(e)},e.parsePrimary=function(){if(this.optional("(")){var t=this.parseExpression();return this.expect(")"),t}if(this.optional("`")){var e=this.parseStringInterpolation();return this.expect("`"),e}if(this.optional("null"))return new Mt(null);if(this.optional("undefined"))return new Mt(void 0);if(this.optional("true"))return new Mt(!0);if(this.optional("false"))return new Mt(!1);if(this.optional("[")){var i=this.parseExpressionList("]");return this.expect("]"),new Pt(i)}if("{"===this.peek.text)return this.parseObject();if(null!==this.peek.key&&void 0!==this.peek.key)return this.parseAccessOrCallScope();if(null!==this.peek.value&&void 0!==this.peek.value){var n=this.peek.value;return this.advance(),n instanceof String||"string"==typeof n?new Lt(n):new Mt(n)}if(this.index>=this.tokens.length)throw new Error("Unexpected end of expression: "+this.input);this.error("Unexpected token "+this.peek.text)},e.parseAccessOrCallScope=function(){var t=this.peek.key;if(this.advance(),"$this"===t)return new Ct(0);for(var e=0;"$parent"===t;)if(e++,this.optional("."))t=this.peek.key,this.advance();else{if(this.peek===Ut||"("===this.peek.text||")"===this.peek.text||"["===this.peek.text||"}"===this.peek.text||","===this.peek.text)return new Ct(e);this.error("Unexpected token "+this.peek.text)}if(this.optional("(")){var i=this.parseExpressionList(")");return this.expect(")"),new At(t,i,e)}return new bt(t,e)},e.parseObject=function(){var t=[],e=[];if(this.expect("{"),"}"!==this.peek.text)do{var i=this.peek,n=i.value;t.push("string"==typeof n?n:i.text),this.advance(),!i.key||","!==this.peek.text&&"}"!==this.peek.text?(this.expect(":"),e.push(this.parseExpression())):(--this.index,e.push(this.parseAccessOrCallScope()))}while(this.optional(","));return this.expect("}"),new Rt(t,e)},e.parseExpressionList=function(t){var e=[];if(this.peek.text!==t)do{e.push(this.parseExpression())}while(this.optional(","));return e},e.optional=function(t){return this.peek.text===t&&(this.advance(),!0)},e.expect=function(t){this.peek.text===t?this.advance():this.error("Missing expected "+t)},e.advance=function(){this.index++},e.error=function(t){var e=this.index<this.tokens.length?"at column "+(this.tokens[this.index].index+1)+" in":"at the end of the expression";throw new Error("Parser Error: "+t+" "+e+" ["+this.input+"]")},i(t,[{key:"peek",get:function(){return this.index<this.tokens.length?this.tokens[this.index]:Ut}}]),t}(),Bt=new Nt;function Ft(t,e,i,n){return Bt.parse(t,n).evaluateWith(e,i)}t.Parser=Nt,t.createOverrideContext=dt,t.createSimpleScope=gt,t.evaluate=Ft,t.evaluateStringInterpolation=function(t,e,i,r){return void 0===r&&(r={}),Ft(t,e,i,n({},r,{stringInterpolationMode:!0}))},Object.defineProperty(t,"__esModule",{value:!0})}));
module.exports=function(t,e){"use strict";var i={};function __webpack_require__(e){if(i[e]){return i[e].exports}var n=i[e]={i:e,l:false,exports:{}};t[e].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(874)}e(__webpack_require__);return startup()}({874:function(t,e,i){"use strict";i.r(e);class Token{constructor(t,e){this.index=t;this.text=e}withOp(t){this.opKey=t;return this}withGetterSetter(t){this.key=t;return this}withValue(t){this.value=t;return this}toString(){return`Token(${this.text})`}}class Lexer{lex(t,e){let i=new Scanner(t,e);let n=[];let s=i.scanToken();while(s){n.push(s);s=i.scanToken()}return n}}const n=0;const s=1;const r=2;const a=3;class Scanner{constructor(t,e={}){this.input=t;this.length=t.length;this.peek=0;this.index=-1;this.stringInterpolationMode=e.stringInterpolationMode||false;const i=this.stringInterpolationMode?r:n;this.contextStack=[i];this.advance()}get context(){return this.contextStack[this.contextStack.length-1]}get isRootLevelOfStringInterpolationMode(){return this.stringInterpolationMode&&this.contextStack.length===1}scanToken(){let t=this.index;if(this.context!==r){while(this.peek<=d){if(++this.index>=this.length){this.peek=h;return null}this.peek=this.input.charCodeAt(this.index)}if(isIdentifierStart(this.peek)){return this.scanIdentifier()}if(isDigit(this.peek)){return this.scanNumber(this.index)}switch(this.peek){case I:this.advance();return isDigit(this.peek)?this.scanNumber(t):new Token(t,".");case et:this.contextStack.push(s);return this.scanCharacter(t,String.fromCharCode(this.peek));case nt:this.contextStack.pop();return this.scanCharacter(t,String.fromCharCode(this.peek));case S:case C:case Z:case Y:case A:case m:case M:return this.scanCharacter(t,String.fromCharCode(this.peek));case y:case v:return this.scanString();case _:case L:case b:case j:case g:case J:case F:return this.scanOperator(t,String.fromCharCode(this.peek));case O:case q:case x:case P:return this.scanComplexOperator(t,P,String.fromCharCode(this.peek),"=");case k:return this.scanComplexOperator(t,k,"&","&");case it:return this.scanComplexOperator(t,it,"|","|");case E:this.contextStack.push(r);return this.scanCharacter(t,String.fromCharCode(this.peek));case st:while(isWhitespace(this.peek)){this.advance()}return this.scanToken()}let e=String.fromCharCode(this.peek);this.error(`Unexpected character [${e}]`);return null}else{if(this.peek===E){if(this.isRootLevelOfStringInterpolationMode){return this.scanString()}else{this.contextStack.pop();return this.scanCharacter(t,String.fromCharCode(this.peek))}}else if(this.isStartOfInterpolation()){const t=this.scanStartOfInterpolation();this.contextStack.push(a);return t}else if(this.peek){return this.scanString()}}}scanCharacter(t,e){assert(this.peek===e.charCodeAt(0));this.advance();return new Token(t,e)}scanOperator(t,e){assert(this.peek===e.charCodeAt(0));assert(o.indexOf(e)!==-1);this.advance();return new Token(t,e).withOp(e)}scanComplexOperator(t,e,i,n){assert(this.peek===i.charCodeAt(0));this.advance();let s=i;if(this.peek===e){this.advance();s+=n}if(this.peek===e){this.advance();s+=n}assert(o.indexOf(s)!==-1);return new Token(t,s).withOp(s)}scanIdentifier(){assert(isIdentifierStart(this.peek));let t=this.index;this.advance();while(isIdentifierPart(this.peek)){this.advance()}let e=this.input.substring(t,this.index);let i=new Token(t,e);if(o.indexOf(e)!==-1){i.withOp(e)}else{i.withGetterSetter(e)}return i}scanNumber(t){assert(isDigit(this.peek));let e=this.index===t;this.advance();while(true){if(!isDigit(this.peek)){if(this.peek===I){e=false}else if(isExponentStart(this.peek)){this.advance();if(isExponentSign(this.peek)){this.advance()}if(!isDigit(this.peek)){this.error("Invalid exponent",-1)}e=false}else{break}}this.advance()}let i=this.input.substring(t,this.index);let n=e?parseInt(i,10):parseFloat(i);return new Token(t,i).withValue(n)}scanString(){if(this.context!==r){assert(this.peek===y||this.peek===v)}let t=this.index;let e;if(this.context!==r){e=this.peek;this.advance()}else{e=this.isRootLevelOfStringInterpolationMode?h:E}let i;let n=this.index;while(this.peek!==e&&!this.isStartOfInterpolation()){if(this.peek===z){if(!i){i=[]}i.push(this.input.substring(n,this.index));this.advance();let t;if(this.peek===N){let e=this.input.substring(this.index+1,this.index+5);if(!/[A-Z0-9]{4}/.test(e)){this.error(`Invalid unicode escape [\\u${e}]`)}t=parseInt(e,16);for(let t=0;t<5;++t){this.advance()}}else{t=lexer_unescape(this.peek);this.advance()}i.push(String.fromCharCode(t));n=this.index}else if(e!==h&&this.peek===h){this.error("Unterminated quote")}else{this.advance()}}let s=this.input.substring(n,this.index);if(this.context!==r){this.advance()}let a=this.input.substring(t,this.index);let o=s;if(i!==null&&i!==undefined){i.push(s);o=i.join("")}return new Token(t,a).withValue(o)}scanStartOfInterpolation(){assert(this.isStartOfInterpolation());let t=this.index;this.advance();this.advance();return new Token(t,"${")}advance(){if(++this.index>=this.length){this.peek=h}else{this.peek=this.input.charCodeAt(this.index)}}error(t,e=0){let i=this.index+e;throw new Error(`Lexer Error: ${t} at column ${i} in expression [${this.input}]`)}isStartOfInterpolation(){if(this.context===r){return this.peek===w&&this.input.charCodeAt(this.index+1)===et}}}const o=["undefined","null","true","false","+","-","*","/","%","^","=","==","===","!=","!==","<",">","<=",">=","&&","||","&","|","!","?"];const h=0;const c=9;const p=10;const l=11;const u=12;const f=13;const d=32;const x=33;const v=34;const w=36;const g=37;const k=38;const y=39;const S=40;const C=41;const b=42;const _=43;const A=44;const L=45;const I=46;const j=47;const m=58;const M=59;const O=60;const P=61;const q=62;const F=63;const U=48;const W=57;const V=65;const B=69;const K=90;const Z=91;const z=92;const Y=93;const J=94;const D=95;const E=96;const H=97;const G=101;const X=102;const Q=110;const T=114;const $=116;const N=117;const R=118;const tt=122;const et=123;const it=124;const nt=125;const st=160;function isWhitespace(t){return t>=c&&t<=d||t===st}function isIdentifierStart(t){return H<=t&&t<=tt||V<=t&&t<=K||t===D||t===w}function isIdentifierPart(t){return H<=t&&t<=tt||V<=t&&t<=K||U<=t&&t<=W||t===D||t===w}function isDigit(t){return U<=t&&t<=W}function isExponentStart(t){return t===G||t===B}function isExponentSign(t){return t===L||t===_}function lexer_unescape(t){switch(t){case Q:return p;case X:return u;case T:return f;case $:return c;case R:return l;default:return t}}function assert(t,e){if(!t){throw e||"Assertion failed"}}class Unparser{constructor(t){this.buffer=t}static unparse(t){let e=[];let i=new Unparser(e);t.accept(i);return e.join("")}write(t){this.buffer.push(t)}writeArgs(t){this.write("(");for(let e=0,i=t.length;e<i;++e){if(e!==0){this.write(",")}t[e].accept(this)}this.write(")")}visitAssign(t){t.target.accept(this);this.write("=");t.value.accept(this)}visitConditional(t){t.condition.accept(this);this.write("?");t.yes.accept(this);this.write(":");t.no.accept(this)}visitAccessThis(t){if(t.ancestor===0){this.write("$this");return}this.write("$parent");let e=t.ancestor-1;while(e--){this.write(".$parent")}}visitAccessScope(t){let e=t.ancestor;while(e--){this.write("$parent.")}this.write(t.name)}visitAccessMember(t){t.object.accept(this);this.write(`.${t.name}`)}visitAccessKeyed(t){t.object.accept(this);this.write("[");t.key.accept(this);this.write("]")}visitCallScope(t){let e=t.ancestor;while(e--){this.write("$parent.")}this.write(t.name);this.writeArgs(t.args)}visitCallFunction(t){t.func.accept(this);this.writeArgs(t.args)}visitCallMember(t){t.object.accept(this);this.write(`.${t.name}`);this.writeArgs(t.args)}visitPrefix(t){this.write(`(${t.operation}`);t.expression.accept(this);this.write(")")}visitBinary(t){t.left.accept(this);this.write(t.operation);t.right.accept(this)}visitLiteralPrimitive(t){this.write(`${t.value}`)}visitLiteralArray(t){let e=t.elements;this.write("[");for(let t=0,i=e.length;t<i;++t){if(t!==0){this.write(",")}e[t].accept(this)}this.write("]")}visitLiteralObject(t){let e=t.keys;let i=t.values;this.write("{");for(let t=0,n=e.length;t<n;++t){if(t!==0){this.write(",")}this.write(`'${e[t]}':`);i[t].accept(this)}this.write("}")}visitLiteralString(t){let e=t.value.replace(/'/g,"'");this.write(`'${e}'`)}visitStringInterpolation(t){let e=t.parts;this.write("(''");for(let t=0,i=e.length;t<i;++t){let i=e[t];this.write("+(");e[t].accept(this);this.write(")")}this.write(")")}}function has(t,e){const i=typeof t;return(i==="object"||i==="function")&&e in t}function createOverrideContext(t,e){return{bindingContext:t,parentOverrideContext:e||null}}function getContextFor(t,e,i){let n=e.overrideContext;if(i){while(i&&n){i--;n=n.parentOverrideContext}if(i||!n){return undefined}return has(n,t)?n:n.bindingContext}while(n&&!has(n,t)&&!(n.bindingContext&&has(n.bindingContext,t))){n=n.parentOverrideContext}if(n){return has(n,t)?n:n.bindingContext}return e.bindingContext||e.overrideContext}function createSimpleScope(t,e){if(e){return{bindingContext:t,overrideContext:createOverrideContext(t,createOverrideContext(e))}}return{bindingContext:t,overrideContext:createOverrideContext(t)}}class ast_Expression{constructor(){this.isAssignable=false}evaluate(t,e){throw new Error(`Binding expression "${this}" cannot be evaluated.`)}evaluateWith(t,e,i){return this.evaluate(createSimpleScope(t,e),i)}assign(t,e){throw new Error(`Binding expression "${this}" cannot be assigned to.`)}toString(){return typeof FEATURE_NO_UNPARSER==="undefined"?Unparser.unparse(this):super.toString()}}class Assign extends ast_Expression{constructor(t,e){super();this.target=t;this.value=e;this.isAssignable=true}evaluate(t){return this.target.assign(t,this.value.evaluate(t))}accept(t){t.visitAssign(this)}assign(t,e){this.value.assign(t,e);this.target.assign(t,e)}}class Conditional extends ast_Expression{constructor(t,e,i){super();this.condition=t;this.yes=e;this.no=i}evaluate(t){return!!this.condition.evaluate(t)?this.yes.evaluate(t):this.no.evaluate(t)}accept(t){return t.visitConditional(this)}}class AccessThis extends ast_Expression{constructor(t){super();this.ancestor=t}evaluate(t){let e=t.overrideContext;let i=this.ancestor;while(i--&&e){e=e.parentOverrideContext}return i<1&&e?e.bindingContext:undefined}accept(t){return t.visitAccessThis(this)}}class ast_AccessScope extends ast_Expression{constructor(t,e){super();this.name=t;this.ancestor=e;this.isAssignable=true}evaluate(t){let e=getContextFor(this.name,t,this.ancestor);return e[this.name]}assign(t,e){let i=getContextFor(this.name,t,this.ancestor);return i?i[this.name]=e:undefined}accept(t){return t.visitAccessScope(this)}}class AccessMember extends ast_Expression{constructor(t,e){super();this.object=t;this.name=e;this.isAssignable=true}evaluate(t){let e=this.object.evaluate(t);return e===null||e===undefined?e:e[this.name]}assign(t,e){let i=this.object.evaluate(t);if(i===null||i===undefined){i={};this.object.assign(t,i)}i[this.name]=e;return e}accept(t){return t.visitAccessMember(this)}}class AccessKeyed extends ast_Expression{constructor(t,e){super();this.object=t;this.key=e;this.isAssignable=true}evaluate(t){let e=this.object.evaluate(t);let i=this.key.evaluate(t);return getKeyed(e,i)}assign(t,e){let i=this.object.evaluate(t);let n=this.key.evaluate(t);return setKeyed(i,n,e)}accept(t){return t.visitAccessKeyed(this)}}class ast_CallScope extends ast_Expression{constructor(t,e,i){super();this.name=t;this.args=e;this.ancestor=i}evaluate(t,e){let i=evalList(t,this.args);let n=getContextFor(this.name,t,this.ancestor);let s=getFunction(n,this.name,e);if(s){return s.apply(n,i)}return undefined}accept(t){return t.visitCallScope(this)}}class CallMember extends ast_Expression{constructor(t,e,i){super();this.object=t;this.name=e;this.args=i}evaluate(t,e){let i=this.object.evaluate(t);let n=evalList(t,this.args);let s=getFunction(i,this.name,e);if(s){return s.apply(i,n)}return undefined}accept(t){return t.visitCallMember(this)}}class CallFunction extends ast_Expression{constructor(t,e){super();this.func=t;this.args=e}evaluate(t,e){let i=this.func.evaluate(t);if(typeof i==="function"){return i.apply(null,evalList(t,this.args))}if(!e&&(i===null||i===undefined)){return undefined}throw new Error(`${this.func} is not a function`)}accept(t){return t.visitCallFunction(this)}}class Binary extends ast_Expression{constructor(t,e,i){super();this.operation=t;this.left=e;this.right=i}evaluate(t){let e=this.left.evaluate(t);switch(this.operation){case"&&":return e&&this.right.evaluate(t);case"||":return e||this.right.evaluate(t)}let i=this.right.evaluate(t);switch(this.operation){case"==":return e==i;case"===":return e===i;case"!=":return e!=i;case"!==":return e!==i}if(e===null||i===null||e===undefined||i===undefined){switch(this.operation){case"+":if(e!==null&&e!==undefined)return e;if(i!==null&&i!==undefined)return i;return 0;case"-":if(e!==null&&e!==undefined)return e;if(i!==null&&i!==undefined)return 0-i;return 0}}switch(this.operation){case"+":return autoConvertAdd(e,i);case"-":return e-i;case"*":return e*i;case"/":return e/i;case"%":return e%i;case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i;case"^":return e^i;case"&":return e&i;case"|":return e|i;case"<<":return e<<i;case">>":return e>>i;case">>>":return e>>>i}throw new Error(`Internal error [${this.operation}] not handled`)}accept(t){return t.visitBinary(this)}}class PrefixNot extends ast_Expression{constructor(t,e){super();this.operation=t;this.expression=e}evaluate(t){return!this.expression.evaluate(t)}accept(t){return t.visitPrefix(this)}}class LiteralPrimitive extends ast_Expression{constructor(t){super();this.value=t}evaluate(t){return this.value}accept(t){return t.visitLiteralPrimitive(this)}}class LiteralString extends ast_Expression{constructor(t){super();this.value=t}evaluate(t){return this.value}accept(t){return t.visitLiteralString(this)}}class LiteralArray extends ast_Expression{constructor(t){super();this.elements=t}evaluate(t){let e=this.elements;let i=[];for(let n=0,s=e.length;n<s;++n){i[n]=e[n].evaluate(t)}return i}accept(t){return t.visitLiteralArray(this)}}class LiteralObject extends ast_Expression{constructor(t,e){super();this.keys=t;this.values=e}evaluate(t){let e={};let i=this.keys;let n=this.values;for(let s=0,r=i.length;s<r;++s){e[i[s]]=n[s].evaluate(t)}return e}accept(t){return t.visitLiteralObject(this)}}class StringInterpolation extends ast_Expression{constructor(t){super();this.parts=t}evaluate(t){let e=this.parts;let i="";for(let n=0,s=e.length;n<s;++n){i+=e[n].evaluate(t)}return i}accept(t){return t.visitStringInterpolation(this)}}function evalList(t,e){const i=e.length;const n=[];for(let s=0;s<i;s++){n[s]=e[s].evaluate(t)}return n}function autoConvertAdd(t,e){if(t!==null&&e!==null){if(typeof t==="string"&&typeof e!=="string"){return t+e.toString()}if(typeof t!=="string"&&typeof e==="string"){return t.toString()+e}return t+e}if(t!==null){return t}if(e!==null){return e}return 0}function getFunction(t,e,i){let n=t===null||t===undefined?null:t[e];if(typeof n==="function"){return n}if(!i&&(n===null||n===undefined)){return null}throw new Error(`${e} is not a function`)}function getKeyed(t,e){if(Array.isArray(t)){return t[parseInt(e,10)]}else if(t){return t[e]}else if(t===null||t===undefined){return undefined}return t[e]}function setKeyed(t,e,i){if(Array.isArray(t)){let n=parseInt(e,10);if(t.length<=n){t.length=n+1}t[n]=i}else{t[e]=i}return i}let rt=new Token(-1,null);class parser_Parser{constructor(){this.cache={};this.lexer=new Lexer}parse(t,e={}){t=t||"";const i=t+":"+JSON.stringify(e);if(!this.cache[i]){const n=new parser_ParserImplementation(this.lexer,t,e);this.cache[i]=n.parseExpression();let s="";for(let t=0,e=n.tokens.length;t<e;++t){s+=n.tokens[t].text}this.cache[i].toString=function(){return s}}return this.cache[i]}}class parser_ParserImplementation{constructor(t,e,i={}){this.rejectAssignment=i.rejectAssignment||false;this.stringInterpolationMode=i.stringInterpolationMode||false;this.index=0;this.input=e;this.tokens=t.lex(e,{stringInterpolationMode:this.stringInterpolationMode})}get peek(){return this.index<this.tokens.length?this.tokens[this.index]:rt}parseExpression(){if(this.index===0&&this.stringInterpolationMode){return this.parseStringInterpolation(true)}let t=this.peek.index;let e=this.parseConditional();while(this.peek.text==="="){if(this.rejectAssignment){this.error("assignment is not allowed")}if(!e.isAssignable){let e=this.index<this.tokens.length?this.peek.index:this.input.length;let i=this.input.substring(t,e);this.error(`Expression ${i} is not assignable`)}this.expect("=");e=new Assign(e,this.parseConditional())}return e}parseConditional(){let t=this.peek.index;let e=this.parseLogicalOr();if(this.optional("?")){let i=this.parseExpression();if(!this.optional(":")){let e=this.index<this.tokens.length?this.peek.index:this.input.length;let i=this.input.substring(t,e);this.error(`Conditional expression ${i} requires all 3 expressions`)}let n=this.parseExpression();e=new Conditional(e,i,n)}return e}parseLogicalOr(){let t=this.parseLogicalAnd();while(this.optional("||")){t=new Binary("||",t,this.parseLogicalAnd())}return t}parseLogicalAnd(){let t=this.parseEquality();while(this.optional("&&")){t=new Binary("&&",t,this.parseEquality())}return t}parseEquality(){let t=this.parseRelational();while(true){if(this.optional("==")){t=new Binary("==",t,this.parseRelational())}else if(this.optional("!=")){t=new Binary("!=",t,this.parseRelational())}else if(this.optional("===")){t=new Binary("===",t,this.parseRelational())}else if(this.optional("!==")){t=new Binary("!==",t,this.parseRelational())}else{return t}}}parseRelational(){let t=this.parseAdditive();while(true){if(this.optional("<")){t=new Binary("<",t,this.parseAdditive())}else if(this.optional(">")){t=new Binary(">",t,this.parseAdditive())}else if(this.optional("<=")){t=new Binary("<=",t,this.parseAdditive())}else if(this.optional(">=")){t=new Binary(">=",t,this.parseAdditive())}else{return t}}}parseAdditive(){let t=this.parseMultiplicative();while(true){if(this.optional("+")){t=new Binary("+",t,this.parseMultiplicative())}else if(this.optional("-")){t=new Binary("-",t,this.parseMultiplicative())}else{return t}}}parseMultiplicative(){let t=this.parsePrefix();while(true){if(this.optional("*")){t=new Binary("*",t,this.parsePrefix())}else if(this.optional("%")){t=new Binary("%",t,this.parsePrefix())}else if(this.optional("/")){t=new Binary("/",t,this.parsePrefix())}else{return t}}}parsePrefix(){if(this.optional("+")){return this.parsePrefix()}else if(this.optional("-")){return new Binary("-",new LiteralPrimitive(0),this.parsePrefix())}else if(this.optional("!")){return new PrefixNot("!",this.parsePrefix())}return this.parseAccessOrCallMember()}parseAccessOrCallMember(){let t=this.parsePrimary();while(true){if(this.optional(".")){let e=this.peek.text;this.advance();if(this.optional("(")){let i=this.parseExpressionList(")");this.expect(")");if(t instanceof AccessThis){t=new ast_CallScope(e,i,t.ancestor)}else{t=new CallMember(t,e,i)}}else{if(t instanceof AccessThis){t=new ast_AccessScope(e,t.ancestor)}else{t=new AccessMember(t,e)}}}else if(this.optional("[")){let e=this.parseExpression();this.expect("]");t=new AccessKeyed(t,e)}else if(this.optional("(")){let e=this.parseExpressionList(")");this.expect(")");t=new CallFunction(t,e)}else{return t}}}parseStringInterpolation(t){let e=[];while(t?this.peek!==rt:this.peek!==rt&&this.peek.text!=="`"){if(this.optional("${")){let t=this.parseExpression();this.expect("}");e.push(t)}else if(typeof this.peek.value==="string"){let t=this.peek.value;this.advance();e.push(new LiteralString(t))}}return new StringInterpolation(e)}parsePrimary(){if(this.optional("(")){let t=this.parseExpression();this.expect(")");return t}else if(this.optional("`")){let t=this.parseStringInterpolation();this.expect("`");return t}else if(this.optional("null")){return new LiteralPrimitive(null)}else if(this.optional("undefined")){return new LiteralPrimitive(undefined)}else if(this.optional("true")){return new LiteralPrimitive(true)}else if(this.optional("false")){return new LiteralPrimitive(false)}else if(this.optional("[")){let t=this.parseExpressionList("]");this.expect("]");return new LiteralArray(t)}else if(this.peek.text==="{"){return this.parseObject()}else if(this.peek.key!==null&&this.peek.key!==undefined){return this.parseAccessOrCallScope()}else if(this.peek.value!==null&&this.peek.value!==undefined){let t=this.peek.value;this.advance();return t instanceof String||typeof t==="string"?new LiteralString(t):new LiteralPrimitive(t)}else if(this.index>=this.tokens.length){throw new Error(`Unexpected end of expression: ${this.input}`)}else{this.error(`Unexpected token ${this.peek.text}`)}}parseAccessOrCallScope(){let t=this.peek.key;this.advance();if(t==="$this"){return new AccessThis(0)}let e=0;while(t==="$parent"){e++;if(this.optional(".")){t=this.peek.key;this.advance()}else if(this.peek===rt||this.peek.text==="("||this.peek.text===")"||this.peek.text==="["||this.peek.text==="}"||this.peek.text===","){return new AccessThis(e)}else{this.error(`Unexpected token ${this.peek.text}`)}}if(this.optional("(")){let i=this.parseExpressionList(")");this.expect(")");return new ast_CallScope(t,i,e)}return new ast_AccessScope(t,e)}parseObject(){let t=[];let e=[];this.expect("{");if(this.peek.text!=="}"){do{let i=this.peek;let n=i.value;t.push(typeof n==="string"?n:i.text);this.advance();if(i.key&&(this.peek.text===","||this.peek.text==="}")){--this.index;e.push(this.parseAccessOrCallScope())}else{this.expect(":");e.push(this.parseExpression())}}while(this.optional(","))}this.expect("}");return new LiteralObject(t,e)}parseExpressionList(t){let e=[];if(this.peek.text!==t){do{e.push(this.parseExpression())}while(this.optional(","))}return e}optional(t){if(this.peek.text===t){this.advance();return true}return false}expect(t){if(this.peek.text===t){this.advance()}else{this.error(`Missing expected ${t}`)}}advance(){this.index++}error(t){let e=this.index<this.tokens.length?`at column ${this.tokens[this.index].index+1} in`:"at the end of the expression";throw new Error(`Parser Error: ${t} ${e} [${this.input}]`)}}i.d(e,"Parser",function(){return parser_Parser});i.d(e,"createOverrideContext",function(){return createOverrideContext});i.d(e,"createSimpleScope",function(){return createSimpleScope});i.d(e,"evaluate",function(){return evaluate});i.d(e,"evaluateStringInterpolation",function(){return evaluateStringInterpolation});const at=new parser_Parser;function evaluate(t,e,i,n){const s=at.parse(t,n);return s.evaluateWith(e,i)}function evaluateStringInterpolation(t,e,i,n={}){return evaluate(t,e,i,{...n,stringInterpolationMode:true})}}},function(t){"use strict";!function(){t.r=function(t){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})}}();!function(){var e=Object.prototype.hasOwnProperty;t.d=function(t,i,n){if(!e.call(t,i)){Object.defineProperty(t,i,{enumerable:true,get:n})}}}()});
{
"name": "bcx-expression-evaluator",
"version": "1.1.0",
"version": "1.2.0",
"description": "Safely evaluate a JavaScript like expression in given context.",

@@ -21,15 +21,13 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"@babel/register": "^7.6.2",
"babel-eslint": "^10.0.3",
"eslint": "^6.5.1",
"rollup": "^1.23.1",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-terser": "^5.1.2",
"standard-changelog": "^2.0.15",
"tape": "^4.11.0"
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/register": "^7.9.0",
"@zeit/ncc": "^0.22.1",
"babel-eslint": "^10.1.0",
"eslint": "^7.0.0",
"standard-changelog": "^2.0.24",
"tape": "^5.0.0"
},
"scripts": {
"build": "env BABEL_ENV=development rollup -c",
"build": "ncc build src/index.js -m",
"lint": "eslint src",

@@ -41,3 +39,3 @@ "prepare": "npm run build",

"pretest": "npm run lint",
"test": "env BABEL_ENV=test tape -r @babel/register 'test/**/*.spec.js'"
"test": "tape -r @babel/register 'test/**/*.spec.js'"
},

@@ -44,0 +42,0 @@ "main": "dist/index.js",

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

# bcx-expression-evaluator [![Build Status](https://travis-ci.org/buttonwoodcx/bcx-expression-evaluator.svg?branch=master)](https://travis-ci.org/buttonwoodcx/bcx-expression-evaluator)
# bcx-expression-evaluator ![CI](https://github.com/buttonwoodcx/bcx-expression-evaluator/workflows/CI/badge.svg)

@@ -11,3 +11,3 @@ Safely evaluate a JavaScript-like expression in given context.

npm install --save bcx-expression-evaluator
npm install bcx-expression-evaluator

@@ -14,0 +14,0 @@ ## Document

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc