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

imapper-storage-memory

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

imapper-storage-memory - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

81

lib/storage.js

@@ -95,5 +95,6 @@ /*jslint node:true */

if (inRange(isUid ? uid : i + 1, rangeParts, isUid ? maxUid : totalMessages)) {
result.push([i + 1, messages[i]]);
result.push(_.extend({index: i+1},messages[i]));
}
}
result.push(null);
return result;

@@ -180,10 +181,6 @@ },

"index": function (value) {
return getMessageRange(messageSource, value, false).map(function(item) {
return item[1];
});
return _.without(getMessageRange(messageSource, value, false),null);
},
"uid": function (value) {
return getMessageRange(messageSource, value, true).map(function(item) {
return item[1];
});
return _.without(getMessageRange(messageSource, value, true),null);
},

@@ -347,6 +344,6 @@ "headers": function (value) {

// build the indexCache
totalResults = _.uniq(totalResults);
totalResults = _.map(totalResults,"uid");
indexCache = _.reduce(messageSource,function (total,message,i) {
if (_.includes(totalResults,message)) {
total.push({uid:message.uid,index:i+1});
if (_.includes(totalResults,message.uid)) {
total.push({uid:message.uid,index: i+1});
}

@@ -807,5 +804,6 @@ return total;

// make sure that the messages exist
if (!messages || messages.length <= 0) {
if (!messages || messages.length <= 0 || messages[0] === null) {
return cb("Invalid messages");
}
messages = _.without(messages,null);
_.each(messages,function (message) {

@@ -819,7 +817,7 @@ [].concat(flags).forEach(function(flag) {

if (message[1].flags.indexOf(flag) < 0) {
message[1].flags.push(flag);
if (message.flags.indexOf(flag) < 0) {
message.flags.push(flag);
}
});
ret.push({index: message[0], uid: message[1].uid, flags: message[1].flags});
ret.push({index: message.index, uid: message.uid, flags: message.flags});
});

@@ -835,12 +833,13 @@ cb(null,ret);

// make sure that the messages exist
if (!messages || messages.length <= 0) {
if (!messages || messages.length <= 0 || messages[0] === null) {
return cb("Invalid messages");
}
messages = _.without(messages,null);
_.each(messages,function (message) {
[].concat(flags).forEach(function(flag) {
if (message[1].flags.indexOf(flag) >= 0) {
for (var i = 0; i < message[1].flags.length; i++) {
if (message[1].flags[i] === flag) {
message[1].flags.splice(i, 1);
if (message.flags.indexOf(flag) >= 0) {
for (var i = 0; i < message.flags.length; i++) {
if (message.flags[i] === flag) {
message.flags.splice(i, 1);
break;

@@ -851,3 +850,3 @@ }

});
ret.push({index: message[0], uid: message[1].uid, flags: message[1].flags});
ret.push({index: message.index, uid: message.uid, flags: message.flags});
});

@@ -866,5 +865,6 @@ cb(null,ret);

// make sure that the messages exist
if (!messages || messages.length <= 0) {
if (!messages || messages.length <= 0 || messages[0] === null) {
return cb("Invalid messages");
}
messages = _.without(messages,null);
_.each(messages,function (message) {

@@ -883,4 +883,4 @@ var messageFlags = [];

});
message[1].flags = messageFlags;
ret.push({index: message[0], uid: message[1].uid, flags: message[1].flags});
message.flags = messageFlags;
ret.push({index: message.index, uid: message.uid, flags: message.flags});
});

@@ -897,18 +897,19 @@ cb(null, ret);

// make sure that the messages exist
if (!messages || messages.length <= 0) {
if (!messages || messages.length <= 0 || messages[0] === null) {
return cb("Invalid messages");
}
messages = _.without(messages,null);
_.each(messages,function (message) {
_.each(properties,function (value,key) {
if (!message[1].properties[key]) {
message[1].properties[key] = value;
} else if (_.isArray(message[1].properties[key])) {
message[1].properties[key] = message[1].properties[key].concat(value||[]);
} else if (typeof(message[1].properties[key]) === "string") {
message[1].properties[key] = [].concat(message[1].properties[key],value||[]);
if (!message.properties[key]) {
message.properties[key] = value;
} else if (_.isArray(message.properties[key])) {
message.properties[key] = message.properties[key].concat(value||[]);
} else if (typeof(message.properties[key]) === "string") {
message.properties[key] = [].concat(message.properties[key],value||[]);
} else {
message[1].properties[key] = value;
message.properties[key] = value;
}
});
ret.push({index: message[0], uid: message[1].uid, properties: message[1].properties});
ret.push({index: message.index, uid: message.uid, properties: message.properties});
});

@@ -924,12 +925,13 @@ cb(null,ret);

// make sure that the messages exist
if (!messages || messages.length <= 0) {
if (!messages || messages.length <= 0 || messages[0] === null) {
return cb("Invalid messages");
}
messages = _.without(messages,null);
_.each(messages,function (message) {
_.each(properties,function (value,key) {
message[1].properties[key] = _.reduce([].concat(value||[]),function (list,toRemove) {
message.properties[key] = _.reduce([].concat(value||[]),function (list,toRemove) {
return _.without(list,toRemove);
},message[1].properties[key] || []);
},message.properties[key] || []);
});
ret.push({index: message[0], uid: message[1].uid, properties: message[1].properties});
ret.push({index: message.index, uid: message.uid, properties: message.properties});
});

@@ -948,10 +950,11 @@ cb(null,ret);

// make sure that the messages exist
if (!messages || messages.length <= 0) {
if (!messages || messages.length <= 0 || messages[0] === null) {
return cb("Invalid messages");
}
messages = _.without(messages,null);
_.each(messages,function (message) {
_.each(properties,function (value,key) {
message[1].properties[key] = value;
message.properties[key] = value;
});
ret.push({index: message[0], uid: message[1].uid, properties: message[1].properties});
ret.push({index: message.index, uid: message.uid, properties: message.properties});
});

@@ -958,0 +961,0 @@ cb(null,ret);

{
"name": "imapper-storage-memory",
"version": "0.4.0",
"version": "0.5.0",
"description": "Memory storage plugin for Imapper https://github.com/deitch/imapper",

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