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

persistent-hash-trie

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

persistent-hash-trie - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

2

package.json
{
"name": "persistent-hash-trie",
"description": "Pure string:val storage, using structural sharing",
"version": "0.4.0",
"version": "0.4.1",
"main": "src/persistent-hash-trie.js",

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

@@ -315,25 +315,32 @@ 'use strict';

// given a node, function and seed, reduce to produce results.
lib.reduce = function(node, callback, seed){
try {
return reduce(node, callback, { seed: seed }).seed
} catch(e) {
if ( e instanceof lib.reduce.Break ) return e.value;
else throw e;
}
lib.reduce = function(node, callback, initial){
var state = reduce(node, callback, initial)
return state instanceof Break ? state.value : state
}
var reduce = function(node, callback, state) {
reduceFns[node.type](node, callback, state)
return state
var reduce = function(node, callback, initial) {
return reduceFns[node.type](node, callback, initial)
}
var reduceFns = {
trie: function(node, callback, state){
for ( var path in node.children ) if ( node.children.hasOwnProperty(path) ) reduce(node.children[path], callback, state)
trie: function(node, callback, state) {
for ( var path in node.children ) {
if ( node.children.hasOwnProperty(path) ) {
state = reduce(node.children[path], callback, state)
}
if (state instanceof Break) break
}
return state
},
value: function(node, callback, state){
state.seed = callback(state.seed, node.value, node.key)
return callback(state, node.value, node.key)
},
hashmap: function(node, callback, state){
for ( var key in node.values ) if ( node.values.hasOwnProperty(key) ) reduce(node.values[key], callback, state)
for ( var key in node.values ) {
if ( node.values.hasOwnProperty(key) ) {
state = reduce(node.values[key], callback, state)
}
if (state instanceof Break) break
}
return state
}

@@ -343,3 +350,6 @@ }

lib.reduce.Break = function(v){ this.value = v }
var Break = lib.reduce.Break = function(v) {
if (!(this instanceof Break)) return new Break(v)
this.value = v
}

@@ -346,0 +356,0 @@

@@ -34,3 +34,3 @@ 'use strict';

var iterate = function(){
throw new p.reduce.Break("my-return-value")
return p.reduce.Break("my-return-value")
}

@@ -37,0 +37,0 @@

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