Socket
Socket
Sign inDemoInstall

efrt

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

efrt - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

builds/efrt-unpack.min.js

8

builds/efrt.min.js

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

/* efrt v2.1.0
github.com/nlp-compromise/efrt
MIT
*/
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="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})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}),function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="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})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}),function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="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})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)}),function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).efrt=t()}(function(){return function t(n,e,o){function r(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=e[s]={exports:{}};n[s][0].call(h.exports,function(t){return r(n[s][1][t]||t)},h,h.exports,t,n,e,o)}return e[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(t,n,e){"use strict";var o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=o.split("").reduce(function(t,n,e){return t[n]=e,t},{});n.exports={toAlphaCode:function(t){if(void 0!==o[t])return o[t];for(var n=1,e=36,r="";t>=e;t-=e,n++,e*=36);for(;n--;){var i=t%36;r=String.fromCharCode((i<10?48:55)+i)+r,t=(t-i)/36}return r},fromAlphaCode:function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,o=36,i=1;e<t.length;n+=o,e++,o*=36);for(var s=t.length-1;s>=0;s--,i*=36){var u=t.charCodeAt(s)-48;u>10&&(u-=7),n+=u*i}return n}}},{}],2:[function(t,n,e){(function(e){"use strict";var o={pack:t("./pack/index"),unpack:t("./unpack/index")};"undefined"!=typeof self?self.efrt=o:"undefined"!=typeof window?window.efrt=o:void 0!==e&&(e.efrt=o),void 0!==n&&(n.exports=o)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./pack/index":5,"./unpack/index":9}],3:[function(t,n,e){"use strict";n.exports={commonPrefix:function(t,n){for(var e=Math.min(t.length,n.length);e>0;){var o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique:function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)}}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},r={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){for(var n=[],e=Object.keys(this.counts),o=0;o<e.length;o++){var r=e[o];n.push([r,this.counts[r]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(r).forEach(function(t){o.prototype[t]=r[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),r=function(t){return"[object Array]"===Object.prototype.toString.call(t)};n.exports=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;var e=Object.keys(t).reduce(function(n,e){var o=t[e];if(r(o)){for(var i=0;i<o.length;i++)n[o[i]]=n[o[i]]||[],n[o[i]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){var n=new o(e[t]);e[t]=n.pack()}),Object.keys(e).map(function(t){return t+"¦"+e[t]}).join("|")}},{"./trie":8}],6:[function(t,n,e){"use strict";function o(t){return(o="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})(t)}var r=t("./fns"),i=t("./pack"),s=new RegExp("[0-9A-Z,;!:|¦]");n.exports={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(var n=0;n<t.length;n++)t[n]=t[n].toLowerCase();r.unique(t);for(var e=0;e<t.length;e++)null===t[e].match(s)&&this.insert(t[e])}},insert:function(t){this._insert(t,this.root);var n=this.lastWord;if(this.lastWord=t,r.commonPrefix(t,n)!==n){var e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)}},_insert:function(t,n){var e,i;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(0!==(e=r.commonPrefix(t,f)).length){if(f===e&&"object"===o(n[f]))return void this._insert(t.slice(e.length),n[f]);if(f===t&&"number"==typeof n[f])return;return(i={})[f.slice(e.length)]=n[f],this.addTerminal(i,t=t.slice(e.length)),delete n[f],n[e]=i,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)t[n]=1;else{var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))}},nodeProps:function(t,n){var e=[];for(var r in t)""!==r&&"_"!==r[0]&&(n&&"object"!==o(t[r])||e.push(r));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;var n=[];this.isTerminal(t)&&n.push("!");for(var e=this.nodeProps(t),r=0;r<e.length;r++){var i=e[r];"object"===o(t[i])?(t[i]=this.combineSuffixNode(t[i]),n.push(i),n.push(t[i]._c)):n.push(i)}return n=n.join("-"),this.suffixes[n]||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,!this.visited(t))for(var n=this.nodeProps(t,!0),e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){var n,e,r,i;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)"object"===o(r=t[n=e[i]])&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],t[n+=r._g]=r[r._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){for(var o=this.nodeProps(e,!0),r=0;r<o.length;r++){var i=o[r];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return i(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),r=t("../encoding"),i=function(t,n){var e="",o="";t.isTerminal(n)&&(e+="!");for(var i=t.nodeProps(n),s=0;s<i.length;s++){var u=i[s];if("number"!=typeof n[u])if(t.syms[n[u]._n])e+=o+u+t.syms[n[u]._n],o="";else{var f=r.toAlphaCode(n._n-n[u]._n-1+t.symCount);n[u]._g&&f.length>=n[u]._g.length&&1===n[n[u]._g]?(e+=o+u+(f=n[u]._g),o=","):(e+=o+u+f,o="")}else e+=o+u,o=","}return e};n.exports=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new o,t.histRel=new o,function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),r=0;r<o.length;r++)t(n,e[o[r]]);e._n=n.pos++,n.nodes.unshift(e)}}(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++){var s=o[i],u=e._n-e[s]._n-1;u<36&&n.histRel.add(u),n.histAbs.add(e[s]._n,r.toAlphaCode(u).length-1),t(n,e[s])}}(t,t.root),t.symCount=function(t){t.histAbs=t.histAbs.highest(36);var n=[];n[-1]=0;for(var e=0,o=0,i=3+r.toAlphaCode(t.nodeCount).length,s=0;s<36&&void 0!==t.histAbs[s];s++)n[s]=t.histAbs[s][1]-i-t.histRel.countOf(36-s-1)+n[s-1],n[s]>=e&&(e=n[s],o=s+1);return o}(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=r.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=i(t,t.nodes[e]);for(var s=t.symCount-1;s>=0;s--)t.nodes.unshift(r.toAlphaCode(s)+":"+r.toAlphaCode(t.nodeCount-t.histAbs[s][0]-1));return t.nodes.join(";")}},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),r=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(o).forEach(function(t){r.prototype[t]=o[t]}),n.exports=r},{"./methods":6}],9:[function(t,n,e){"use strict";var o=t("./unpack");n.exports=function(t){var n=t.split("|").reduce(function(t,n){var e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){var r=o(n[t]);"true"===t&&(t=!0);for(var i=0;i<r.length;i++){var s=r[i];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e}},{"./unpack":11}],10:[function(t,n,e){"use strict";var o=t("../encoding");n.exports=function(t){for(var n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)"),e=0;e<t.nodes.length;e++){var r=n.exec(t.nodes[e]);if(!r){t.symCount=e;break}t.syms[o.fromAlphaCode(r[1])]=o.fromAlphaCode(r[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),r=t("../encoding"),i=function(t,n,e){var o=r.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount};n.exports=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),function(t){var n=[];return function e(o,r){var s=t.nodes[o];"!"===s[0]&&(n.push(r),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],h=u[f+1];if(c){var a=r+c;","!==h&&void 0!==h?e(i(t,h,o),a):n.push(a)}}}(0,""),n}(n)}},{"../encoding":1,"./symbols":10}]},{},[2])(2)});
"use strict";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,n){return t(n={exports:{}},n.exports),n.exports}const commonPrefix=function(t,n){let e=Math.min(t.length,n.length);for(;e>0;){const o=t.slice(0,e);if(o===n.slice(0,e))return o;e-=1}return""},unique=function(t){t.sort();for(let n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)};var fns={commonPrefix:commonPrefix,unique:unique};const Histogram=function(){this.counts={}},methods={init:function(t){void 0===this.counts[t]&&(this.counts[t]=0)},add:function(t,n){void 0===n&&(n=1),this.init(t),this.counts[t]+=n},countOf:function(t){return this.init(t),this.counts[t]},highest:function(t){let n=[];const e=Object.keys(this.counts);for(let t=0;t<e.length;t++){const o=e[t];n.push([o,this.counts[o]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(methods).forEach(function(t){Histogram.prototype[t]=methods[t]});var histogram=Histogram;const BASE=36,seq="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",cache=seq.split("").reduce(function(t,n,e){return t[n]=e,t},{}),toAlphaCode=function(t){if(void 0!==seq[t])return seq[t];let n=1,e=36,o="";for(;t>=e;t-=e,n++,e*=36);for(;n--;){const n=t%36;o=String.fromCharCode((n<10?48:55)+n)+o,t=(t-n)/36}return o},fromAlphaCode=function(t){if(void 0!==cache[t])return cache[t];let n=0,e=1,o=36,s=1;for(;e<t.length;n+=o,e++,o*=36);for(let e=t.length-1;e>=0;e--,s*=36){let o=t.charCodeAt(e)-48;o>10&&(o-=7),n+=o*s}return n};var encoding={toAlphaCode:toAlphaCode,fromAlphaCode:fromAlphaCode};const config={NODE_SEP:";",KEY_VAL:":",STRING_SEP:",",TERMINAL_PREFIX:"!",BASE:36},nodeLine=function(t,n){let e="",o="";t.isTerminal(n)&&(e+=config.TERMINAL_PREFIX);const s=t.nodeProps(n);for(let i=0;i<s.length;i++){const r=s[i];if("number"==typeof n[r]){e+=o+r,o=config.STRING_SEP;continue}if(t.syms[n[r]._n]){e+=o+r+t.syms[n[r]._n],o="";continue}let c=encoding.toAlphaCode(n._n-n[r]._n-1+t.symCount);n[r]._g&&c.length>=n[r]._g.length&&1===n[n[r]._g]?(e+=o+r+(c=n[r]._g),o=config.STRING_SEP):(e+=o+r+c,o="")}return e},analyzeRefs=function(t,n){if(t.visited(n))return;const e=t.nodeProps(n,!0);for(let o=0;o<e.length;o++){const s=e[o],i=n._n-n[s]._n-1;i<config.BASE&&t.histRel.add(i),t.histAbs.add(n[s]._n,encoding.toAlphaCode(i).length-1),analyzeRefs(t,n[s])}},symbolCount=function(t){t.histAbs=t.histAbs.highest(config.BASE);const n=[];n[-1]=0;let e=0,o=0;const s=3+encoding.toAlphaCode(t.nodeCount).length;for(let i=0;i<config.BASE&&void 0!==t.histAbs[i];i++)n[i]=t.histAbs[i][1]-s-t.histRel.countOf(config.BASE-i-1)+n[i-1],n[i]>=e&&(e=n[i],o=i+1);return o},numberNodes=function(t,n){if(void 0!==n._n)return;const e=t.nodeProps(n,!0);for(let o=0;o<e.length;o++)numberNodes(t,n[e[o]]);n._n=t.pos++,t.nodes.unshift(n)},pack=function(t){t.nodes=[],t.nodeCount=0,t.syms={},t.symCount=0,t.pos=0,t.optimize(),t.histAbs=new histogram,t.histRel=new histogram,numberNodes(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),analyzeRefs(t,t.root),t.symCount=symbolCount(t);for(let n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=encoding.toAlphaCode(n);for(let n=0;n<t.nodeCount;n++)t.nodes[n]=nodeLine(t,t.nodes[n]);for(let n=t.symCount-1;n>=0;n--)t.nodes.unshift(encoding.toAlphaCode(n)+config.KEY_VAL+encoding.toAlphaCode(t.nodeCount-t.histAbs[n][0]-1));return t.nodes.join(config.NODE_SEP)};var pack_1=pack;const NOT_ALLOWED=new RegExp("[0-9A-Z,;!:|¦]");var methods$1={insertWords:function(t){if(void 0!==t){"string"==typeof t&&(t=t.split(/[^a-zA-Z]+/));for(let n=0;n<t.length;n++)t[n]=t[n].toLowerCase();fns.unique(t);for(let n=0;n<t.length;n++)null===t[n].match(NOT_ALLOWED)&&this.insert(t[n])}},insert:function(t){this._insert(t,this.root);const n=this.lastWord;if(this.lastWord=t,fns.commonPrefix(t,n)===n)return;const e=this.uniqueNode(n,t,this.root);e&&this.combineSuffixNode(e)},_insert:function(t,n){let e,o;if(0===t.length)return;const s=Object.keys(n);for(let i=0;i<s.length;i++){const r=s[i];if(0!==(e=fns.commonPrefix(t,r)).length){if(r===e&&"object"==typeof n[r])return void this._insert(t.slice(e.length),n[r]);if(r===t&&"number"==typeof n[r])return;return(o={})[r.slice(e.length)]=n[r],this.addTerminal(o,t=t.slice(e.length)),delete n[r],n[e]=o,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++},addTerminal:function(t,n){if(n.length<=1)return void(t[n]=1);const e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))},nodeProps:function(t,n){const e=[];for(const o in t)""!==o&&"_"!==o[0]&&(n&&"object"!=typeof t[o]||e.push(o));return e.sort(),e},optimize:function(){this.combineSuffixNode(this.root),this.prepDFS(),this.countDegree(this.root),this.prepDFS(),this.collapseChains(this.root)},combineSuffixNode:function(t){if(t._c)return t;let n=[];this.isTerminal(t)&&n.push("!");const e=this.nodeProps(t);for(let o=0;o<e.length;o++){const s=e[o];"object"==typeof t[s]?(t[s]=this.combineSuffixNode(t[s]),n.push(s),n.push(t[s]._c)):n.push(s)}n=n.join("-");const o=this.suffixes[n];return o||(this.suffixes[n]=t,t._c=this.cNext++,t)},prepDFS:function(){this.vCur++},visited:function(t){return t._v===this.vCur||(t._v=this.vCur,!1)},countDegree:function(t){if(void 0===t._d&&(t._d=0),t._d++,this.visited(t))return;const n=this.nodeProps(t,!0);for(let e=0;e<n.length;e++)this.countDegree(t[n[e]])},collapseChains:function(t){let n,e,o,s;if(!this.visited(t)){for(e=this.nodeProps(t),s=0;s<e.length;s++)"object"==typeof(o=t[n=e[s]])&&(this.collapseChains(o),void 0===o._g||1!==o._d&&1!==o._g.length||(delete t[n],t[n+=o._g]=o[o._g]));1!==e.length||this.isTerminal(t)||(t._g=n)}},isTerminal:function(t){return!!t[""]},uniqueNode:function(t,n,e){const o=this.nodeProps(e,!0);for(let s=0;s<o.length;s++){const i=o[s];if(i===t.slice(0,i.length))return i!==n.slice(0,i.length)?e[i]:this.uniqueNode(t.slice(i.length),n.slice(i.length),e[i])}},pack:function(){return pack_1(this)}};const Trie=function(t){this.root={},this.lastWord="",this.suffixes={},this.suffixCounts={},this.cNext=1,this.wordCount=0,this.insertWords(t),this.vCur=0};Object.keys(methods$1).forEach(function(t){Trie.prototype[t]=methods$1[t]});var trie=Trie;const isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},handleFormats=function(t){return null==t?{}:"string"==typeof t?t.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):isArray(t)?t.reduce(function(t,n){return t[n]=!0,t},{}):t},pack$1=function(t){var n;t=null==(n=t)?{}:"string"==typeof n?n.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):isArray(n)?n.reduce(function(t,n){return t[n]=!0,t},{}):n;const e=Object.keys(t).reduce(function(n,e){const o=t[e];if(isArray(o)){for(let t=0;t<o.length;t++)n[o[t]]=n[o[t]]||[],n[o[t]].push(e);return n}return!1===n.hasOwnProperty(o)&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(e).forEach(function(t){const n=new trie(e[t]);e[t]=n.pack()}),Object.keys(e).map(t=>t+"¦"+e[t]).join("|")};var pack_1$1=pack$1,symbols=function(t){const n=new RegExp("([0-9A-Z]+):([0-9A-Z]+)");for(let e=0;e<t.nodes.length;e++){const o=n.exec(t.nodes[e]);if(!o){t.symCount=e;break}t.syms[encoding.fromAlphaCode(o[1])]=encoding.fromAlphaCode(o[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)};const indexFromRef=function(t,n,e){const o=encoding.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount},toArray=function(t){const n=[],e=(o,s)=>{let i=t.nodes[o];"!"===i[0]&&(n.push(s),i=i.slice(1));const r=i.split(/([A-Z0-9,]+)/g);for(let i=0;i<r.length;i+=2){const c=r[i],u=r[i+1];if(!c)continue;const f=s+c;if(","===u||void 0===u){n.push(f);continue}const l=indexFromRef(t,u,o);e(l,f)}};return e(0,""),n},unpack=function(t){const n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&symbols(n),toArray(n)};var unpack_1=unpack,unpack_1$1=function(t){const n=t.split("|").reduce((t,n)=>{const e=n.split("¦");return t[e[0]]=e[1],t},{}),e={};return Object.keys(n).forEach(function(t){const o=unpack_1(n[t]);"true"===t&&(t=!0);for(let n=0;n<o.length;n++){const s=o[n];!0===e.hasOwnProperty(s)?!1===Array.isArray(e[s])?e[s]=[e[s],t]:e[s].push(t):e[s]=t}}),e},src=createCommonjsModule(function(t){const n={pack:pack_1$1,unpack:unpack_1$1};"undefined"!=typeof self?self.efrt=n:"undefined"!=typeof window?window.efrt=n:void 0!==commonjsGlobal&&(commonjsGlobal.efrt=n),t.exports=n});module.exports=src;
//# sourceMappingURL=efrt.min.js.map

@@ -5,3 +5,3 @@ {

"description": "neato compression of key-value data",
"version": "2.1.0",
"version": "2.2.0",
"main": "./builds/efrt.js",

@@ -13,5 +13,6 @@ "repository": {

"scripts": {
"test": "node ./scripts/test.js",
"testb": "TESTENV=prod node ./scripts/test.js",
"build": "node ./scripts/build/index.js",
"build": "rollup -c && node ./scripts/filesize.js",
"filesize": "node ./scripts/filesize.js",
"test": "tape \"./tests/*.test.js\" | tap-dancer",
"testb": "TESTENV=prod tape \"./tests/*.test.js\" | tap-dancer",
"watch": "amble ./scratch"

@@ -31,18 +32,14 @@ },

"devDependencies": {
"@babel/core": "7.4.5",
"@babel/preset-env": "7.4.5",
"@babel/core": "7.5.5",
"@babel/preset-env": "7.5.5",
"amble": "0.0.7",
"babelify": "10.0.0",
"browserify": "16.2.3",
"codacy-coverage": "3.4.0",
"derequire": "^2.0.3",
"eslint": "6.0.1",
"gaze": "^1.1.2",
"nyc": "14.1.1",
"shelljs": "0.8.3",
"tap-spec": "5.0.0",
"tape": "4.10.2",
"terser": "^4.0.0"
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "10.0.1",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-terser": "5.1.1",
"tap-dancer": "^0.2.0",
"tape": "4.11.0"
},
"license": "MIT"
}

@@ -7,11 +7,11 @@ <div align="center">

</a>
<a href="https://www.codacy.com/app/spencerkelly86/efrt">
<img src="https://api.codacy.com/project/badge/Coverage/fc03e2761c8c471c8f84141abf2704de" />
</a>
<a href="https://unpkg.com/efrt/builds/efrt.min.js">
<img src="https://badge-size.herokuapp.com/spencermountain/efrt/master/builds/efrt.min.js" />
</a>
<a href="https://nodejs.org/api/documentation.html#documentation_stability_index">
<img src="https://img.shields.io/badge/stability-stable-green.svg?style=flat-square" />
</a>
<a href="https://www.codacy.com/app/spencerkelly86/efrt">
<img src="https://api.codacy.com/project/badge/grade/fc03e2761c8c471c8f84141abf2704de" />
</a>
<a href="https://www.codacy.com/app/spencerkelly86/efrt">
<img src="https://api.codacy.com/project/badge/Coverage/fc03e2761c8c471c8f84141abf2704de" />
</a>
</div>

@@ -53,3 +53,3 @@

The whole library is **8kb**, the unpack half is barely **2.5kb**.
The whole library is **8kb**, the unpack half is barely **2kb**.

@@ -94,2 +94,27 @@ it is based on:

```
---
<h5 align="left">
or, an Array:
</h5>
if you pass it an array of strings, it just creates an object with `true` values:
```js
const data = [
'january',
'february',
'april',
'june',
'july',
'august',
'september',
'october',
'november',
'december'
]
const packd = efrt.pack(data)
// true¦a6dec4febr3j1ma0nov4octo5sept4;rch,y;an1u0;ly,ne;uary;em0;ber;pril,ugust
const sameArray = Object.keys(efrt.unpack(packd))
// same thing !
```
## Reserved characters

@@ -105,3 +130,3 @@ the keys of the object are normalized. Spaces/unicode are good, but numbers, case-sensitivity, and *some punctuation* (semicolon, comma, exclamation-mark) are not (yet) supported.

## Performance
*efrt* is tuned to be very quick to unzip. It is O(1) to lookup. Packing-up the data is the slowest part, which is usually cool.
*efrt* is tuned to be very quick to unzip. It is O(1) to lookup. Packing-up the data is the slowest part, which is usually fine:
```js

@@ -108,0 +133,0 @@ var compressed = efrt.pack(skateboarders);//1k words (on a macbook)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc