UNPKG

dropkiq

Version:

Liquid Expressions Simplified

1 lines 2.33 kB
"use strict";var __generator=this&&this.__generator||function(e,r){var t,n,a,o,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(t)throw new TypeError("Generator is already executing.");for(;l;)try{if(t=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,n=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=r.call(e,l)}catch(e){o=[6,e],n=0}finally{t=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},__values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(exports,"__esModule",{value:!0});var lexical_1=require("../../parser/lexical"),expression_1=require("../../render/expression"),Hash=function(){function e(){}return e.parse=function(r){var t,n=new e;for(lexical_1.hashCapture.lastIndex=0;t=lexical_1.hashCapture.exec(r);){var a=t[1],o=t[2];n[a]=o}return n},e.create=function(r,t){var n,a,o,l,s,u,i,c,f;return __generator(this,(function(p){switch(p.label){case 0:n=e.parse(r),p.label=1;case 1:p.trys.push([1,6,7,8]),a=__values(Object.keys(n)),o=a.next(),p.label=2;case 2:return o.done?[3,5]:(l=o.value,s=n,u=l,[4,new expression_1.Expression(n[l]).evaluate(t)]);case 3:s[u]=p.sent(),p.label=4;case 4:return o=a.next(),[3,2];case 5:return[3,8];case 6:return i=p.sent(),c={error:i},[3,8];case 7:try{o&&!o.done&&(f=a.return)&&f.call(a)}finally{if(c)throw c.error}return[7];case 8:return[2,n]}}))},e}();exports.Hash=Hash;