-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsql-where-parser.min.js
More file actions
1 lines (1 loc) · 14 KB
/
sql-where-parser.min.js
File metadata and controls
1 lines (1 loc) · 14 KB
1
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.SqlWhereParser=t()}}(function(){var t;return function t(e,r,n){function o(s,u){if(!r[s]){if(!e[s]){var c="function"==typeof require&&require;if(!u&&c)return c(s,!0);if(i)return i(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var r=e[s][1][t];return o(r?r:t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),u=t("es6-symbol"),c=t("tokenize-this"),a=u("-"),f=1,l=2,p=3,h=o({},a,f),y=function(){function t(e,r,o){n(this,t),this.value=e,this.type=r,this.precedence=o}return s(t,[{key:"toJSON",value:function(){return this.value}},{key:"toString",value:function(){return""+this.value}}]),t}(),d=function(){function t(e){var r=this;n(this,t),e||(e={}),e=Object.assign({},this.constructor.defaultConfig,e),this.tokenizer=new c(e.tokenizer),this.operators={},e.operators.forEach(function(t,e){Object.keys(t).concat(Object.getOwnPropertySymbols(t)).forEach(function(n){r.operators[n]=new y(n,t[n],e)})})}return s(t,[{key:"parse",value:function(t,e){var r=this,n=[],o=[],i=void 0,s=0,u=!1;for(e||(e=this.defaultEvaluator),this.tokenizer.tokenize("("+t+")",function(t,c){if(s++,"string"!=typeof t||c)o.push(t),u=!1;else{var f=t.toUpperCase();if(r.operators[f]){if("BETWEEN"===i&&"AND"===f)return void(i="AND");for("-"!==f||1!==s&&!u||(f=a);n[n.length-1]&&"("!==n[n.length-1]&&r.operatorPrecedenceFromValues(f,n[n.length-1]);){for(var l=r.operators[n.pop()],p=[],h=l.type;h--;)p.unshift(o.pop());o.push(e(l.value,p))}n.push(f),i=f,u=!0}else if("("===t)n.push(t),u=!0;else if(")"===t){for(;n.length&&"("!==n[n.length-1];){for(var y=r.operators[n.pop()],d=[],m=y.type;m--;)d.unshift(o.pop());o.push(e(y.value,d))}if(!n.length)throw new SyntaxError("Unmatched parenthesis.");n.pop(),u=!1}else o.push(t),u=!1}});n.length;){var c=n.pop();if("("===c)throw new SyntaxError("Unmatched parenthesis.");for(var f=this.operators[c],l=[],p=f.type;p--;)l.unshift(o.pop());o.push(e(f.value,l))}if(o.length>1)throw new SyntaxError("Could not reduce to a single expression.");return o[0]}},{key:"toArray",value:function(t){var e=this,r=[],n=0,o=void 0,i=[];for(this.tokenizer.tokenize("("+t+")",function(t,s){switch(n++,t){case"(":i.push(r.length);break;case")":for(var u=i.pop(),c=r.splice(u,r.length);c&&c.constructor===Array&&1===c.length;)c=c[0];r.push(c);break;case"":break;case",":break;default:var f=null;s||(f=e.getOperator(t),"-"===t&&(1===n||"("===o||o&&o.constructor===y)&&(f=e.getOperator(a))),r.push(f?f:t)}o=t});r&&r.constructor===Array&&1===r.length;)r=r[0];return r}},{key:"operatorPrecedenceFromValues",value:function(t,e){return this.operators[e].precedence<=this.operators[t].precedence}},{key:"getOperator",value:function(t){return"string"==typeof t?this.operators[t.toUpperCase()]:"symbol"===("undefined"==typeof t?"undefined":i(t))?this.operators[t]:null}},{key:"defaultEvaluator",value:function(t,e){return t===a&&(t="-"),","===t?[].concat(e[0],e[1]):o({},t,e)}}],[{key:"defaultConfig",get:function(){return{operators:[{"!":f},h,{"^":l},{"*":l,"/":l,"%":l},{"+":l,"-":l},{"=":l,"<":l,">":l,"<=":l,">=":l,"!=":l},{",":l},{NOT:f},{BETWEEN:p,IN:l,IS:l,LIKE:l},{AND:l},{OR:l}],tokenizer:{shouldTokenize:["(",")",",","*","/","%","+","-","=","!=","!","<",">","<=",">=","^"],shouldMatch:['"',"'","`"],shouldDelimitBy:[" ","\n","\r","\t"]}}}},{key:"Operator",get:function(){return y}},{key:"OPERATOR_UNARY_MINUS",get:function(){return a}}]),t}();e.exports=d},{"es6-symbol":2,"tokenize-this":20}],2:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":3,"./polyfill":18}],3:[function(t,e,r){"use strict";var n={object:!0,symbol:!0};e.exports=function(){var t;if("function"!=typeof Symbol)return!1;t=Symbol("test symbol");try{String(t)}catch(t){return!1}return!!n[typeof Symbol.iterator]&&(!!n[typeof Symbol.toPrimitive]&&!!n[typeof Symbol.toStringTag])}},{}],4:[function(t,e,r){"use strict";e.exports=function(t){return!!t&&("symbol"==typeof t||!!t.constructor&&("Symbol"===t.constructor.name&&"Symbol"===t[t.constructor.toStringTag]))}},{}],5:[function(t,e,r){"use strict";var n,o=t("es5-ext/object/assign"),i=t("es5-ext/object/normalize-options"),s=t("es5-ext/object/is-callable"),u=t("es5-ext/string/#/contains");n=e.exports=function(t,e){var r,n,s,c,a;return arguments.length<2||"string"!=typeof t?(c=e,e=t,t=null):c=arguments[2],null==t?(r=s=!0,n=!1):(r=u.call(t,"c"),n=u.call(t,"e"),s=u.call(t,"w")),a={value:e,configurable:r,enumerable:n,writable:s},c?o(i(c),a):a},n.gs=function(t,e,r){var n,c,a,f;return"string"!=typeof t?(a=r,r=e,e=t,t=null):a=arguments[3],null==e?e=void 0:s(e)?null==r?r=void 0:s(r)||(a=r,r=void 0):(a=e,e=r=void 0),null==t?(n=!0,c=!1):(n=u.call(t,"c"),c=u.call(t,"e")),f={get:e,set:r,configurable:n,enumerable:c},a?o(i(a),f):f}},{"es5-ext/object/assign":6,"es5-ext/object/is-callable":9,"es5-ext/object/normalize-options":13,"es5-ext/string/#/contains":15}],6:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.assign:t("./shim")},{"./is-implemented":7,"./shim":8}],7:[function(t,e,r){"use strict";e.exports=function(){var t,e=Object.assign;return"function"==typeof e&&(t={foo:"raz"},e(t,{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},{}],8:[function(t,e,r){"use strict";var n=t("../keys"),o=t("../valid-value"),i=Math.max;e.exports=function(t,e){var r,s,u,c=i(arguments.length,2);for(t=Object(o(t)),u=function(n){try{t[n]=e[n]}catch(t){r||(r=t)}},s=1;s<c;++s)e=arguments[s],n(e).forEach(u);if(void 0!==r)throw r;return t}},{"../keys":10,"../valid-value":14}],9:[function(t,e,r){"use strict";e.exports=function(t){return"function"==typeof t}},{}],10:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Object.keys:t("./shim")},{"./is-implemented":11,"./shim":12}],11:[function(t,e,r){"use strict";e.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},{}],12:[function(t,e,r){"use strict";var n=Object.keys;e.exports=function(t){return n(null==t?t:Object(t))}},{}],13:[function(t,e,r){"use strict";var n=Array.prototype.forEach,o=Object.create,i=function(t,e){var r;for(r in t)e[r]=t[r]};e.exports=function(t){var e=o(null);return n.call(arguments,function(t){null!=t&&i(Object(t),e)}),e}},{}],14:[function(t,e,r){"use strict";e.exports=function(t){if(null==t)throw new TypeError("Cannot use null or undefined");return t}},{}],15:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?String.prototype.contains:t("./shim")},{"./is-implemented":16,"./shim":17}],16:[function(t,e,r){"use strict";var n="razdwatrzy";e.exports=function(){return"function"==typeof n.contains&&(n.contains("dwa")===!0&&n.contains("foo")===!1)}},{}],17:[function(t,e,r){"use strict";var n=String.prototype.indexOf;e.exports=function(t){return n.call(this,t,arguments[1])>-1}},{}],18:[function(t,e,r){"use strict";var n,o,i,s,u=t("d"),c=t("./validate-symbol"),a=Object.create,f=Object.defineProperties,l=Object.defineProperty,p=Object.prototype,h=a(null);if("function"==typeof Symbol){n=Symbol;try{String(n()),s=!0}catch(t){}}var y=function(){var t=a(null);return function(e){for(var r,n,o=0;t[e+(o||"")];)++o;return e+=o||"",t[e]=!0,r="@@"+e,l(p,r,u.gs(null,function(t){n||(n=!0,l(this,r,u(t)),n=!1)})),r}}();i=function(t){if(this instanceof i)throw new TypeError("TypeError: Symbol is not a constructor");return o(t)},e.exports=o=function t(e){var r;if(this instanceof t)throw new TypeError("TypeError: Symbol is not a constructor");return s?n(e):(r=a(i.prototype),e=void 0===e?"":String(e),f(r,{__description__:u("",e),__name__:u("",y(e))}))},f(o,{for:u(function(t){return h[t]?h[t]:h[t]=o(String(t))}),keyFor:u(function(t){var e;c(t);for(e in h)if(h[e]===t)return e}),hasInstance:u("",n&&n.hasInstance||o("hasInstance")),isConcatSpreadable:u("",n&&n.isConcatSpreadable||o("isConcatSpreadable")),iterator:u("",n&&n.iterator||o("iterator")),match:u("",n&&n.match||o("match")),replace:u("",n&&n.replace||o("replace")),search:u("",n&&n.search||o("search")),species:u("",n&&n.species||o("species")),split:u("",n&&n.split||o("split")),toPrimitive:u("",n&&n.toPrimitive||o("toPrimitive")),toStringTag:u("",n&&n.toStringTag||o("toStringTag")),unscopables:u("",n&&n.unscopables||o("unscopables"))}),f(i.prototype,{constructor:u(o),toString:u("",function(){return this.__name__})}),f(o.prototype,{toString:u(function(){return"Symbol ("+c(this).__description__+")"}),valueOf:u(function(){return c(this)})}),l(o.prototype,o.toPrimitive,u("",function(){var t=c(this);return"symbol"==typeof t?t:t.toString()})),l(o.prototype,o.toStringTag,u("c","Symbol")),l(i.prototype,o.toStringTag,u("c",o.prototype[o.toStringTag])),l(i.prototype,o.toPrimitive,u("c",o.prototype[o.toPrimitive]))},{"./validate-symbol":19,d:5}],19:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":4}],20:[function(e,r,n){(function(o){!function(e){if("object"==typeof n&&"undefined"!=typeof r)r.exports=e();else if("function"==typeof t&&t.amd)t([],e);else{var i;i="undefined"!=typeof window?window:"undefined"!=typeof o?o:"undefined"!=typeof self?self:this,i.TokenizeThis=e()}}(function(){return function t(r,n,o){function i(u,c){if(!n[u]){if(!r[u]){var a="function"==typeof e&&e;if(!c&&a)return a(u,!0);if(s)return s(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[u]={exports:{}};r[u][0].call(l.exports,function(t){var e=r[u][1][t];return i(e?e:t)},l,l.exports,t,r,n,o)}return n[u].exports}for(var s="function"==typeof e&&e,u=0;u<o.length;u++)i(o[u]);return i}({1:[function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i="modeNone",s="modeDefault",u="modeMatch",c=function(t,e){return t.length>e.length?-1:t.length<e.length?1:0},a=function(){function t(e,r,o){n(this,t),this.factory=e,this.str=r,this.forEachToken=o,this.previousChr="",this.toMatch="",this.currentToken="",this.modeStack=[i]}return o(t,[{key:"getCurrentMode",value:function(){return this.modeStack[this.modeStack.length-1]}},{key:"setCurrentMode",value:function(t){return this.modeStack.push(t)}},{key:"completeCurrentMode",value:function(){var t=this.getCurrentMode();return t===s&&this.pushDefaultModeTokenizables(),(t===u&&""===this.currentToken||""!==this.currentToken)&&this.push(this.currentToken),this.currentToken="",this.modeStack.pop()}},{key:"push",value:function(t){var e="";if(this.factory.convertLiterals&&this.getCurrentMode()!==u)switch(t.toLowerCase()){case"null":t=null;break;case"true":t=!0;break;case"false":t=!1;break;default:isFinite(t)&&(t=Number(t))}else e=this.toMatch;this.forEachToken&&this.forEachToken(t,e)}},{key:"tokenize",value:function(){for(var t=0;t<this.str.length;)this.consume(this.str.charAt(t++));for(;this.getCurrentMode()!==i;)this.completeCurrentMode()}},{key:"consume",value:function(t){this[this.getCurrentMode()](t),this.previousChr=t}},{key:i,value:function(t){return this.factory.matchMap[t]?(this.setCurrentMode(u),void(this.toMatch=t)):(this.setCurrentMode(s),this.consume(t))}},{key:s,value:function(t){return this.factory.delimiterMap[t]?this.completeCurrentMode():this.factory.matchMap[t]?(this.completeCurrentMode(),this.consume(t)):(this.currentToken+=t,this.currentToken)}},{key:"pushDefaultModeTokenizables",value:function(){for(var t=0,e=1/0,r=null;this.currentToken&&t<this.factory.tokenizeList.length;){var n=this.factory.tokenizeList[t++],o=this.currentToken.indexOf(n);o!==-1&&o<e&&(e=o,r=n)}if(r)return e>0&&this.push(this.currentToken.substring(0,e)),e!==-1?(this.push(r),this.currentToken=this.currentToken.substring(e+r.length),this.pushDefaultModeTokenizables()):void 0}},{key:u,value:function(t){if(t===this.toMatch){if(this.previousChr!==this.factory.escapeCharacter)return this.completeCurrentMode();this.currentToken=this.currentToken.substring(0,this.currentToken.length-1)}return this.currentToken+=t,this.currentToken}}]),t}(),f=function(){function t(e){var r=this;n(this,t),e||(e={}),e=Object.assign({},this.constructor.defaultConfig,e),this.convertLiterals=e.convertLiterals,this.escapeCharacter=e.escapeCharacter,this.tokenizeList=[],this.tokenizeMap={},this.matchList=[],this.matchMap={},this.delimiterList=[],this.delimiterMap={},e.shouldTokenize.sort(c).forEach(function(t){r.tokenizeMap[t]||(r.tokenizeList.push(t),r.tokenizeMap[t]=t)}),e.shouldMatch.forEach(function(t){r.matchMap[t]||(r.matchList.push(t),r.matchMap[t]=t)}),e.shouldDelimitBy.forEach(function(t){r.delimiterMap[t]||(r.delimiterList.push(t),r.delimiterMap[t]=t)})}return o(t,[{key:"tokenize",value:function(t,e){var r=new a(this,t,e);return r.tokenize()}}],[{key:"defaultConfig",get:function(){return{shouldTokenize:["(",")",",","*","/","%","+","-","=","!=","!","<",">","<=",">=","^"],shouldMatch:['"',"'","`"],shouldDelimitBy:[" ","\n","\r","\t"],convertLiterals:!0,escapeCharacter:"\\"}}}]),t}();e.exports=f},{}]},{},[1])(1)})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});