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

multikey-store

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multikey-store - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

27

lib/MultiKeyStore.js

@@ -85,2 +85,23 @@

MultiKeyStore.prototype.removeItemWithKeyValues = function (keyValues) {
var keyValue;
var entity;
console.log('MultiKeyStore:', '('+this.keyName+')' ,'removeItemWithKeyValues:', keyValues);
keyValue = keyValues[this.keyName];
entity = this.entities[keyValue];
if (!entity) {
return false;
}
if (this.terminus) {
delete this.entities[keyValue];
return true;
} else {
return entity.removeItemWithKeyValues(keyValues);
}
};
//==============================

@@ -112,6 +133,8 @@ // MultiKeyStoreWalker

// advance to next item
this.index += 1;
if (this.index < this.numEntities) {
entityKey = this.entitiesKeys[this.index];
entity = this.entities[entityKey];
this.index += 1;
}

@@ -130,3 +153,3 @@

MultiKeyStoreWalker.prototype.reset = function () {
this.index = 0;
this.index = -1;
this.entitiesKeys = Object.keys(this.entities);

@@ -133,0 +156,0 @@ this.numEntities = this.entitiesKeys.length;

2

package.json
{
"name": "multikey-store",
"version": "0.0.3",
"version": "0.0.4",
"title": "MultiKeyStore",

@@ -5,0 +5,0 @@ "description": "A hierarchical in-memory Store mechanism.",

var MultiKeyStore = require('..');
var i;
var item;
var keyNames;
var keyValues;
var result;
var store;
var walker;
console.log('====== create store =======');
keyNames = ['city', 'name'];
store = new MultiKeyStore(keyNames);
var store = new MultiKeyStore(keyNames);
console.log('====== add items =======');
console.log('\n====== add items =======');
var item = {
item = {
name: 'bob'

@@ -42,4 +51,4 @@ , city: 'nyc'

var walker = store.getWalker();
var i = 0;
walker = store.getWalker();
i = 0;
while (item = walker.getNextItem()) {

@@ -55,3 +64,2 @@ console.log(i, item);

var keyValues;
keyValues = {city: 'sf', name: 'sue'};

@@ -68,1 +76,35 @@ item = store.getItemForKeyValues(keyValues);

console.log(keyValues, '==>', item);
console.log('\n====== removeItemWithKeyValues =======');
keyValues = {city: 'sf', name: 'sam'};
result = store.removeItemWithKeyValues(keyValues);
console.log('delete', keyValues, '==>', result);
keyValues = {city: 'sf', name: 'sue'};
result = store.removeItemWithKeyValues(keyValues);
console.log('delete', keyValues, '==>', result);
keyValues = {city: 'sf', name: 'sue'};
item = store.getItemForKeyValues(keyValues);
console.log('get', keyValues, '==>', item);
keyValues = {city: 'nyc', name: 'sam'};
result = store.removeItemWithKeyValues(keyValues);
console.log('delete', keyValues, '==>', result);
keyValues = {city: 'nyc', name: 'bob'};
result = store.removeItemWithKeyValues(keyValues);
console.log('delete', keyValues, '==>', result);
console.log('\n====== walk =======');
walker.reset();
i = 0;
while (item = walker.getNextItem()) {
console.log(i, item);
i += 1;
if (i > 5) {
process.exit();
}
}
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