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

ioredis-mock

Package Overview
Dependencies
Maintainers
1
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ioredis-mock - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

lib/buffer.js

14

CHANGELOG.md

@@ -8,2 +8,11 @@ # ioredis-mock change log

## [2.4.0] - 2017-03-05
### Features
* `exec` supports a callback argument. (#290)
### Fixes
* Don't modify objects passed to or returned from the internal datastore. (#281 @jeffkenney)
* Fix hash get commands for missing hashes. (#284 @jeffkenney)
## [2.3.0] - 2017-02-28

@@ -19,3 +28,3 @@

### Misc
* updated all dependencies to latest stable versions (@greenkeeperio-bot)
* updated all dependencies to latest stable versions. (@greenkeeperio-bot)

@@ -322,3 +331,4 @@ ## [2.2.0] - 2016-10-31

[Unreleased]: https://github.com/stipsan/ioredis-mock/compare/v2.3.0...HEAD
[Unreleased]: https://github.com/stipsan/ioredis-mock/compare/v2.4.0...HEAD
[v2.4.0]: https://github.com/stipsan/ioredis-mock/compare/v2.3.0...v2.4.0
[2.3.0]: https://github.com/stipsan/ioredis-mock/compare/v2.2.0...v2.3.0

@@ -325,0 +335,0 @@ [2.2.0]: https://github.com/stipsan/ioredis-mock/compare/v2.1.0...v2.2.0

10

lib/commands/hdel.js

@@ -8,3 +8,3 @@ "use strict";

function hdel(key) {
var _this = this;
var value = this.data.get(key);

@@ -15,5 +15,5 @@ for (var _len = arguments.length, fields = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

return fields.filter(function (field) {
if ({}.hasOwnProperty.call(_this.data.get(key), field)) {
delete _this.data.get(key)[field];
var numDeleted = fields.filter(function (field) {
if ({}.hasOwnProperty.call(value, field)) {
delete value[field];
return true;

@@ -23,2 +23,4 @@ }

}).length;
this.data.set(key, value);
return numDeleted;
}

@@ -8,3 +8,9 @@ "use strict";

function hget(key, hashKey) {
return this.data.get(key)[hashKey];
var hash = this.data.get(key);
if (!hash || hash[hashKey] === undefined) {
return null;
}
return hash[hashKey];
}

@@ -8,3 +8,3 @@ "use strict";

function hgetall(key) {
return this.data.get(key);
return this.data.get(key) || {};
}

@@ -16,9 +16,12 @@ 'use strict';

}
if (!{}.hasOwnProperty.call(this.data.get(key), field)) {
this.data.get(key)[field] = '0';
var hash = this.data.get(key);
if (!{}.hasOwnProperty.call(hash, field)) {
hash[field] = '0';
}
var curVal = Number(this.data.get(key)[field]);
var curVal = Number(hash[field]);
var nextVal = curVal + parseInt(increment, 10);
this.data.get(key)[field] = nextVal.toString();
hash[field] = nextVal.toString();
this.data.set(key, hash);
return nextVal;
}

@@ -14,8 +14,10 @@ 'use strict';

}
if (!{}.hasOwnProperty.call(this.data.get(key), field)) {
this.data.get(key)[field] = '0';
var hash = this.data.get(key);
if (!{}.hasOwnProperty.call(hash, field)) {
hash[field] = '0';
}
var curVal = parseFloat(this.data.get(key)[field]);
this.data.get(key)[field] = (curVal + parseFloat(increment)).toString();
return this.data.get(key)[field];
var curVal = parseFloat(hash[field]);
hash[field] = (curVal + parseFloat(increment)).toString();
this.data.set(key, hash);
return hash[field];
}

@@ -8,3 +8,3 @@ "use strict";

function hmget(key) {
var _this = this;
var hash = this.data.get(key);

@@ -16,4 +16,7 @@ for (var _len = arguments.length, fields = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

return fields.map(function (field) {
return _this.data.get(key)[field] || null;
if (!hash || hash[field] === undefined) {
return null;
}
return hash[field];
});
}

@@ -12,2 +12,4 @@ 'use strict';

var hash = this.data.get(key);
for (var _len = arguments.length, hmsetData = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {

@@ -18,6 +20,8 @@ hmsetData[_key - 1] = arguments[_key];

for (var i = 0; i < hmsetData.length; i += 2) {
this.data.get(key)[hmsetData[i]] = hmsetData[i + 1];
hash[hmsetData[i]] = hmsetData[i + 1];
}
this.data.set(key, hash);
return 'OK';
}

@@ -21,3 +21,5 @@ "use strict";

this.data.set(key, hash);
return reply;
}

@@ -13,3 +13,5 @@ "use strict";

if (!{}.hasOwnProperty.call(this.data.get(key), hashKey)) {
this.data.get(key)[hashKey] = hashVal;
var hash = this.data.get(key);
hash[hashKey] = hashVal;
this.data.set(key, hash);

@@ -16,0 +18,0 @@ return 1;

@@ -13,3 +13,7 @@ "use strict";

return list.length > 0 ? list.shift() : null;
var item = list.length > 0 ? list.shift() : null;
this.data.set(key, list);
return item;
}

@@ -19,3 +19,5 @@ 'use strict';

list[index < 0 ? list.length + index : index] = value;
this.data.set(key, list);
return 'OK';
}

@@ -13,3 +13,7 @@ "use strict";

return list.length > 0 ? list.pop() : null;
var item = list.length > 0 ? list.pop() : null;
this.data.set(key, list);
return item;
}

@@ -23,6 +23,12 @@ "use strict";

var item = this.data.get(source).pop();
this.data.get(destination).unshift(item);
var newSource = this.data.get(source);
var item = newSource.pop();
var newDest = this.data.get(destination);
newDest.unshift(item);
this.data.set(source, newSource);
this.data.set(destination, newDest);
return item;
}

@@ -31,3 +31,4 @@ 'use strict';

});
this.data.set(key, set);
return added;
}

