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
1
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.2 to 1.0.3

2

package.json
{
"name": "radix-trie",
"version": "1.0.2",
"version": "1.0.3",
"description": "radix-trie implementation for Inverse Index Document Search.",

@@ -5,0 +5,0 @@ "main": "radixtrie.js",

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

addWord(word, data, node) {
word = word.toLowerCase();
if (typeof word !== 'string') return new Error('dont be such a sucker');

@@ -114,29 +115,43 @@ if (!node) {

for (let i = 1; i <= substring.length; i += 1) {
if (node.labels.hasOwnProperty(substring.slice(0,i))) {
return this.findData(substring.slice(i), node.labels[substring.slice(0,i)]);
if (node.labels.hasOwnProperty(substring.slice(0, i))) {
return this.findData(substring.slice(i), node.labels[substring.slice(0, i)]);
}
}
for (let i in Object.keys(node.labels) ) {
let label = Object.keys(node.labels)[i]
if (substring.charAt(0) === label.charAt(0)) {
return this.findData(getDifference(label, substring), node.labels[label]);
for (let j = 0; j < Object.keys(node.labels).length; j += 1) {
const label = Object.keys(node.labels)[j];
let next = 0;
for (let z = 0; z <= substring.length; z += 1) {
if (substring.charAt(z) === label.charAt(z)) {
next = z + 1;
} else {
break;
}
}
return this.getData(node.labels[label]);
if (next) {
return this.findData(substring.slice(next), node.labels[label]);
}
}
return false
return null;
}
autocomplete(substring, node, words) {
autocomplete(substring, node, words, word) {
if (!node) node = this.root;
if (!words) words = [];
if (!word) word = '';
if (node.eow) {
words.push(substring);
words.push(word);
}
for (let i in Object.keys(node.labels) ) {
let label = Object.keys(node.labels)[i]
if(substring.charAt(0) === label.charAt(0)) {
return this.findData(getDifference(label, substring), node.labels[label]);
Object.keys(node.labels).forEach((label) => {
let next = 0;
for (let z = 0; z <= substring.length; z += 1) {
if (substring.charAt(z) === label.charAt(z)) {
next = z + 1;
} else {
break;
}
}
};
if (next || substring.length === 0) {
this.autocomplete(substring.slice(next), node.labels[label], words, word + label);
}
});
return words;

@@ -146,7 +161,11 @@ }

getData(node) {
if(!node) node = this.root;
if(isEmpty(node.labels)) return node.data;
return node.data.concat(concatMap(Object.keys(node.labels),
if (!node) node = this.root;
if (isEmpty(node.labels)) return node.data;
if (node.data) {
return node.data.concat(concatMap(Object.keys(node.labels),
label => this.getData(node.labels[label])));
}
return [].concat(concatMap(Object.keys(node.labels),
label => this.getData(node.labels[label])));
};
}

@@ -153,0 +172,0 @@ removeData(node, parent, data, word) {

@@ -81,2 +81,1 @@ const test = require('tape');

});
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