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.0.1 to 2.0.2

516

builds/efrt-unpack.es5.js

@@ -345,2 +345,518 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

},{"../encoding":1,"./symbols":3}]},{},[2])(2)
});(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
var BASE = 36;
var seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var cache = seq.split('').reduce(function (h, c, i) {
h[c] = i;
return h;
}, {});
// 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ...
var toAlphaCode = function toAlphaCode(n) {
if (seq[n] !== undefined) {
return seq[n];
}
var places = 1;
var range = BASE;
var s = '';
for (; n >= range; n -= range, places++, range *= BASE) {}
while (places--) {
var d = n % BASE;
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s;
n = (n - d) / BASE;
}
return s;
};
var fromAlphaCode = function fromAlphaCode(s) {
if (cache[s] !== undefined) {
return cache[s];
}
var n = 0;
var places = 1;
var range = BASE;
var pow = 1;
for (; places < s.length; n += range, places++, range *= BASE) {}
for (var i = s.length - 1; i >= 0; i--, pow *= BASE) {
var d = s.charCodeAt(i) - 48;
if (d > 10) {
d -= 7;
}
n += d * pow;
}
return n;
};
module.exports = {
toAlphaCode: toAlphaCode,
fromAlphaCode: fromAlphaCode
};
},{}],2:[function(_dereq_,module,exports){
'use strict';
var unpack = _dereq_('./unpack');
module.exports = function (str) {
//turn the weird string into a key-value object again
var obj = str.split('|').reduce(function (h, s) {
var arr = s.split('¦');
h[arr[0]] = arr[1];
return h;
}, {});
var all = {};
Object.keys(obj).forEach(function (cat) {
var arr = unpack(obj[cat]);
//special case, for botched-boolean
if (cat === 'true') {
cat = true;
}
for (var i = 0; i < arr.length; i++) {
var k = arr[i];
if (all.hasOwnProperty(k) === true) {
if (Array.isArray(all[k]) === false) {
all[k] = [all[k], cat];
} else {
all[k].push(cat);
}
} else {
all[k] = cat;
}
}
});
return all;
};
},{"./unpack":4}],3:[function(_dereq_,module,exports){
'use strict';
var encoding = _dereq_('../encoding');
//the symbols are at the top of the array.
module.exports = function (t) {
//... process these lines
var reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)');
for (var i = 0; i < t.nodes.length; i++) {
var m = reSymbol.exec(t.nodes[i]);
if (!m) {
t.symCount = i;
break;
}
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]);
}
//remove from main node list
t.nodes = t.nodes.slice(t.symCount, t.nodes.length);
};
},{"../encoding":1}],4:[function(_dereq_,module,exports){
'use strict';
var parseSymbols = _dereq_('./symbols');
var encoding = _dereq_('../encoding');
// References are either absolute (symbol) or relative (1 - based)
var indexFromRef = function indexFromRef(trie, ref, index) {
var dnode = encoding.fromAlphaCode(ref);
if (dnode < trie.symCount) {
return trie.syms[dnode];
}
return index + dnode + 1 - trie.symCount;
};
var toArray = function toArray(trie) {
var all = [];
var crawl = function crawl(index, pref) {
var node = trie.nodes[index];
if (node[0] === '!') {
all.push(pref);
node = node.slice(1); //ok, we tried. remove it.
}
var matches = node.split(/([A-Z0-9,]+)/g);
for (var i = 0; i < matches.length; i += 2) {
var str = matches[i];
var ref = matches[i + 1];
if (!str) {
continue;
}
var have = pref + str;
//branch's end
if (ref === ',' || ref === undefined) {
all.push(have);
continue;
}
var newIndex = indexFromRef(trie, ref, index);
crawl(newIndex, have);
}
};
crawl(0, '');
return all;
};
//PackedTrie - Trie traversal of the Trie packed-string representation.
var unpack = function unpack(str) {
var trie = {
nodes: str.split(';'), //that's all ;)!
syms: [],
symCount: 0
};
//process symbols, if they have them
if (str.match(':')) {
parseSymbols(trie);
}
return toArray(trie);
};
module.exports = unpack;
},{"../encoding":1,"./symbols":3}]},{},[2])(2)
});(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
var BASE = 36;
var seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var cache = seq.split('').reduce(function (h, c, i) {
h[c] = i;
return h;
}, {});
// 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ...
var toAlphaCode = function toAlphaCode(n) {
if (seq[n] !== undefined) {
return seq[n];
}
var places = 1;
var range = BASE;
var s = '';
for (; n >= range; n -= range, places++, range *= BASE) {}
while (places--) {
var d = n % BASE;
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s;
n = (n - d) / BASE;
}
return s;
};
var fromAlphaCode = function fromAlphaCode(s) {
if (cache[s] !== undefined) {
return cache[s];
}
var n = 0;
var places = 1;
var range = BASE;
var pow = 1;
for (; places < s.length; n += range, places++, range *= BASE) {}
for (var i = s.length - 1; i >= 0; i--, pow *= BASE) {
var d = s.charCodeAt(i) - 48;
if (d > 10) {
d -= 7;
}
n += d * pow;
}
return n;
};
module.exports = {
toAlphaCode: toAlphaCode,
fromAlphaCode: fromAlphaCode
};
},{}],2:[function(_dereq_,module,exports){
'use strict';
var unpack = _dereq_('./unpack');
module.exports = function (str) {
//turn the weird string into a key-value object again
var obj = str.split('|').reduce(function (h, s) {
var arr = s.split('¦');
h[arr[0]] = arr[1];
return h;
}, {});
var all = {};
Object.keys(obj).forEach(function (cat) {
var arr = unpack(obj[cat]);
//special case, for botched-boolean
if (cat === 'true') {
cat = true;
}
for (var i = 0; i < arr.length; i++) {
var k = arr[i];
if (all.hasOwnProperty(k) === true) {
if (Array.isArray(all[k]) === false) {
all[k] = [all[k], cat];
} else {
all[k].push(cat);
}
} else {
all[k] = cat;
}
}
});
return all;
};
},{"./unpack":4}],3:[function(_dereq_,module,exports){
'use strict';
var encoding = _dereq_('../encoding');
//the symbols are at the top of the array.
module.exports = function (t) {
//... process these lines
var reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)');
for (var i = 0; i < t.nodes.length; i++) {
var m = reSymbol.exec(t.nodes[i]);
if (!m) {
t.symCount = i;
break;
}
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]);
}
//remove from main node list
t.nodes = t.nodes.slice(t.symCount, t.nodes.length);
};
},{"../encoding":1}],4:[function(_dereq_,module,exports){
'use strict';
var parseSymbols = _dereq_('./symbols');
var encoding = _dereq_('../encoding');
// References are either absolute (symbol) or relative (1 - based)
var indexFromRef = function indexFromRef(trie, ref, index) {
var dnode = encoding.fromAlphaCode(ref);
if (dnode < trie.symCount) {
return trie.syms[dnode];
}
return index + dnode + 1 - trie.symCount;
};
var toArray = function toArray(trie) {
var all = [];
var crawl = function crawl(index, pref) {
var node = trie.nodes[index];
if (node[0] === '!') {
all.push(pref);
node = node.slice(1); //ok, we tried. remove it.
}
var matches = node.split(/([A-Z0-9,]+)/g);
for (var i = 0; i < matches.length; i += 2) {
var str = matches[i];
var ref = matches[i + 1];
if (!str) {
continue;
}
var have = pref + str;
//branch's end
if (ref === ',' || ref === undefined) {
all.push(have);
continue;
}
var newIndex = indexFromRef(trie, ref, index);
crawl(newIndex, have);
}
};
crawl(0, '');
return all;
};
//PackedTrie - Trie traversal of the Trie packed-string representation.
var unpack = function unpack(str) {
var trie = {
nodes: str.split(';'), //that's all ;)!
syms: [],
symCount: 0
};
//process symbols, if they have them
if (str.match(':')) {
parseSymbols(trie);
}
return toArray(trie);
};
module.exports = unpack;
},{"../encoding":1,"./symbols":3}]},{},[2])(2)
});(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';
var BASE = 36;
var seq = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var cache = seq.split('').reduce(function (h, c, i) {
h[c] = i;
return h;
}, {});
// 0, 1, 2, ..., A, B, C, ..., 00, 01, ... AA, AB, AC, ..., AAA, AAB, ...
var toAlphaCode = function toAlphaCode(n) {
if (seq[n] !== undefined) {
return seq[n];
}
var places = 1;
var range = BASE;
var s = '';
for (; n >= range; n -= range, places++, range *= BASE) {}
while (places--) {
var d = n % BASE;
s = String.fromCharCode((d < 10 ? 48 : 55) + d) + s;
n = (n - d) / BASE;
}
return s;
};
var fromAlphaCode = function fromAlphaCode(s) {
if (cache[s] !== undefined) {
return cache[s];
}
var n = 0;
var places = 1;
var range = BASE;
var pow = 1;
for (; places < s.length; n += range, places++, range *= BASE) {}
for (var i = s.length - 1; i >= 0; i--, pow *= BASE) {
var d = s.charCodeAt(i) - 48;
if (d > 10) {
d -= 7;
}
n += d * pow;
}
return n;
};
module.exports = {
toAlphaCode: toAlphaCode,
fromAlphaCode: fromAlphaCode
};
},{}],2:[function(_dereq_,module,exports){
'use strict';
var unpack = _dereq_('./unpack');
module.exports = function (str) {
//turn the weird string into a key-value object again
var obj = str.split('|').reduce(function (h, s) {
var arr = s.split('¦');
h[arr[0]] = arr[1];
return h;
}, {});
var all = {};
Object.keys(obj).forEach(function (cat) {
var arr = unpack(obj[cat]);
//special case, for botched-boolean
if (cat === 'true') {
cat = true;
}
for (var i = 0; i < arr.length; i++) {
var k = arr[i];
if (all.hasOwnProperty(k) === true) {
if (Array.isArray(all[k]) === false) {
all[k] = [all[k], cat];
} else {
all[k].push(cat);
}
} else {
all[k] = cat;
}
}
});
return all;
};
},{"./unpack":4}],3:[function(_dereq_,module,exports){
'use strict';
var encoding = _dereq_('../encoding');
//the symbols are at the top of the array.
module.exports = function (t) {
//... process these lines
var reSymbol = new RegExp('([0-9A-Z]+):([0-9A-Z]+)');
for (var i = 0; i < t.nodes.length; i++) {
var m = reSymbol.exec(t.nodes[i]);
if (!m) {
t.symCount = i;
break;
}
t.syms[encoding.fromAlphaCode(m[1])] = encoding.fromAlphaCode(m[2]);
}
//remove from main node list
t.nodes = t.nodes.slice(t.symCount, t.nodes.length);
};
},{"../encoding":1}],4:[function(_dereq_,module,exports){
'use strict';
var parseSymbols = _dereq_('./symbols');
var encoding = _dereq_('../encoding');
// References are either absolute (symbol) or relative (1 - based)
var indexFromRef = function indexFromRef(trie, ref, index) {
var dnode = encoding.fromAlphaCode(ref);
if (dnode < trie.symCount) {
return trie.syms[dnode];
}
return index + dnode + 1 - trie.symCount;
};
var toArray = function toArray(trie) {
var all = [];
var crawl = function crawl(index, pref) {
var node = trie.nodes[index];
if (node[0] === '!') {
all.push(pref);
node = node.slice(1); //ok, we tried. remove it.
}
var matches = node.split(/([A-Z0-9,]+)/g);
for (var i = 0; i < matches.length; i += 2) {
var str = matches[i];
var ref = matches[i + 1];
if (!str) {
continue;
}
var have = pref + str;
//branch's end
if (ref === ',' || ref === undefined) {
all.push(have);
continue;
}
var newIndex = indexFromRef(trie, ref, index);
crawl(newIndex, have);
}
};
crawl(0, '');
return all;
};
//PackedTrie - Trie traversal of the Trie packed-string representation.
var unpack = function unpack(str) {
var trie = {
nodes: str.split(';'), //that's all ;)!
syms: [],
symCount: 0
};
//process symbols, if they have them
if (str.match(':')) {
parseSymbols(trie);
}
return toArray(trie);
};
module.exports = unpack;
},{"../encoding":1,"./symbols":3}]},{},[2])(2)
});