@@ -32,2 +32,3 @@ 'use strict';

sourceSet.delete(member);
this.data.set(source, sourceSet);

@@ -38,5 +39,7 @@ if (!this.data.has(destination)) {

this.data.get(destination).add(member);
var destSet = this.data.get(destination);
destSet.add(member);
this.data.set(destination, destSet);
return 1;
}

@@ -21,3 +21,4 @@ "use strict";

});
this.data.set(key, set);
return removed;
}

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -6,3 +6,15 @@ Object.defineProperty(exports, "__esModule", {

});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.default = createData;
var _lodash = require('lodash');
var _buffer = require('./buffer');
var _buffer2 = _interopRequireDefault(_buffer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function createData(expires) {

@@ -28,3 +40,21 @@ var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

return raw[key];
var value = raw[key];
if (Array.isArray(value)) {
return value.slice();
}
if (Buffer.isBuffer(value)) {
return (0, _buffer2.default)(value);
}
if (value instanceof Set) {
return new Set(value);
}
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value) {
return (0, _lodash.assign)({}, value);
}
return value;
},

@@ -42,3 +72,15 @@ has: function has(key) {

set: function set(key, val) {
raw[key] = val;
var item = val;
if (Array.isArray(val)) {
item = val.slice();
} else if (Buffer.isBuffer(val)) {
item = (0, _buffer2.default)(val);
} else if (val instanceof Set) {
item = new Set(val);
} else if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object' && val) {
item = (0, _lodash.assign)({}, val);
}
raw[key] = item;
}

@@ -45,0 +87,0 @@ });

@@ -13,2 +13,6 @@ 'use strict';

var _bluebird = require('bluebird');
var _bluebird2 = _interopRequireDefault(_bluebird);
var _commands = require('./commands');

@@ -93,4 +97,4 @@

key: 'exec',
value: function exec() {
return Promise.all(this.batch.map(function (promise) {
value: function exec(callback) {
return _bluebird2.default.all(this.batch.map(function (promise) {
return promise();

@@ -101,3 +105,3 @@ })).then(function (results) {

});
});
}).nodeify(callback);
}

@@ -104,0 +108,0 @@ }]);

{
"name": "ioredis-mock",
"version": "2.3.0",
"version": "2.4.0",
"description": "This library emulates ioredis by performing all operations in-memory.",

@@ -60,4 +60,4 @@ "main": "./lib",

"coveralls": "2.11.16",
"eslint": "3.16.1",
"eslint-config-airbnb-base": "11.1.0",
"eslint": "3.17.0",
"eslint-config-airbnb-base": "11.1.1",
"eslint-plugin-import": "2.2.0",

@@ -75,3 +75,3 @@ "expect": "1.20.2",

"array-from": "^2.1.1",
"bluebird": "3.4.7",
"bluebird": "3.5.0",
"es6-set": "^0.1.4",

@@ -78,0 +78,0 @@ "lodash": "4.17.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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