redis-mock
Advanced tools
Comparing version 0.55.1 to 0.56.0
@@ -25,3 +25,3 @@ const charMap = { | ||
exports.patternToRegex = function(pattern) { | ||
var fixed = pattern.replace(patternChanger, function(matched) { | ||
const fixed = pattern.replace(patternChanger, function(matched) { | ||
return charMap[matched] | ||
@@ -36,7 +36,15 @@ }); | ||
var mockCallback = exports.mockCallback = function(err, reply) {}; //eslint-disable-line no-empty-function | ||
const callCallback = exports.callCallback = (callback, err, result) => { | ||
if (typeof callback === 'function') { | ||
process.nextTick(() => { | ||
callback(err, result); | ||
}); | ||
} | ||
}; | ||
var parseCallback = exports.parseCallback = function(args) { | ||
var callback; | ||
var len = args.length; | ||
exports.noOpCallback = function(err, reply) {}; //eslint-disable-line no-empty-function | ||
exports.parseCallback = function(args) { | ||
let callback; | ||
const len = args.length; | ||
if ('function' === typeof args[len - 1]) { | ||
@@ -48,6 +56,6 @@ callback = args[len-1]; | ||
var validKeyType = exports.validKeyType = function(mockInstance, key, type, callback) { | ||
exports.validKeyType = function(mockInstance, key, type, callback) { | ||
if (mockInstance.storage[key] && mockInstance.storage[key].type !== type) { | ||
var err = new Error('WRONGTYPE Operation against a key holding the wrong kind of value'); | ||
mockInstance._callCallback(callback, err); | ||
const err = new Error('WRONGTYPE Operation against a key holding the wrong kind of value'); | ||
callCallback(callback, err); | ||
return false; | ||
@@ -58,8 +66,8 @@ } | ||
var initKey = exports.initKey = function(mockInstance, key, fn) { | ||
exports.initKey = function(mockInstance, key, fn) { | ||
mockInstance.storage[key] = mockInstance.storage[key] || fn(); | ||
}; | ||
var shuffle = exports.shuffle = function(array) { | ||
var counter = array.length; | ||
exports.shuffle = function(array) { | ||
let counter = array.length; | ||
@@ -69,3 +77,3 @@ // While there are elements in the array | ||
// Pick a random index | ||
var index = Math.floor(Math.random() * counter); | ||
const index = Math.floor(Math.random() * counter); | ||
@@ -76,3 +84,3 @@ // Decrease counter by 1 | ||
// And swap the last element with it | ||
var temp = array[counter]; | ||
const temp = array[counter]; | ||
array[counter] = array[index]; | ||
@@ -79,0 +87,0 @@ array[index] = temp; |
{ | ||
"name": "redis-mock", | ||
"version": "0.55.1", | ||
"version": "0.56.0", | ||
"description": "Redis client mock object for unit testing", | ||
"author": "Kristian Faeldt <kristian.faeldt@gmail.com>", | ||
"main": "./lib/redis-mock", | ||
"main": "./lib/index", | ||
"license": "MIT", | ||
@@ -15,8 +15,8 @@ "repository": { | ||
"mocha": "6.2.3", | ||
"redis": "^3.0.2", | ||
"should": "13.2.3" | ||
"should": "13.2.3", | ||
"redis": "^3.0.2" | ||
}, | ||
"scripts": { | ||
"test": "mocha --timeout 5000", | ||
"test:valid": "VALID_TESTS=true mocha --timeout 5000 --exit", | ||
"test": "mocha --timeout 5000 --recursive", | ||
"test:valid": "VALID_TESTS=true npm run test -- --exit", | ||
"lint": "eslint ./lib ./test" | ||
@@ -23,0 +23,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23
3691
120244
1