2

builds/efrt-unpack.js

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

/* efrt trie-compression v2.0.1 github.com/nlp-compromise/efrt - MIT */
/* efrt trie-compression v2.0.2 github.com/nlp-compromise/efrt - MIT */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unpack = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

@@ -3,0 +3,0 @@ 'use strict';

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

/* efrt trie-compression v2.0.1 github.com/nlp-compromise/efrt - MIT */
/* efrt trie-compression v2.0.2 github.com/nlp-compromise/efrt - MIT */
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.efrt = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

@@ -206,3 +206,11 @@ 'use strict';

//normal string/boolean version
h[val] = h[val] || [];
if (h.hasOwnProperty(val) === false) {
//basically h[val]=[] - support reserved words
Object.defineProperty(h, val, {
writable: true,
enumerable: true,
configurable: true,
value: []
});
}
h[val].push(k);

@@ -209,0 +217,0 @@ return h;

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

/* efrt trie-compression v2.0.1 github.com/nlp-compromise/efrt - MIT */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.efrt=t()}}(function(){var t;return function t(n,e,o){function i(s,u){if(!e[s]){if(!n[s]){var f="function"==typeof require&&require;if(!u&&f)return f(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=e[s]={exports:{}};n[s][0].call(d.exports,function(t){var e=n[s][1][t];return i(e?e:t)},d,d.exports,t,n,e,o)}return e[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,n,e){"use strict";var o=36,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",r=i.split("").reduce(function(t,n,e){return t[n]=e,t},{}),s=function(t){if(void 0!==i[t])return i[t];for(var n=1,e=o,r="";t>=e;t-=e,n++,e*=o);for(;n--;){var s=t%o;r=String.fromCharCode((s<10?48:55)+s)+r,t=(t-s)/o}return r},u=function(t){if(void 0!==r[t])return r[t];for(var n=0,e=1,i=o,s=1;e<t.length;n+=i,e++,i*=o);for(var u=t.length-1;u>=0;u--,s*=o){var f=t.charCodeAt(u)-48;f>10&&(f-=7),n+=f*s}return n};n.exports={toAlphaCode:s,fromAlphaCode:u}},{}],2:[function(n,e,o){(function(o){"use strict";var i={pack:n("./pack/index"),unpack:n("./unpack/index")};"undefined"!=typeof self?self.efrt=i:"undefined"!=typeof window?window.efrt=i:"undefined"!=typeof o&&(o.efrt=i),"function"==typeof t&&t.amd&&t(i),"undefined"!=typeof e&&(e.exports=i)}).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";var o=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""},i=function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)};n.exports={commonPrefix:o,unique:i}},{}],4:[function(t,n,e){"use strict";var o=function(){this.counts={}},i={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 i=e[o];n.push([i,this.counts[i]])}return n.sort(function(t,n){return n[1]-t[1]}),t&&(n=n.slice(0,t)),n}};Object.keys(i).forEach(function(t){o.prototype[t]=i[t]}),n.exports=o},{}],5:[function(t,n,e){"use strict";var o=t("./trie"),i=function(t){return"[object Array]"===Object.prototype.toString.call(t)},r=function(t){return null===t||void 0===t?{}:"string"==typeof t?t.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):i(t)?t.reduce(function(t,n){return t[n]=!0,t},{}):t},s=function(t){t=r(t);var n=Object.keys(t).reduce(function(n,e){var o=t[e];if(i(o)){for(var r=0;r<o.length;r++)n[o[r]]=n[o[r]]||[],n[o[r]].push(e);return n}return n[o]=n[o]||[],n[o].push(e),n},{});return Object.keys(n).forEach(function(t){var e=new o(n[t]);n[t]=e.pack()}),Object.keys(n).map(function(t){return t+"¦"+n[t]}).join("|")};n.exports=s},{"./trie":8}],6:[function(t,n,e){"use strict";var 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},i=t("./fns"),r=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();i.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;this.lastWord=t;var e=i.commonPrefix(t,n);if(e!==n){var o=this.uniqueNode(n,t,this.root);o&&this.combineSuffixNode(o)}},_insert:function(t,n){var e=void 0,r=void 0;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(e=i.commonPrefix(t,f),0!==e.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 r={},r[f.slice(e.length)]=n[f],this.addTerminal(r,t=t.slice(e.length)),delete n[f],n[e]=r,void this.wordCount++}}this.addTerminal(n,t),this.wordCount++}},addTerminal:function(t,n){if(n.length<=1)return void(t[n]=1);var e={};t[n[0]]=e,this.addTerminal(e,n.slice(1))},nodeProps:function(t,n){var e=[];for(var i in t)""!==i&&"_"!==i[0]&&(n&&"object"!==o(t[i])||e.push(i));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),i=0;i<e.length;i++){var r=e[i];"object"===o(t[r])?(t[r]=this.combineSuffixNode(t[r]),n.push(r),n.push(t[r]._c)):n.push(r)}n=n.join("-");var s=this.suffixes[n];return s?s:(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=void 0,e=void 0,i=void 0,r=void 0;if(!this.visited(t)){for(e=this.nodeProps(t),r=0;r<e.length;r++)n=e[r],i=t[n],"object"===("undefined"==typeof i?"undefined":o(i))&&(this.collapseChains(i),void 0===i._g||1!==i._d&&1!==i._g.length||(delete t[n],n+=i._g,t[n]=i[i._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),i=0;i<o.length;i++){var r=o[i];if(r===t.slice(0,r.length))return r!==n.slice(0,r.length)?e[r]:this.uniqueNode(t.slice(r.length),n.slice(r.length),e[r])}},pack:function(){return r(this)}}},{"./fns":3,"./pack":7}],7:[function(t,n,e){"use strict";var o=t("./histogram"),i=t("../encoding"),r={NODE_SEP:";",KEY_VAL:":",STRING_SEP:",",TERMINAL_PREFIX:"!",BASE:36},s=function(t,n){var e="",o="";t.isTerminal(n)&&(e+=r.TERMINAL_PREFIX);for(var s=t.nodeProps(n),u=0;u<s.length;u++){var f=s[u];if("number"!=typeof n[f])if(t.syms[n[f]._n])e+=o+f+t.syms[n[f]._n],o="";else{var c=i.toAlphaCode(n._n-n[f]._n-1+t.symCount);n[f]._g&&c.length>=n[f]._g.length&&1===n[n[f]._g]?(c=n[f]._g,e+=o+f+c,o=r.STRING_SEP):(e+=o+f+c,o="")}else e+=o+f,o=r.STRING_SEP}return e},u=function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),s=0;s<o.length;s++){var u=o[s],f=e._n-e[u]._n-1;f<r.BASE&&n.histRel.add(f),n.histAbs.add(e[u]._n,i.toAlphaCode(f).length-1),t(n,e[u])}},f=function(t){t.histAbs=t.histAbs.highest(r.BASE);var n=[];n[-1]=0;for(var e=0,o=0,s=3+i.toAlphaCode(t.nodeCount).length,u=0;u<r.BASE&&void 0!==t.histAbs[u];u++)n[u]=t.histAbs[u][1]-s-t.histRel.countOf(r.BASE-u-1)+n[u-1],n[u]>=e&&(e=n[u],o=u+1);return o},c=function t(n,e){if(void 0===e._n){for(var o=n.nodeProps(e,!0),i=0;i<o.length;i++)t(n,e[o[i]]);e._n=n.pos++,n.nodes.unshift(e)}},d=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,c(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),u(t,t.root),t.symCount=f(t);for(var n=0;n<t.symCount;n++)t.syms[t.histAbs[n][0]]=i.toAlphaCode(n);for(var e=0;e<t.nodeCount;e++)t.nodes[e]=s(t,t.nodes[e]);for(var d=t.symCount-1;d>=0;d--)t.nodes.unshift(i.toAlphaCode(d)+r.KEY_VAL+i.toAlphaCode(t.nodeCount-t.histAbs[d][0]-1));return t.nodes.join(r.NODE_SEP)};n.exports=d},{"../encoding":1,"./histogram":4}],8:[function(t,n,e){"use strict";var o=t("./methods"),i=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){i.prototype[t]=o[t]}),n.exports=i},{"./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 i=o(n[t]);"true"===t&&(t=!0);for(var r=0;r<i.length;r++){var s=i[r];e.hasOwnProperty(s)===!0?Array.isArray(e[s])===!1?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 i=n.exec(t.nodes[e]);if(!i){t.symCount=e;break}t.syms[o.fromAlphaCode(i[1])]=o.fromAlphaCode(i[2])}t.nodes=t.nodes.slice(t.symCount,t.nodes.length)}},{"../encoding":1}],11:[function(t,n,e){"use strict";var o=t("./symbols"),i=t("../encoding"),r=function(t,n,e){var o=i.fromAlphaCode(n);return o<t.symCount?t.syms[o]:e+o+1-t.symCount},s=function(t){var n=[],e=function e(o,i){var s=t.nodes[o];"!"===s[0]&&(n.push(i),s=s.slice(1));for(var u=s.split(/([A-Z0-9,]+)/g),f=0;f<u.length;f+=2){var c=u[f],d=u[f+1];if(c){var h=i+c;if(","!==d&&void 0!==d){var a=r(t,d,o);e(a,h)}else n.push(h)}}};return e(0,""),n},u=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),s(n)};n.exports=u},{"../encoding":1,"./symbols":10}]},{},[2])(2)});
/* efrt trie-compression v2.0.2 github.com/nlp-compromise/efrt - MIT */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.efrt=t()}}(function(){var t;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 a=e[s]={exports:{}};n[s][0].call(a.exports,function(t){var e=n[s][1][t];return r(e?e:t)},a,a.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=36,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",i=r.split("").reduce(function(t,n,e){return t[n]=e,t},{}),s=function(t){if(void 0!==r[t])return r[t];for(var n=1,e=o,i="";t>=e;t-=e,n++,e*=o);for(;n--;){var s=t%o;i=String.fromCharCode((s<10?48:55)+s)+i,t=(t-s)/o}return i},u=function(t){if(void 0!==i[t])return i[t];for(var n=0,e=1,r=o,s=1;e<t.length;n+=r,e++,r*=o);for(var u=t.length-1;u>=0;u--,s*=o){var f=t.charCodeAt(u)-48;f>10&&(f-=7),n+=f*s}return n};n.exports={toAlphaCode:s,fromAlphaCode:u}},{}],2:[function(n,e,o){(function(o){"use strict";var r={pack:n("./pack/index"),unpack:n("./unpack/index")};"undefined"!=typeof self?self.efrt=r:"undefined"!=typeof window?window.efrt=r:"undefined"!=typeof o&&(o.efrt=r),"function"==typeof t&&t.amd&&t(r),"undefined"!=typeof e&&(e.exports=r)}).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";var o=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""},r=function(t){t.sort();for(var n=1;n<t.length;n++)t[n-1]===t[n]&&t.splice(n,1)};n.exports={commonPrefix:o,unique:r}},{}],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)},i=function(t){return null===t||void 0===t?{}:"string"==typeof t?t.split(/ +/g).reduce(function(t,n){return t[n]=!0,t},{}):r(t)?t.reduce(function(t,n){return t[n]=!0,t},{}):t},s=function(t){t=i(t);var n=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 n.hasOwnProperty(o)===!1&&Object.defineProperty(n,o,{writable:!0,enumerable:!0,configurable:!0,value:[]}),n[o].push(e),n},{});return Object.keys(n).forEach(function(t){var e=new o(n[t]);n[t]=e.pack()}),Object.keys(n).map(function(t){return t+"¦"+n[t]}).join("|")};n.exports=s},{"./trie":8}],6:[function(t,n,e){"use strict";var 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},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;this.lastWord=t;var e=r.commonPrefix(t,n);if(e!==n){var o=this.uniqueNode(n,t,this.root);o&&this.combineSuffixNode(o)}},_insert:function(t,n){var e=void 0,i=void 0;if(0!==t.length){for(var s=Object.keys(n),u=0;u<s.length;u++){var f=s[u];if(e=r.commonPrefix(t,f),0!==e.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={},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)return void(t[n]=1);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)}n=n.join("-");var s=this.suffixes[n];return s?s:(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=void 0,e=void 0,r=void 0,i=void 0;if(!this.visited(t)){for(e=this.nodeProps(t),i=0;i<e.length;i++)n=e[i],r=t[n],"object"===("undefined"==typeof r?"undefined":o(r))&&(this.collapseChains(r),void 0===r._g||1!==r._d&&1!==r._g.length||(delete t[n],n+=r._g,t[n]=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={NODE_SEP:";",KEY_VAL:":",STRING_SEP:",",TERMINAL_PREFIX:"!",BASE:36},s=function(t,n){var e="",o="";t.isTerminal(n)&&(e+=i.TERMINAL_PREFIX);for(var s=t.nodeProps(n),u=0;u<s.length;u++){var f=s[u];if("number"!=typeof n[f])if(t.syms[n[f]._n])e+=o+f+t.syms[n[f]._n],o="";else{var c=r.toAlphaCode(n._n-n[f]._n-1+t.symCount);n[f]._g&&c.length>=n[f]._g.length&&1===n[n[f]._g]?(c=n[f]._g,e+=o+f+c,o=i.STRING_SEP):(e+=o+f+c,o="")}else e+=o+f,o=i.STRING_SEP}return e},u=function t(n,e){if(!n.visited(e))for(var o=n.nodeProps(e,!0),s=0;s<o.length;s++){var u=o[s],f=e._n-e[u]._n-1;f<i.BASE&&n.histRel.add(f),n.histAbs.add(e[u]._n,r.toAlphaCode(f).length-1),t(n,e[u])}},f=function(t){t.histAbs=t.histAbs.highest(i.BASE);var n=[];n[-1]=0;for(var e=0,o=0,s=3+r.toAlphaCode(t.nodeCount).length,u=0;u<i.BASE&&void 0!==t.histAbs[u];u++)n[u]=t.histAbs[u][1]-s-t.histRel.countOf(i.BASE-u-1)+n[u-1],n[u]>=e&&(e=n[u],o=u+1);return o},c=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)}},a=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,c(t,t.root),t.nodeCount=t.nodes.length,t.prepDFS(),u(t,t.root),t.symCount=f(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]=s(t,t.nodes[e]);for(var a=t.symCount-1;a>=0;a--)t.nodes.unshift(r.toAlphaCode(a)+i.KEY_VAL+r.toAlphaCode(t.nodeCount-t.histAbs[a][0]-1));return t.nodes.join(i.NODE_SEP)};n.exports=a},{"../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];e.hasOwnProperty(s)===!0?Array.isArray(e[s])===!1?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},s=function(t){var n=[],e=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],a=u[f+1];if(c){var d=r+c;if(","!==a&&void 0!==a){var h=i(t,a,o);e(h,d)}else n.push(d)}}};return e(0,""),n},u=function(t){var n={nodes:t.split(";"),syms:[],symCount:0};return t.match(":")&&o(n),s(n)};n.exports=u},{"../encoding":1,"./symbols":10}]},{},[2])(2)});

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

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

@@ -14,5 +14,5 @@ "repository": {

"test": "node ./scripts/test.js",
"testBuild": "TESTENV=prod node ./scripts/test.js",
"testb": "TESTENV=prod node ./scripts/test.js",
"build": "node ./scripts/build/index.js",
"watch": "node ./scripts/watch.js"
"watch": "amble ./scratch"
},

@@ -24,10 +24,11 @@ "files": [

"devDependencies": {
"nyc": "^11.2.1",
"codacy-coverage": "^2.0.3",
"amble": "0.0.4",
"babel-preset-es2015": "6.9.0",
"babelify": "7.3.0",
"browserify": "13.0.1",
"codacy-coverage": "^2.0.3",
"derequire": "^2.0.3",
"eslint": "^3.17.1",
"gaze": "^1.1.2",
"nyc": "^11.2.1",
"shelljs": "^0.7.2",

@@ -34,0 +35,0 @@ "tap-spec": "4.1.1",

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