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

mnemonist

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mnemonist - npm Package Compare versions

Comparing version 0.37.0 to 0.38.0

4

CHANGELOG.md
# Changelog
## 0.38.0
* Adding `TrieMap.update` (@wholenews).
## 0.37.0

@@ -4,0 +8,0 @@

4

package.json
{
"name": "mnemonist",
"version": "0.37.0",
"version": "0.38.0",
"description": "Curated collection of data structures for the JavaScript language.",

@@ -81,3 +81,3 @@ "scripts": {

"damerau-levenshtein": "^1.0.6",
"eslint": "^7.3.0",
"eslint": "^7.3.1",
"leven": "^3.1.0",

@@ -84,0 +84,0 @@ "lodash": "^4.17.15",

@@ -16,2 +16,3 @@ /**

set(prefix: K, value: V): this;
update(prefix: K, updateFunction: (oldValue: V | undefined) => V): this
get(prefix: K): V;

@@ -18,0 +19,0 @@ delete(prefix: K): boolean;

@@ -70,2 +70,28 @@ /**

/**
* Method used to update the value of the given prefix in the trie.
*
* @param {string|array} prefix - Prefix to follow.
* @param {(oldValue: any | undefined) => any} updateFunction - Update value visitor callback.
* @return {TrieMap}
*/
TrieMap.prototype.update = function(prefix, updateFunction) {
var node = this.root,
token;
for (var i = 0, l = prefix.length; i < l; i++) {
token = prefix[i];
node = node[token] || (node[token] = {});
}
// Do we need to increase size?
if (!(SENTINEL in node))
this.size++;
node[SENTINEL] = updateFunction(node[SENTINEL]);
return this;
};
/**
* Method used to return the value sitting at the end of the given prefix or

@@ -72,0 +98,0 @@ * undefined if none exist.

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