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

cognitive-ts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cognitive-ts - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

11

__test__/trie.test.ts

@@ -23,1 +23,12 @@ import * as _ from 'lodash'

})
test('prefix search', () => {
const t = new Trie()
insertWords(t)
const result = t.prefixSearch('car')
expect(result).toHaveLength(4)
expect(result).toContain('car')
expect(result).toContain('cart')
expect(result).toContain('carts')
expect(result).toContain('card')
})

@@ -86,2 +86,28 @@ import * as _ from 'lodash'

findAllWords = (node: TrieNode, arr: string[] ) => {
if (node.end) {
arr.unshift(node.getWord());
}
for (const child in node.children) {
this.findAllWords(node.children[child], arr);
}
}
prefixSearch = (prefix: string) => {
let node = this.root
const output: string[] = []
for(let i = 0; i < prefix.length; i++) {
const letter = prefix[i]
if (node.children[letter]) {
node = node.children[letter];
} else {
return output;
}
}
this.findAllWords(node, output);
return output;
}
delete = (word: string) => {

@@ -88,0 +114,0 @@ if (!word) {

2

package.json
{
"name": "cognitive-ts",
"version": "2.0.4",
"version": "2.0.5",
"description": "",

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

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