Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-trie-search

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-trie-search - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

24

lib/cjs/trieSearch.js

@@ -10,4 +10,4 @@ "use strict";

constructor() {
this.map = {};
this.words = [];
this.m = {};
this.w = [];
}

@@ -48,3 +48,3 @@ }

if (opts.addKey === true) {
nodeObj.key = trieKey++;
nodeObj.k = trieKey++;
}

@@ -62,3 +62,3 @@ if (!opts.excludeNodes.includes(expandedElement[i].toLowerCase())) {

// empty out the top level array as it serves no purpose and adds to the size
root.words = [];
root.w = [];
return root;

@@ -70,10 +70,10 @@ };

if (startIndex === node.length) {
root.words.push(str);
root.w.push(str);
return;
}
if (!root.map[node[startIndex]]) {
root.map[node[startIndex]] = new TrieNode();
if (!root.m[node[startIndex]]) {
root.m[node[startIndex]] = new TrieNode();
}
root.words.push(str);
add(str, startIndex + 1, root.map[node[startIndex]]);
root.w.push(str);
add(str, startIndex + 1, root.m[node[startIndex]]);
};

@@ -83,8 +83,8 @@ const search = (str, startIndex, root) => {

if (startIndex === str.length && startIndex !== 0) {
return root.words;
return root.w;
}
if (!root.map[str[startIndex]])
if (!root.m[str[startIndex]])
return [];
return search(str, startIndex + 1, root.map[str[startIndex]]);
return search(str, startIndex + 1, root.m[str[startIndex]]);
};
exports.search = search;

@@ -8,4 +8,4 @@ type Options = {

declare class TrieNode {
map: any;
words: any;
m: any;
w: any;
constructor();

@@ -12,0 +12,0 @@ }

import parseRegex from "regex-parser";
class TrieNode {
map;
words;
m; //map
w; //words
constructor() {
this.map = {};
this.words = [];
this.m = {};
this.w = [];
}

@@ -42,3 +42,3 @@ }

if (opts.addKey === true) {
nodeObj.key = trieKey++;
nodeObj.k = trieKey++;
}

@@ -56,3 +56,3 @@ if (!opts.excludeNodes.includes(expandedElement[i].toLowerCase())) {

// empty out the top level array as it serves no purpose and adds to the size
root.words = [];
root.w = [];
return root;

@@ -63,10 +63,10 @@ };

if (startIndex === node.length) {
root.words.push(str);
root.w.push(str);
return;
}
if (!root.map[node[startIndex]]) {
root.map[node[startIndex]] = new TrieNode();
if (!root.m[node[startIndex]]) {
root.m[node[startIndex]] = new TrieNode();
}
root.words.push(str);
add(str, startIndex + 1, root.map[node[startIndex]]);
root.w.push(str);
add(str, startIndex + 1, root.m[node[startIndex]]);
};

@@ -76,8 +76,8 @@ const search = (str, startIndex, root) => {

if (startIndex === str.length && startIndex !== 0) {
return root.words;
return root.w;
}
if (!root.map[str[startIndex]])
if (!root.m[str[startIndex]])
return [];
return search(str, startIndex + 1, root.map[str[startIndex]]);
return search(str, startIndex + 1, root.m[str[startIndex]]);
};
export { generateTrie, search, TrieNode };

@@ -8,4 +8,4 @@ type Options = {

declare class TrieNode {
map: any;
words: any;
m: any;
w: any;
constructor();

@@ -12,0 +12,0 @@ }

{
"name": "fast-trie-search",
"version": "1.1.4",
"description": "This package can be used to implement a Search-As-You-Type funtionality and uses a Trie data structure",
"version": "1.1.5",
"description": "This package can be used to implement a Search-As-You-Type funtionality and uses a Trie data structure ",
"exports": {

@@ -6,0 +6,0 @@ ".": {

Sorry, the diff of this file is not supported yet

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