New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

radix-trie

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

radix-trie - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

.babelrc

21

package.json
{
"name": "radix-trie",
"version": "1.0.6",
"version": "1.0.7",
"description": "radix-trie implementation for Inverse Index Document Search.",
"main": "radixtrie.js",
"main": "dist/radixtrie.js",
"scripts": {
"test": "tape tests/*.js"
"build": "rollup -c",
"test": "tape tests/*.js",
"prepublish": "npm run build"
},

@@ -26,8 +28,13 @@ "repository": {

"homepage": "https://github.com/Plataforma5/radix-trie#readme",
"dependencies": {
"devDependencies": {
"babel-plugin-external-helpers": "~6.22.0",
"babel-preset-es2015": "~6.24.1",
"babel-preset-es2015-rollup": "~3.0.0",
"rollup": "~0.41.6",
"rollup-plugin-babel": "~2.7.1",
"rollup-plugin-commonjs": "~8.0.2",
"rollup-plugin-node-resolve": "~3.0.0",
"rword": "^2.1.0",
"tape": "^4.6.3"
},
"devDependencies": {
"rword": "^2.1.0"
}
}

@@ -33,3 +33,3 @@ const isEmpty = require('./utils.js').isEmpty;

module.exports = class radixTrie {
module.exports = class RadixTrie {
constructor(lang = 'es') {

@@ -40,5 +40,13 @@ this.root = new Root();

}
addWord(word, data, node) {
if (typeof word !== 'string') {
word = String(word);
}
word = replace(word.toLowerCase());
if (typeof word !== 'string') return new Error('TypeError: the word to add to the radix-tree should be a String');
if (typeof word !== 'string') {
return new Error('TypeError: the word to add to the radix-tree should be a String');
}
if (!node) {

@@ -67,2 +75,3 @@ node = this.root;

}
if (node.labels[lcp]) { // If the label for the lcp exists

@@ -78,2 +87,3 @@ return this.addWord(word.substring(lcp.length), data, node.labels[lcp]);

}
addMany(wordArray, data) {

@@ -86,2 +96,3 @@ data = { id: uuid(), data };

}
findPartial(word) {

@@ -104,2 +115,3 @@ const node = this.find(word);

}
for (let i = 1; i <= word.length; i += 1) {

@@ -110,2 +122,3 @@ if (this.labels[word.slice(0, i)]) {

}
return false;

@@ -115,2 +128,5 @@ }

find(word) {
if (typeof word !== 'string') {
word = String(word);
}
const tree = this;

@@ -121,4 +137,8 @@ return this.search.call(this.root, replace(word.toLowerCase()), tree);

findNode(word) {
if (typeof word !== 'string') {
word = String(word);
}
word = word.toLowerCase();
const node = this.find(word);
if (node) {

@@ -130,4 +150,6 @@ return {

}
return node;
}
findData(substring, node) {

@@ -203,2 +225,3 @@ if (!node) {

}
removeData(node, parent, data, word) {

@@ -252,2 +275,3 @@ if (node.data.length > 1 || Object.keys(node.labels).length > 1) {

}
filterStopWords(word) {

@@ -254,0 +278,0 @@ return this.stopwords.indexOf(word) === -1;

module.exports = [
'I',
'i'
'a',
'about',
'an',
'are',
'as',
'at',
'be',
'by',
'com',
'for',
'from',
'how',
'in',
'is',
'it',
'of',
'on',
'or',
'that',
'the',
'this',
'to',
'what',
'when',
'where',
'who',
'will',
'with',
'the',
'www'
]
"a",
"about",
"an",
"are",
"as",
"at",
"be",
"by",
"com",
"for",
"from",
"how",
"i",
"I",
"in",
"is",
"it",
"of",
"on",
"or",
"that",
"the",
"the",
"this",
"to",
"what",
"when",
"where",
"who",
"will",
"with",
"www"
]
module.exports = [
'un',
'una',
'unas',
'unos',
'uno',
'sobre',
'todo',
'también',
'tras',
'otro',
'ser',
'es',
'soy',
'eres',
'somos',
'sois',
'estoy',
'esta',
'estais',
'estan',
'como',
'en',
'para',
'atras',
'porque',
'por qué',
'ante',
'antes',
'ambos',
'pero',
'por',
'puede',
'puedo',
'cada',
'fin',
'incluso',
'gueno',
'ha',
'el',
'la',
'lo',
'las',
'los',
'su',
'aqui',
'mio',
'tuyo',
'ellos',
'ellas',
'nos',
'nosotros',
'vosotros',
'vosotras',
'si',
'dentro',
'solo',
'solamente',
'bastante',
'muchos',
'aquellos',
'aquellas',
'sus',
'dos',
'muy',
'cual',
'cuando',
'donde',
'mientras',
'quien',
'con',
'entre',
'sin',
'yo',
'aquel',
].sort();
"ambos",
"ante",
"antes",
"aquel",
"aquellas",
"aquellos",
"aqui",
"atras",
"bastante",
"cada",
"como",
"con",
"cual",
"cuando",
"dentro",
"donde",
"dos",
"el",
"ellas",
"ellos",
"en",
"entre",
"eres",
"es",
"esta",
"estais",
"estan",
"estoy",
"fin",
"gueno",
"ha",
"incluso",
"la",
"las",
"lo",
"los",
"mientras",
"mio",
"muchos",
"muy",
"nos",
"nosotros",
"otro",
"para",
"pero",
"por qué",
"por",
"porque",
"puede",
"puedo",
"quien",
"ser",
"si",
"sin",
"sobre",
"sois",
"solamente",
"solo",
"somos",
"soy",
"su",
"sus",
"también",
"todo",
"tras",
"tuyo",
"un",
"una",
"unas",
"uno",
"unos",
"vosotras",
"vosotros",
"yo"
]
module.exports = {
es: require('./es.js'),
en: require('./en'),
es: require('./es'),
};

@@ -74,3 +74,3 @@ const test = require('tape');

test('Test findMany', (t) => {
t.plan(6);
t.plan(7);
const trie = new RadixTrie();

@@ -80,2 +80,3 @@ trie.addMany(['hola', 'test'], 1);

trie.addMany(['hola', 'teresa', 'chao'], 3);
trie.addMany(['agregar', 'agregacion'], 4);

@@ -88,2 +89,3 @@ t.ok(Array.isArray(trie.findMany(['test', 'hola'])), 'Should be an Array');

t.equal(trie.findMany(['t']).length, 3, 'Should find all');
t.equal(trie.findMany(['agre']).length, 1, 'Should remove duplicates');
});

@@ -90,0 +92,0 @@

@@ -60,2 +60,11 @@ const test = require('tape');

test('Integers as words', (t) => {
t.plan(1);
const trie = new RadixTrie();
trie.addWord(1234, 1234);
trie.addWord(0, 0);
t.ok(trie.findNode(1234) && trie.findNode(0), 'Should find the two nodes.');
});
test('Count words', (t) => {

@@ -62,0 +71,0 @@ const trie = new RadixTrie();

Sorry, the diff of this file is not supported yet

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