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

lru-cache-for-clusters-as-promised

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lru-cache-for-clusters-as-promised - npm Package Compare versions

Comparing version 1.5.9 to 1.5.10

5

CHANGELOG.md

@@ -0,1 +1,6 @@

1.5.10 / 2017-05-07
==================
* Deduplicate common methods - fixes CodeClimate rating to 4.0
1.5.9 / 2017-05-06

@@ -2,0 +7,0 @@ ==================

62

lru-cache-for-clusters-as-promised.js

@@ -52,2 +52,26 @@ /**

const funcs = {
mapObjects: (pairs, objs, jsonFunction) =>
Promise.all(
Object.keys(pairs).map((key) => Promise.resolve((objs[key] = JSON[jsonFunction](pairs[key]))))
),
mDel: (lru, params) => {
if (params[0] && params[0] instanceof Array) {
params[0].map((key) => lru.del(key));
}
},
mGet: (lru, params) => {
const mGetValues = {};
if (params[0] && params[0] instanceof Array) {
params[0].map((key) => (mGetValues[key] = lru.get(key)));
}
return mGetValues;
},
mSet: (lru, params) => {
if (params[0] && params[0] instanceof Object) {
Object.keys(params[0]).map((key) => lru.set(key, params[0][key], params[1]));
}
},
};
// only run on the master thread

@@ -141,6 +165,3 @@ if (cluster.isMaster) {

case 'mGet': {
const mGetValues = {};
if (params[0] && params[0] instanceof Array) {
params[0].map((key) => (mGetValues[key] = lru.get(key)));
}
const mGetValues = funcs.mGet(lru, params);
sendResponse({ value: mGetValues });

@@ -150,5 +171,3 @@ break;

case 'mSet': {
if (params[0] && params[0] instanceof Object) {
Object.keys(params[0]).map((key) => lru.set(key, params[0][key], params[1]));
}
funcs.mSet(lru, params);
sendResponse({ value: true });

@@ -158,5 +177,3 @@ break;

case 'mDel': {
if (params[0] && params[0] instanceof Array) {
params[0].map((key) => lru.del(key));
}
funcs.mDel(lru, params);
sendResponse({ value: true });

@@ -272,18 +289,11 @@ break;

case 'mGet': {
const mGetValues = {};
if (funcArgs[0] && funcArgs[0] instanceof Array) {
funcArgs[0].map((key) => (mGetValues[key] = lru.get(key)));
}
const mGetValues = funcs.mGet(lru, funcArgs);
return Promise.resolve(mGetValues);
}
case 'mSet': {
if (funcArgs[0] && funcArgs[0] instanceof Object) {
Object.keys(funcArgs[0]).map((key) => lru.set(key, funcArgs[0][key], funcArgs[1]));
}
funcs.mSet(lru, funcArgs);
return Promise.resolve(true);
}
case 'mDel': {
if (funcArgs[0] && funcArgs[0] instanceof Array) {
funcArgs[0].map((key) => lru.del(key));
}
funcs.mDel(lru, funcArgs);
return Promise.resolve(true);

@@ -355,11 +365,11 @@ }

const objs = {};
return Promise.all(
Object.keys(pairs).map((key) => Promise.resolve((objs[key] = JSON.parse(pairs[key]))))
).then(() => Promise.resolve(objs));
return funcs
.mapObjects(pairs, objs, 'parse')
.then(() => Promise.resolve(objs));
}),
mSetObjects: (pairs, maxAge) => {
const objs = {};
return Promise.all(
Object.keys(pairs).map((key) => Promise.resolve((objs[key] = JSON.stringify(pairs[key]))))
).then(() => promiseTo('mSet', objs, maxAge));
return funcs
.mapObjects(pairs, objs, 'stringify')
.then(() => promiseTo('mSet', objs, maxAge));
},

@@ -366,0 +376,0 @@ mDel: (keys) => promiseTo('mDel', keys),

{
"name": "lru-cache-for-clusters-as-promised",
"version": "1.5.9",
"version": "1.5.10",
"description": "LRU Cache that is safe for clusters",

@@ -5,0 +5,0 @@ "main": "./lru-cache-for-clusters-as-promised.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