@navpreetdevpuri/trie-js
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -91,3 +91,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (currentNode[ch]) { | ||
return currentNode; | ||
return currentNode[ch]; | ||
} | ||
@@ -106,4 +106,2 @@ } | ||
} | ||
if (!currentNode || !currentNode._isEnd) | ||
return null; | ||
return currentNode; | ||
@@ -151,10 +149,10 @@ }; | ||
Trie.prototype.find = function (key) { | ||
var currentNode = this._findNode(key); | ||
if (!currentNode) | ||
var node = this._findNode(key); | ||
if (!node._isEnd) | ||
return null; | ||
return currentNode.values; | ||
return node.values; | ||
}; | ||
Trie.prototype.remove = function (key, valueChecker) { | ||
var node = this._findNode(key); | ||
if (!node) | ||
if (!node._isEnd) | ||
return false; | ||
@@ -161,0 +159,0 @@ node.values.forEach(function (value, index) { |
{ | ||
"name": "@navpreetdevpuri/trie-js", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Trie data structure implementation in javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -113,3 +113,3 @@ type TrieNode = { | ||
if (currentNode[ch]) { | ||
return currentNode; | ||
return currentNode[ch]; | ||
} | ||
@@ -129,3 +129,2 @@ } | ||
if (!currentNode || !currentNode._isEnd) return null; | ||
return currentNode; | ||
@@ -139,2 +138,3 @@ } | ||
const queue: [TrieNode, string][] = []; | ||
this._pushAllPossibleNodesForPrefix(key, queue); | ||
@@ -188,5 +188,5 @@ | ||
find(key): any[] { | ||
let currentNode = this._findNode(key); | ||
if (!currentNode) return null; | ||
return currentNode.values; | ||
let node = this._findNode(key); | ||
if (!node._isEnd) return null; | ||
return node.values; | ||
} | ||
@@ -196,3 +196,3 @@ | ||
const node = this._findNode(key); | ||
if (!node) return false; | ||
if (!node._isEnd) return false; | ||
node.values.forEach((value, index) => { | ||
@@ -199,0 +199,0 @@ if (valueChecker(value)) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
19699
491