precedent 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +1 -1
- package/dist/precedent.compatible.js +3975 -315
- package/dist/precedent.compatible.min.js +4 -4
- package/dist/precedent.compatible.min.js.map +1 -1
- package/dist/precedent.js +3975 -315
- package/dist/precedent.min.js +4 -4
- package/dist/precedent.min.js.map +1 -1
- package/gulpfile-config.json +2 -2
- package/package.json +4 -2
- package/source/Precedent.js +7 -2
- package/source/StringParser.js +129 -16
- package/source/WordTree.js +32 -0
- package/test/Precedent_tests.js +23 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Precedent=t()}}((function(){return function t(e,r,n){function a(s,f){if(!r[s]){if(!e[s]){var o="function"==typeof require&&require;if(!f&&o)return o(s,!0);if(u)return u(s,!0);var i=new Error("Cannot find module '"+s+"'");throw i.code="MODULE_NOT_FOUND",i}var P=r[s]={exports:{}};e[s][0].call(P.exports,(function(t){return a(e[s][1][t]||t)}),P,P.exports,t,e,r,n)}return r[s].exports}for(var u="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(t,e,r){var n=t("./Precedent.js");"object"!=typeof window||window.hasOwnProperty("Precedent")||(window.Precedent=n),e.exports=n},{"./Precedent.js":2}],2:[function(t,e,r){
|
|
1
|
+
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Precedent=t()}}((function(){return function t(e,r,n){function i(a,o){if(!r[a]){if(!e[a]){var s="function"==typeof require&&require;if(!o&&s)return s(a,!0);if(u)return u(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[a]={exports:{}};e[a][0].call(f.exports,(function(t){return i(e[a][1][t]||t)}),f,f.exports,t,e,r,n)}return r[a].exports}for(var u="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}({1:[function(t,e,r){(function(t,n){(function(){!function(t,n){n("object"==typeof r&&void 0!==e?r:t.async={})}(this,(function(e){"use strict";function r(t,...e){return(...r)=>t(...e,...r)}function i(t){return function(...e){var r=e.pop();return t.call(this,e,r)}}var u="function"==typeof queueMicrotask&&queueMicrotask,a="function"==typeof n&&n,o="object"==typeof t&&"function"==typeof t.nextTick;function s(t){setTimeout(t,0)}function c(t){return(e,...r)=>t((()=>e(...r)))}var f=c(u?queueMicrotask:a?n:o?t.nextTick:s);function l(t){return d(t)?function(...e){const r=e.pop();return h(t.apply(this,e),r)}:i((function(e,r){var n;try{n=t.apply(this,e)}catch(t){return r(t)}if(n&&"function"==typeof n.then)return h(n,r);r(null,n)}))}function h(t,e){return t.then((t=>{p(e,null,t)}),(t=>{p(e,t&&t.message?t:new Error(t))}))}function p(t,e,r){try{t(e,r)}catch(t){f((t=>{throw t}),t)}}function d(t){return"AsyncFunction"===t[Symbol.toStringTag]}function y(t){if("function"!=typeof t)throw new Error("expected a function");return d(t)?l(t):t}function v(t,e=t.length){if(!e)throw new Error("arity is undefined");return function(...r){return"function"==typeof r[e-1]?t.apply(this,r):new Promise(((n,i)=>{r[e-1]=(t,...e)=>{if(t)return i(t);n(e.length>1?e:e[0])},t.apply(this,r)}))}}function m(t){return function(e,...r){return v((function(n){var i=this;return t(e,((t,e)=>{y(t).apply(i,r.concat(e))}),n)}))}}function g(t,e,r,n){e=e||[];var i=[],u=0,a=y(r);return t(e,((t,e,r)=>{var n=u++;a(t,((t,e)=>{i[n]=e,r(t)}))}),(t=>{n(t,i)}))}function P(t){return t&&"number"==typeof t.length&&t.length>=0&&t.length%1==0}const w={};function O(t){function e(...e){if(null!==t){var r=t;t=null,r.apply(this,e)}}return Object.assign(e,t),e}function S(t){if(P(t))return function(t){var e=-1,r=t.length;return function(){return++e<r?{value:t[e],key:e}:null}}(t);var e,r,n,i,u=function(t){return t[Symbol.iterator]&&t[Symbol.iterator]()}(t);return u?function(t){var e=-1;return function(){var r=t.next();return r.done?null:(e++,{value:r.value,key:e})}}(u):(r=(e=t)?Object.keys(e):[],n=-1,i=r.length,function t(){var u=r[++n];return"__proto__"===u?t():n<i?{value:e[u],key:u}:null})}function E(t){return function(...e){if(null===t)throw new Error("Callback was already called.");var r=t;t=null,r.apply(this,e)}}function b(t,e,r,n){let i=!1,u=!1,a=!1,o=0,s=0;function c(){o>=e||a||i||(a=!0,t.next().then((({value:t,done:e})=>{if(!u&&!i){if(a=!1,e)return i=!0,void(o<=0&&n(null));o++,r(t,s,f),s++,c()}})).catch(l))}function f(t,e){if(o-=1,!u)return t?l(t):!1===t?(i=!0,void(u=!0)):e===w||i&&o<=0?(i=!0,n(null)):void c()}function l(t){u||(a=!1,i=!0,n(t))}c()}var T=t=>(e,r,n)=>{if(n=O(n),t<=0)throw new RangeError("concurrency limit cannot be less than 1");if(!e)return n(null);if("AsyncGenerator"===e[Symbol.toStringTag])return b(e,t,r,n);if(function(t){return"function"==typeof t[Symbol.asyncIterator]}(e))return b(e[Symbol.asyncIterator](),t,r,n);var i=S(e),u=!1,a=!1,o=0,s=!1;function c(t,e){if(!a)if(o-=1,t)u=!0,n(t);else if(!1===t)u=!0,a=!0;else{if(e===w||u&&o<=0)return u=!0,n(null);s||f()}}function f(){for(s=!0;o<t&&!u;){var e=i();if(null===e)return u=!0,void(o<=0&&n(null));o+=1,r(e.value,e.key,E(c))}s=!1}f()};var k=v((function(t,e,r,n){return T(e)(t,y(r),n)}),4);function A(t,e,r){r=O(r);var n=0,i=0,{length:u}=t,a=!1;function o(t,e){!1===t&&(a=!0),!0!==a&&(t?r(t):++i!==u&&e!==w||r(null))}for(0===u&&r(null);n<u;n++)e(t[n],n,E(o))}function L(t,e,r){return k(t,1/0,e,r)}var x=v((function(t,e,r){return(P(t)?A:L)(t,y(e),r)}),3);var B=v((function(t,e,r){return g(x,t,e,r)}),3),j=m(B);var _=v((function(t,e,r){return k(t,1,e,r)}),3);var M=v((function(t,e,r){return g(_,t,e,r)}),3),I=m(M);const C=Symbol("promiseCallback");function F(){let t,e;function r(r,...n){if(r)return e(r);t(n.length>1?n:n[0])}return r[C]=new Promise(((r,n)=>{t=r,e=n})),r}function q(t,e,r){"number"!=typeof e&&(r=e,e=null),r=O(r||F());var n=Object.keys(t).length;if(!n)return r(null);e||(e=n);var i={},u=0,a=!1,o=!1,s=Object.create(null),c=[],f=[],l={};function h(t,e){c.push((()=>function(t,e){if(o)return;var n=E(((e,...n)=>{if(u--,!1!==e)if(n.length<2&&([n]=n),e){var c={};if(Object.keys(i).forEach((t=>{c[t]=i[t]})),c[t]=n,o=!0,s=Object.create(null),a)return;r(e,c)}else i[t]=n,(s[t]||[]).forEach((t=>t())),p();else a=!0}));u++;var c=y(e[e.length-1]);e.length>1?c(i,n):c(n)}(t,e)))}function p(){if(!a){if(0===c.length&&0===u)return r(null,i);for(;c.length&&u<e;){c.shift()()}}}function d(e){var r=[];return Object.keys(t).forEach((n=>{const i=t[n];Array.isArray(i)&&i.indexOf(e)>=0&&r.push(n)})),r}return Object.keys(t).forEach((e=>{var r=t[e];if(!Array.isArray(r))return h(e,[r]),void f.push(e);var n=r.slice(0,r.length-1),i=n.length;if(0===i)return h(e,r),void f.push(e);l[e]=i,n.forEach((u=>{if(!t[u])throw new Error("async.auto task `"+e+"` has a non-existent dependency `"+u+"` in "+n.join(", "));!function(t,e){var r=s[t];r||(r=s[t]=[]);r.push(e)}(u,(()=>{0===--i&&h(e,r)}))}))})),function(){var t,e=0;for(;f.length;)t=f.pop(),e++,d(t).forEach((t=>{0==--l[t]&&f.push(t)}));if(e!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),p(),r[C]}var R=/^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/,N=/^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/,D=/,/,W=/(=.+)?(\s*)$/;function z(t,e){var r={};return Object.keys(t).forEach((e=>{var n,i=t[e],u=d(i),a=!u&&1===i.length||u&&0===i.length;if(Array.isArray(i))n=[...i],i=n.pop(),r[e]=n.concat(n.length>0?o:i);else if(a)r[e]=i;else{if(n=function(t){const e=function(t){let e="",r=0,n=t.indexOf("*/");for(;r<t.length;)if("/"===t[r]&&"/"===t[r+1]){let e=t.indexOf("\n",r);r=-1===e?t.length:e}else if(-1!==n&&"/"===t[r]&&"*"===t[r+1]){let i=t.indexOf("*/",r);-1!==i?(r=i+2,n=t.indexOf("*/",r)):(e+=t[r],r++)}else e+=t[r],r++;return e}(t.toString());let r=e.match(R);if(r||(r=e.match(N)),!r)throw new Error("could not parse args in autoInject\nSource:\n"+e);let[,n]=r;return n.replace(/\s/g,"").split(D).map((t=>t.replace(W,"").trim()))}(i),0===i.length&&!u&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");u||n.pop(),r[e]=n.concat(o)}function o(t,e){var r=n.map((e=>t[e]));r.push(e),y(i)(...r)}})),q(r,e)}class U{constructor(){this.head=this.tail=null,this.length=0}removeLink(t){return t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,t.prev=t.next=null,this.length-=1,t}empty(){for(;this.head;)this.shift();return this}insertAfter(t,e){e.prev=t,e.next=t.next,t.next?t.next.prev=e:this.tail=e,t.next=e,this.length+=1}insertBefore(t,e){e.prev=t.prev,e.next=t,t.prev?t.prev.next=e:this.head=e,t.prev=e,this.length+=1}unshift(t){this.head?this.insertBefore(this.head,t):V(this,t)}push(t){this.tail?this.insertAfter(this.tail,t):V(this,t)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){for(var t=this.head;t;)yield t.data,t=t.next}remove(t){for(var e=this.head;e;){var{next:r}=e;t(e)&&this.removeLink(e),e=r}return this}}function V(t,e){t.length=1,t.head=t.tail=e}function $(t,e,r){if(null==e)e=1;else if(0===e)throw new RangeError("Concurrency must not be zero");var n=y(t),i=0,u=[];const a={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};function o(t,e){return t?e?void(a[t]=a[t].filter((t=>t!==e))):a[t]=[]:Object.keys(a).forEach((t=>a[t]=[]))}function s(t,...e){a[t].forEach((t=>t(...e)))}var c=!1;function l(t,e,r,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");var i,u;function a(t,...e){return t?r?u(t):i():e.length<=1?i(e[0]):void i(e)}m.started=!0;var o=m._createTaskItem(t,r?a:n||a);if(e?m._tasks.unshift(o):m._tasks.push(o),c||(c=!0,f((()=>{c=!1,m.process()}))),r||!n)return new Promise(((t,e)=>{i=t,u=e}))}function h(t){return function(e,...r){i-=1;for(var n=0,a=t.length;n<a;n++){var o=t[n],c=u.indexOf(o);0===c?u.shift():c>0&&u.splice(c,1),o.callback(e,...r),null!=e&&s("error",e,o.data)}i<=m.concurrency-m.buffer&&s("unsaturated"),m.idle()&&s("drain"),m.process()}}function p(t){return!(0!==t.length||!m.idle())&&(f((()=>s("drain"))),!0)}const d=t=>e=>{if(!e)return new Promise(((e,r)=>{!function(t,e){const r=(...n)=>{o(t,r),e(...n)};a[t].push(r)}(t,((t,n)=>{if(t)return r(t);e(n)}))}));o(t),function(t,e){a[t].push(e)}(t,e)};var v=!1,m={_tasks:new U,_createTaskItem:(t,e)=>({data:t,callback:e}),*[Symbol.iterator](){yield*m._tasks[Symbol.iterator]()},concurrency:e,payload:r,buffer:e/4,started:!1,paused:!1,push(t,e){if(Array.isArray(t)){if(p(t))return;return t.map((t=>l(t,!1,!1,e)))}return l(t,!1,!1,e)},pushAsync(t,e){if(Array.isArray(t)){if(p(t))return;return t.map((t=>l(t,!1,!0,e)))}return l(t,!1,!0,e)},kill(){o(),m._tasks.empty()},unshift(t,e){if(Array.isArray(t)){if(p(t))return;return t.map((t=>l(t,!0,!1,e)))}return l(t,!0,!1,e)},unshiftAsync(t,e){if(Array.isArray(t)){if(p(t))return;return t.map((t=>l(t,!0,!0,e)))}return l(t,!0,!0,e)},remove(t){m._tasks.remove(t)},process(){if(!v){for(v=!0;!m.paused&&i<m.concurrency&&m._tasks.length;){var t=[],e=[],r=m._tasks.length;m.payload&&(r=Math.min(r,m.payload));for(var a=0;a<r;a++){var o=m._tasks.shift();t.push(o),u.push(o),e.push(o.data)}i+=1,0===m._tasks.length&&s("empty"),i===m.concurrency&&s("saturated");var c=E(h(t));n(e,c)}v=!1}},length:()=>m._tasks.length,running:()=>i,workersList:()=>u,idle:()=>m._tasks.length+i===0,pause(){m.paused=!0},resume(){!1!==m.paused&&(m.paused=!1,f(m.process))}};return Object.defineProperties(m,{saturated:{writable:!1,value:d("saturated")},unsaturated:{writable:!1,value:d("unsaturated")},empty:{writable:!1,value:d("empty")},drain:{writable:!1,value:d("drain")},error:{writable:!1,value:d("error")}}),m}function Q(t,e){return $(t,1,e)}function G(t,e,r){return $(t,e,r)}var H=v((function(t,e,r,n){n=O(n);var i=y(r);return _(t,((t,r,n)=>{i(e,t,((t,r)=>{e=r,n(t)}))}),(t=>n(t,e)))}),4);function J(...t){var e=t.map(y);return function(...t){var r=this,n=t[t.length-1];return"function"==typeof n?t.pop():n=F(),H(e,t,((t,e,n)=>{e.apply(r,t.concat(((t,...e)=>{n(t,e)})))}),((t,e)=>n(t,...e))),n[C]}}function K(...t){return J(...t.reverse())}var X=v((function(t,e,r,n){return g(T(e),t,r,n)}),4);var Y=v((function(t,e,r,n){var i=y(r);return X(t,e,((t,e)=>{i(t,((t,...r)=>t?e(t):e(t,r)))}),((t,e)=>{for(var r=[],i=0;i<e.length;i++)e[i]&&(r=r.concat(...e[i]));return n(t,r)}))}),4);var Z=v((function(t,e,r){return Y(t,1/0,e,r)}),3);var tt=v((function(t,e,r){return Y(t,1,e,r)}),3);function et(...t){return function(...e){return e.pop()(null,...t)}}function rt(t,e){return(r,n,i,u)=>{var a,o=!1;const s=y(i);r(n,((r,n,i)=>{s(r,((n,u)=>n||!1===n?i(n):t(u)&&!a?(o=!0,a=e(!0,r),i(null,w)):void i()))}),(t=>{if(t)return u(t);u(null,o?a:e(!1))}))}}var nt=v((function(t,e,r){return rt((t=>t),((t,e)=>e))(x,t,e,r)}),3);var it=v((function(t,e,r,n){return rt((t=>t),((t,e)=>e))(T(e),t,r,n)}),4);var ut=v((function(t,e,r){return rt((t=>t),((t,e)=>e))(T(1),t,e,r)}),3);function at(t){return(e,...r)=>y(e)(...r,((e,...r)=>{"object"==typeof console&&(e?console.error&&console.error(e):console[t]&&r.forEach((e=>console[t](e))))}))}var ot=at("dir");var st=v((function(t,e,r){r=E(r);var n,i=y(t),u=y(e);function a(t,...e){if(t)return r(t);!1!==t&&(n=e,u(...e,o))}function o(t,e){return t?r(t):!1!==t?e?void i(a):r(null,...n):void 0}return o(null,!0)}),3);function ct(t,e,r){const n=y(e);return st(t,((...t)=>{const e=t.pop();n(...t,((t,r)=>e(t,!r)))}),r)}function ft(t){return(e,r,n)=>t(e,n)}var lt=v((function(t,e,r){return x(t,ft(y(e)),r)}),3);var ht=v((function(t,e,r,n){return T(e)(t,ft(y(r)),n)}),4);var pt=v((function(t,e,r){return ht(t,1,e,r)}),3);function dt(t){return d(t)?t:function(...e){var r=e.pop(),n=!0;e.push(((...t)=>{n?f((()=>r(...t))):r(...t)})),t.apply(this,e),n=!1}}var yt=v((function(t,e,r){return rt((t=>!t),(t=>!t))(x,t,e,r)}),3);var vt=v((function(t,e,r,n){return rt((t=>!t),(t=>!t))(T(e),t,r,n)}),4);var mt=v((function(t,e,r){return rt((t=>!t),(t=>!t))(_,t,e,r)}),3);function gt(t,e,r,n){var i=new Array(e.length);t(e,((t,e,n)=>{r(t,((t,r)=>{i[e]=!!r,n(t)}))}),(t=>{if(t)return n(t);for(var r=[],u=0;u<e.length;u++)i[u]&&r.push(e[u]);n(null,r)}))}function Pt(t,e,r,n){var i=[];t(e,((t,e,n)=>{r(t,((r,u)=>{if(r)return n(r);u&&i.push({index:e,value:t}),n(r)}))}),(t=>{if(t)return n(t);n(null,i.sort(((t,e)=>t.index-e.index)).map((t=>t.value)))}))}function wt(t,e,r,n){return(P(e)?gt:Pt)(t,e,y(r),n)}var Ot=v((function(t,e,r){return wt(x,t,e,r)}),3);var St=v((function(t,e,r,n){return wt(T(e),t,r,n)}),4);var Et=v((function(t,e,r){return wt(_,t,e,r)}),3);var bt=v((function(t,e){var r=E(e),n=y(dt(t));return function t(e){if(e)return r(e);!1!==e&&n(t)}()}),2);var Tt=v((function(t,e,r,n){var i=y(r);return X(t,e,((t,e)=>{i(t,((r,n)=>r?e(r):e(r,{key:n,val:t})))}),((t,e)=>{for(var r={},{hasOwnProperty:i}=Object.prototype,u=0;u<e.length;u++)if(e[u]){var{key:a}=e[u],{val:o}=e[u];i.call(r,a)?r[a].push(o):r[a]=[o]}return n(t,r)}))}),4);function kt(t,e,r){return Tt(t,1/0,e,r)}function At(t,e,r){return Tt(t,1,e,r)}var Lt=at("log");var xt=v((function(t,e,r,n){n=O(n);var i={},u=y(r);return T(e)(t,((t,e,r)=>{u(t,e,((t,n)=>{if(t)return r(t);i[e]=n,r(t)}))}),(t=>n(t,i)))}),4);function Bt(t,e,r){return xt(t,1/0,e,r)}function jt(t,e,r){return xt(t,1,e,r)}function _t(t,e=(t=>t)){var r=Object.create(null),n=Object.create(null),u=y(t),a=i(((t,i)=>{var a=e(...t);a in r?f((()=>i(null,...r[a]))):a in n?n[a].push(i):(n[a]=[i],u(...t,((t,...e)=>{t||(r[a]=e);var i=n[a];delete n[a];for(var u=0,o=i.length;u<o;u++)i[u](t,...e)})))}));return a.memo=r,a.unmemoized=t,a}var Mt=c(o?t.nextTick:a?n:s),It=v(((t,e,r)=>{var n=P(e)?[]:{};t(e,((t,e,r)=>{y(t)(((t,...i)=>{i.length<2&&([i]=i),n[e]=i,r(t)}))}),(t=>r(t,n)))}),3);function Ct(t,e){return It(x,t,e)}function Ft(t,e,r){return It(T(e),t,r)}function qt(t,e){var r=y(t);return $(((t,e)=>{r(t[0],e)}),e,1)}class Rt{constructor(){this.heap=[],this.pushCount=Number.MIN_SAFE_INTEGER}get length(){return this.heap.length}empty(){return this.heap=[],this}percUp(t){let e;for(;t>0&&Dt(this.heap[t],this.heap[e=Nt(t)]);){let r=this.heap[t];this.heap[t]=this.heap[e],this.heap[e]=r,t=e}}percDown(t){let e;for(;(e=1+(t<<1))<this.heap.length&&(e+1<this.heap.length&&Dt(this.heap[e+1],this.heap[e])&&(e+=1),!Dt(this.heap[t],this.heap[e]));){let r=this.heap[t];this.heap[t]=this.heap[e],this.heap[e]=r,t=e}}push(t){t.pushCount=++this.pushCount,this.heap.push(t),this.percUp(this.heap.length-1)}unshift(t){return this.heap.push(t)}shift(){let[t]=this.heap;return this.heap[0]=this.heap[this.heap.length-1],this.heap.pop(),this.percDown(0),t}toArray(){return[...this]}*[Symbol.iterator](){for(let t=0;t<this.heap.length;t++)yield this.heap[t].data}remove(t){let e=0;for(let r=0;r<this.heap.length;r++)t(this.heap[r])||(this.heap[e]=this.heap[r],e++);this.heap.splice(e);for(let t=Nt(this.heap.length-1);t>=0;t--)this.percDown(t);return this}}function Nt(t){return(t+1>>1)-1}function Dt(t,e){return t.priority!==e.priority?t.priority<e.priority:t.pushCount<e.pushCount}function Wt(t,e){var r=qt(t,e),{push:n,pushAsync:i}=r;function u(t,e){return Array.isArray(t)?t.map((t=>({data:t,priority:e}))):{data:t,priority:e}}return r._tasks=new Rt,r._createTaskItem=({data:t,priority:e},r)=>({data:t,priority:e,callback:r}),r.push=function(t,e=0,r){return n(u(t,e),r)},r.pushAsync=function(t,e=0,r){return i(u(t,e),r)},delete r.unshift,delete r.unshiftAsync,r}var zt=v((function(t,e){if(e=O(e),!Array.isArray(t))return e(new TypeError("First argument to race must be an array of functions"));if(!t.length)return e();for(var r=0,n=t.length;r<n;r++)y(t[r])(e)}),2);function Ut(t,e,r,n){var i=[...t].reverse();return H(i,e,r,n)}function Vt(t){var e=y(t);return i((function(t,r){return t.push(((t,...e)=>{let n={};if(t&&(n.error=t),e.length>0){var i=e;e.length<=1&&([i]=e),n.value=i}r(null,n)})),e.apply(this,t)}))}function $t(t){var e;return Array.isArray(t)?e=t.map(Vt):(e={},Object.keys(t).forEach((r=>{e[r]=Vt.call(this,t[r])}))),e}function Qt(t,e,r,n){const i=y(r);return wt(t,e,((t,e)=>{i(t,((t,r)=>{e(t,!r)}))}),n)}var Gt=v((function(t,e,r){return Qt(x,t,e,r)}),3);var Ht=v((function(t,e,r,n){return Qt(T(e),t,r,n)}),4);var Jt=v((function(t,e,r){return Qt(_,t,e,r)}),3);function Kt(t){return function(){return t}}function Xt(t,e,r){var n={times:5,intervalFunc:Kt(0)};if(arguments.length<3&&"function"==typeof t?(r=e||F(),e=t):(Yt(n,t),r=r||F()),"function"!=typeof e)throw new Error("Invalid arguments for async.retry");var i=y(e),u=1;function a(){i(((t,...e)=>{!1!==t&&(t&&u++<n.times&&("function"!=typeof n.errorFilter||n.errorFilter(t))?setTimeout(a,n.intervalFunc(u-1)):r(t,...e))}))}return a(),r[C]}function Yt(t,e){if("object"==typeof e)t.times=+e.times||5,t.intervalFunc="function"==typeof e.interval?e.interval:Kt(+e.interval||0),t.errorFilter=e.errorFilter;else{if("number"!=typeof e&&"string"!=typeof e)throw new Error("Invalid arguments for async.retry");t.times=+e||5}}function Zt(t,e){e||(e=t,t=null);let r=t&&t.arity||e.length;d(e)&&(r+=1);var n=y(e);return i(((e,i)=>{function u(t){n(...e,t)}return(e.length<r-1||null==i)&&(e.push(i),i=F()),t?Xt(t,u,i):Xt(u,i),i[C]}))}function te(t,e){return It(_,t,e)}var ee=v((function(t,e,r){return rt(Boolean,(t=>t))(x,t,e,r)}),3);var re=v((function(t,e,r,n){return rt(Boolean,(t=>t))(T(e),t,r,n)}),4);var ne=v((function(t,e,r){return rt(Boolean,(t=>t))(_,t,e,r)}),3);var ie=v((function(t,e,r){var n=y(e);return B(t,((t,e)=>{n(t,((r,n)=>{if(r)return e(r);e(r,{value:t,criteria:n})}))}),((t,e)=>{if(t)return r(t);r(null,e.sort(i).map((t=>t.value)))}));function i(t,e){var r=t.criteria,n=e.criteria;return r<n?-1:r>n?1:0}}),3);function ue(t,e,r){var n=y(t);return i(((i,u)=>{var a,o=!1;i.push(((...t)=>{o||(u(...t),clearTimeout(a))})),a=setTimeout((function(){var e=t.name||"anonymous",n=new Error('Callback function "'+e+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),o=!0,u(n)}),e),n(...i)}))}function ae(t,e,r,n){var i=y(r);return X(function(t){for(var e=Array(t);t--;)e[t]=t;return e}(t),e,i,n)}function oe(t,e,r){return ae(t,1/0,e,r)}function se(t,e,r){return ae(t,1,e,r)}function ce(t,e,r,n){arguments.length<=3&&"function"==typeof e&&(n=r,r=e,e=Array.isArray(t)?[]:{}),n=O(n||F());var i=y(r);return x(t,((t,r,n)=>{i(e,t,r,n)}),(t=>n(t,e))),n[C]}var fe=v((function(t,e){var r,n=null;return pt(t,((t,e)=>{y(t)(((t,...i)=>{if(!1===t)return e(t);i.length<2?[r]=i:r=i,n=t,e(t?null:{})}))}),(()=>e(n,r)))}));function le(t){return(...e)=>(t.unmemoized||t)(...e)}var he=v((function(t,e,r){r=E(r);var n=y(e),i=y(t),u=[];function a(t,...e){if(t)return r(t);u=e,!1!==t&&i(o)}function o(t,e){return t?r(t):!1!==t?e?void n(a):r(null,...u):void 0}return i(o)}),3);function pe(t,e,r){const n=y(t);return he((t=>n(((e,r)=>t(e,!r)))),e,r)}var de=v((function(t,e){if(e=O(e),!Array.isArray(t))return e(new Error("First argument to waterfall must be an array of functions"));if(!t.length)return e();var r=0;function n(e){y(t[r++])(...e,E(i))}function i(i,...u){if(!1!==i)return i||r===t.length?e(i,...u):void n(u)}n([])})),ye={apply:r,applyEach:j,applyEachSeries:I,asyncify:l,auto:q,autoInject:z,cargo:Q,cargoQueue:G,compose:K,concat:Z,concatLimit:Y,concatSeries:tt,constant:et,detect:nt,detectLimit:it,detectSeries:ut,dir:ot,doUntil:ct,doWhilst:st,each:lt,eachLimit:ht,eachOf:x,eachOfLimit:k,eachOfSeries:_,eachSeries:pt,ensureAsync:dt,every:yt,everyLimit:vt,everySeries:mt,filter:Ot,filterLimit:St,filterSeries:Et,forever:bt,groupBy:kt,groupByLimit:Tt,groupBySeries:At,log:Lt,map:B,mapLimit:X,mapSeries:M,mapValues:Bt,mapValuesLimit:xt,mapValuesSeries:jt,memoize:_t,nextTick:Mt,parallel:Ct,parallelLimit:Ft,priorityQueue:Wt,queue:qt,race:zt,reduce:H,reduceRight:Ut,reflect:Vt,reflectAll:$t,reject:Gt,rejectLimit:Ht,rejectSeries:Jt,retry:Xt,retryable:Zt,seq:J,series:te,setImmediate:f,some:ee,someLimit:re,someSeries:ne,sortBy:ie,timeout:ue,times:oe,timesLimit:ae,timesSeries:se,transform:ce,tryEach:fe,unmemoize:le,until:pe,waterfall:de,whilst:he,all:yt,allLimit:vt,allSeries:mt,any:ee,anyLimit:re,anySeries:ne,find:nt,findLimit:it,findSeries:ut,flatMap:Z,flatMapLimit:Y,flatMapSeries:tt,forEach:lt,forEachSeries:pt,forEachLimit:ht,forEachOf:x,forEachOfSeries:_,forEachOfLimit:k,inject:H,foldl:H,foldr:Ut,select:Ot,selectLimit:St,selectSeries:Et,wrapSync:l,during:he,doDuring:st};e.default=ye,e.apply=r,e.applyEach=j,e.applyEachSeries=I,e.asyncify=l,e.auto=q,e.autoInject=z,e.cargo=Q,e.cargoQueue=G,e.compose=K,e.concat=Z,e.concatLimit=Y,e.concatSeries=tt,e.constant=et,e.detect=nt,e.detectLimit=it,e.detectSeries=ut,e.dir=ot,e.doUntil=ct,e.doWhilst=st,e.each=lt,e.eachLimit=ht,e.eachOf=x,e.eachOfLimit=k,e.eachOfSeries=_,e.eachSeries=pt,e.ensureAsync=dt,e.every=yt,e.everyLimit=vt,e.everySeries=mt,e.filter=Ot,e.filterLimit=St,e.filterSeries=Et,e.forever=bt,e.groupBy=kt,e.groupByLimit=Tt,e.groupBySeries=At,e.log=Lt,e.map=B,e.mapLimit=X,e.mapSeries=M,e.mapValues=Bt,e.mapValuesLimit=xt,e.mapValuesSeries=jt,e.memoize=_t,e.nextTick=Mt,e.parallel=Ct,e.parallelLimit=Ft,e.priorityQueue=Wt,e.queue=qt,e.race=zt,e.reduce=H,e.reduceRight=Ut,e.reflect=Vt,e.reflectAll=$t,e.reject=Gt,e.rejectLimit=Ht,e.rejectSeries=Jt,e.retry=Xt,e.retryable=Zt,e.seq=J,e.series=te,e.setImmediate=f,e.some=ee,e.someLimit=re,e.someSeries=ne,e.sortBy=ie,e.timeout=ue,e.times=oe,e.timesLimit=ae,e.timesSeries=se,e.transform=ce,e.tryEach=fe,e.unmemoize=le,e.until=pe,e.waterfall=de,e.whilst=he,e.all=yt,e.allLimit=vt,e.allSeries=mt,e.any=ee,e.anyLimit=re,e.anySeries=ne,e.find=nt,e.findLimit=it,e.findSeries=ut,e.flatMap=Z,e.flatMapLimit=Y,e.flatMapSeries=tt,e.forEach=lt,e.forEachSeries=pt,e.forEachLimit=ht,e.forEachOf=x,e.forEachOfSeries=_,e.forEachOfLimit=k,e.inject=H,e.foldl=H,e.foldr=Ut,e.select=Ot,e.selectLimit=St,e.selectSeries=Et,e.wrapSync=l,e.during=he,e.doDuring=st,Object.defineProperty(e,"__esModule",{value:!0})}))}).call(this)}).call(this,t("_process"),t("timers").setImmediate)},{_process:2,timers:3}],2:[function(t,e,r){var n,i,u=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===a||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:a}catch(t){n=a}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(t){i=o}}();var c,f=[],l=!1,h=-1;function p(){l&&c&&(l=!1,c.length?f=c.concat(f):h=-1,f.length&&d())}function d(){if(!l){var t=s(p);l=!0;for(var e=f.length;e;){for(c=f,f=[];++h<e;)c&&c[h].run();h=-1,e=f.length}c=null,l=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function v(){}u.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];f.push(new y(t,e)),1!==f.length||l||s(d)},y.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=v,u.addListener=v,u.once=v,u.off=v,u.removeListener=v,u.removeAllListeners=v,u.emit=v,u.prependListener=v,u.prependOnceListener=v,u.listeners=function(t){return[]},u.binding=function(t){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(t){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},{}],3:[function(t,e,r){(function(e,n){(function(){var i=t("process/browser.js").nextTick,u=Function.prototype.apply,a=Array.prototype.slice,o={},s=0;function c(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new c(u.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new c(u.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},c.prototype.unref=c.prototype.ref=function(){},c.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},r.setImmediate="function"==typeof e?e:function(t){var e=s++,n=!(arguments.length<2)&&a.call(arguments,1);return o[e]=!0,i((function(){o[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))})),e},r.clearImmediate="function"==typeof n?n:function(t){delete o[t]}}).call(this)}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":2,timers:3}],4:[function(t,e,r){var n=t("./Precedent.js");"object"!=typeof window||window.hasOwnProperty("Precedent")||(window.Precedent=n),e.exports=n},{"./Precedent.js":5}],5:[function(t,e,r){
|
|
2
2
|
/**
|
|
3
3
|
* Precedent Meta-Templating
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @description Process text streams, parsing out meta-template expressions.
|
|
10
10
|
*/
|
|
11
|
-
var n=t("./WordTree.js"),
|
|
11
|
+
var n=t("./WordTree.js"),i=t("./StringParser.js");e.exports=class{constructor(){this.WordTree=new n,this.StringParser=new i,this.ParseTree=this.WordTree.ParseTree}addPattern(t,e,r){return this.WordTree.addPattern(t,e,r)}addPatternAsync(t,e,r){return this.WordTree.addPatternAsync(t,e,r)}parseString(t,e,r){return this.StringParser.parseString(t,this.ParseTree,e,r)}}},{"./StringParser.js":6,"./WordTree.js":7}],6:[function(t,e,r){
|
|
12
12
|
/**
|
|
13
13
|
* String Parser
|
|
14
14
|
*
|
|
@@ -18,7 +18,7 @@ var n=t("./WordTree.js"),a=t("./StringParser.js");e.exports=class{constructor(){
|
|
|
18
18
|
*
|
|
19
19
|
* @description Parse a string, properly processing each matched token in the word tree.
|
|
20
20
|
*/
|
|
21
|
-
class{constructor(){}newParserState(t){return{ParseTree:t,Output:"",OutputBuffer:"",Pattern:!1,PatternMatch:!1,PatternMatchOutputBuffer:""}}assignNode(t,e){e.PatternMatch=t,e.PatternMatch.hasOwnProperty("PatternEnd")&&(e.Pattern=e.PatternMatch)}appendOutputBuffer(t,e){e.OutputBuffer+=t}flushOutputBuffer(t){t.Output+=t.OutputBuffer,t.OutputBuffer=""}checkPatternEnd(t,e){t.OutputBuffer.length>=t.Pattern.PatternEnd.length+t.Pattern.PatternStart.length&&t.OutputBuffer.substr(-t.Pattern.PatternEnd.length)===t.Pattern.PatternEnd&&(t.OutputBuffer=t.Pattern.Parse(t.OutputBuffer.substr(t.Pattern.PatternStart.length,t.OutputBuffer.length-(t.Pattern.PatternStart.length+t.Pattern.PatternEnd.length)),e),this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1)}parseCharacter(t,e,r){!e.PatternMatch&&e.ParseTree.hasOwnProperty(t)?(this.assignNode(e.ParseTree[t],e),this.appendOutputBuffer(t,e)):e.PatternMatch?(e.PatternMatch.hasOwnProperty(t)&&this.assignNode(e.PatternMatch[t],e),this.appendOutputBuffer(t,e),e.Pattern&&this.checkPatternEnd(e,r)):e.Output+=t}parseString(t,e,r){let n=this.newParserState(e);for(var
|
|
21
|
+
let n=t("async");e.exports=class{constructor(){}newParserState(t){return{ParseTree:t,Asynchronous:!1,Output:"",OutputBuffer:"",Pattern:!1,PatternMatch:!1,PatternMatchOutputBuffer:""}}assignNode(t,e){e.PatternMatch=t,e.PatternMatch.hasOwnProperty("PatternEnd")&&(e.Pattern=e.PatternMatch)}appendOutputBuffer(t,e){e.OutputBuffer+=t}flushOutputBuffer(t){t.Output+=t.OutputBuffer,t.OutputBuffer=""}checkPatternEnd(t,e){t.OutputBuffer.length>=t.Pattern.PatternEnd.length+t.Pattern.PatternStart.length&&t.OutputBuffer.substr(-t.Pattern.PatternEnd.length)===t.Pattern.PatternEnd&&(t.Pattern.isAsync?(console.log(`Precedent ERROR: Async template detected for pattern ${t.Pattern.PatternStart} ... ${t.Pattern.PatternEnd} but the template engine is being run in non-async mode.`),this.OutputBuffer="",this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1):(t.OutputBuffer=t.Pattern.Parse(t.OutputBuffer.substr(t.Pattern.PatternStart.length,t.OutputBuffer.length-(t.Pattern.PatternStart.length+t.Pattern.PatternEnd.length)),e),this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1))}checkPatternEndAsync(t,e,r){if(t.OutputBuffer.length>=t.Pattern.PatternEnd.length+t.Pattern.PatternStart.length&&t.OutputBuffer.substr(-t.Pattern.PatternEnd.length)===t.Pattern.PatternEnd){if(t.Pattern.isAsync)return t.Pattern.Parse(t.OutputBuffer.substr(t.Pattern.PatternStart.length,t.OutputBuffer.length-(t.Pattern.PatternStart.length+t.Pattern.PatternEnd.length)),e,((e,n)=>(e&&console.log(`Precedent ERROR: Async template error happened parsing ${t.Pattern.PatternStart} ... ${t.Pattern.PatternEnd}: ${e}`),t.OutputBuffer=n,this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1,r())));t.OutputBuffer=t.Pattern.Parse(t.OutputBuffer.substr(t.Pattern.PatternStart.length,t.OutputBuffer.length-(t.Pattern.PatternStart.length+t.Pattern.PatternEnd.length)),e),this.flushOutputBuffer(t),t.Pattern=!1,t.PatternMatch=!1}return r()}parseCharacter(t,e,r){!e.PatternMatch&&e.ParseTree.hasOwnProperty(t)?(this.assignNode(e.ParseTree[t],e),this.appendOutputBuffer(t,e)):e.PatternMatch?(e.PatternMatch.hasOwnProperty(t)&&this.assignNode(e.PatternMatch[t],e),this.appendOutputBuffer(t,e),e.Pattern&&this.checkPatternEnd(e,r)):e.Output+=t}parseCharacterAsync(t,e,r,n){if(!e.PatternMatch&&e.ParseTree.hasOwnProperty(t))this.assignNode(e.ParseTree[t],e),this.appendOutputBuffer(t,e);else if(e.PatternMatch){if(e.PatternMatch.hasOwnProperty(t)&&this.assignNode(e.PatternMatch[t],e),this.appendOutputBuffer(t,e),e.Pattern)return this.checkPatternEndAsync(e,r,n)}else e.Output+=t;return n(null)}parseString(t,e,r,i){if("function"!=typeof i){let n=this.newParserState(e);for(var u=0;u<t.length;u++)this.parseCharacter(t[u],n,r,i);return this.flushOutputBuffer(n),n.Output}{let u=this.newParserState(e);n.eachSeries(t,((t,e)=>{this.parseCharacterAsync(t,u,r,e)}),(t=>{this.flushOutputBuffer(u),i(t,u.Output)}))}}}},{async:1}],7:[function(t,e,r){e.exports=
|
|
22
22
|
/**
|
|
23
23
|
* Word Tree
|
|
24
24
|
*
|
|
@@ -28,5 +28,5 @@ class{constructor(){}newParserState(t){return{ParseTree:t,Output:"",OutputBuffer
|
|
|
28
28
|
*
|
|
29
29
|
* @description Create a tree (directed graph) of Javascript objects, one character per object.
|
|
30
30
|
*/
|
|
31
|
-
class{constructor(){this.ParseTree={}}addChild(t,e,r){return t.hasOwnProperty(e[r])||(t[e[r]]={}),t[e[r]]}addPattern(t,e,r){if(t.length<1)return!1;if("string"==typeof e&&e.length<1)return!1;let n=this.ParseTree;for(var
|
|
31
|
+
class{constructor(){this.ParseTree={}}addChild(t,e,r){return t.hasOwnProperty(e[r])||(t[e[r]]={}),t[e[r]]}addPattern(t,e,r){if(t.length<1)return!1;if("string"==typeof e&&e.length<1)return!1;let n=this.ParseTree;for(var i=0;i<t.length;i++)n=this.addChild(n,t,i);return n.PatternStart=t,n.PatternEnd="string"==typeof e&&e.length>0?e:t,n.Parse="function"==typeof r?r:"string"==typeof r?()=>r:t=>t,n.isPromise=!1,!0}addPatternAsync(t,e,r){if(t.length<1)return!1;if("string"==typeof e&&e.length<1)return!1;let n=this.ParseTree;for(var i=0;i<t.length;i++)n=this.addChild(n,t,i);return n.PatternStart=t,n.PatternEnd="string"==typeof e&&e.length>0?e:t,n.Parse="function"==typeof r?r:"string"==typeof r?(t,e,r)=>{r(pParserPromise)}:(t,e,r)=>r(t),n.isAsync=!0,!0}}},{}]},{},[4])(4)}));
|
|
32
32
|
//# sourceMappingURL=precedent.compatible.min.js.map
|