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

trie-prefix-tree

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trie-prefix-tree - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

15

dist/index.js

@@ -87,2 +87,4 @@ 'use strict';

getPrefix: function getPrefix(strPrefix) {
var sorted = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (typeof strPrefix !== 'string' || strPrefix === '') {

@@ -92,2 +94,6 @@ throw 'Expected string prefix, received ' + (typeof strPrefix === 'undefined' ? 'undefined' : _typeof(strPrefix));

if (typeof sorted !== 'boolean') {
throw 'Expected sort parameter as boolean, received ' + (typeof sorted === 'undefined' ? 'undefined' : _typeof(sorted));
}
if (!this.isPrefix(strPrefix)) {

@@ -100,3 +106,3 @@ return [];

return (0, _recursePrefix2.default)(prefixNode, strPrefix);
return (0, _recursePrefix2.default)(prefixNode, strPrefix, sorted);
},

@@ -121,3 +127,8 @@

getWords: function getWords() {
return (0, _recursePrefix2.default)(trie, '');
var sorted = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
if (typeof sorted !== 'boolean') {
throw 'Expected sort parameter as boolean, received ' + (typeof sorted === 'undefined' ? 'undefined' : _typeof(sorted));
}
return (0, _recursePrefix2.default)(trie, '', sorted);
},

@@ -124,0 +135,0 @@

12

dist/recursePrefix.js

@@ -31,4 +31,4 @@ 'use strict';

function recursePrefix(node, prefix) {
var prefixes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
function recursePrefix(node, prefix, sorted) {
var prefixes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];

@@ -39,6 +39,10 @@ var word = prefix;

if (branch === _config2.default.END_WORD) {
pushInOrder(word, prefixes);
if (sorted) {
pushInOrder(word, prefixes);
} else {
prefixes.push(word);
}
word = '';
}
recursePrefix(node[branch], prefix + branch, prefixes);
recursePrefix(node[branch], prefix + branch, sorted, prefixes);
}

@@ -45,0 +49,0 @@

{
"name": "trie-prefix-tree",
"version": "1.3.1",
"version": "1.4.0",
"description": "Create and modify trie prefix structures, extract word lists including anagrams and sub-anagrams",

@@ -5,0 +5,0 @@ "main": "dist/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