Comparing version 0.0.3 to 1.0.0
71
index.js
@@ -1,15 +0,60 @@ | ||
module.exports = function (redisClient) { | ||
var exports = {}; | ||
require('./commands').forEach(function (command) { | ||
var commandLower = command.toLowerCase(); | ||
exports[command] = function () { | ||
var args = Array.prototype.slice.call(arguments); | ||
return function (done) { | ||
args.push(done); | ||
return redisClient[command].apply(redisClient, args); | ||
} | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var thunkify = require('thunkify'); | ||
/** | ||
* List of API functions that do not take a callback as an argument | ||
* since they are not redis commands. | ||
* | ||
* @constant | ||
* @type {Array} | ||
*/ | ||
var API_FUNCTIONS = ['end', 'unref']; | ||
/** | ||
* Wrap `client`. | ||
* | ||
* @param {Redis} client | ||
* @return {Object} | ||
*/ | ||
module.exports = function (client) { | ||
var wrap = {}; | ||
wrap.multi = function () { | ||
var multi = client.multi(); | ||
multi.exec = thunkify(multi.exec); | ||
return multi; | ||
}; | ||
Object.keys(client).forEach(function (key) { | ||
wrap[key] = client[key]; | ||
}); | ||
Object.defineProperty(wrap, 'connected', { | ||
get: function () { return client.connected } | ||
}); | ||
Object.defineProperty(wrap, 'retry_delay', { | ||
get: function () { return client.retry_delay } | ||
}); | ||
Object.defineProperty(wrap, 'retry_backoff', { | ||
get: function () { return client.retry_backoff } | ||
}); | ||
Object.keys(Object.getPrototypeOf(client)).forEach(function (key) { | ||
var protoFunction = client[key].bind(client); | ||
var isCommand = API_FUNCTIONS.indexOf(key) === -1; | ||
var isMulti = key == 'multi'; | ||
if (isMulti) return; | ||
if (isCommand) { | ||
protoFunction = thunkify(protoFunction); | ||
} | ||
exports[commandLower] = exports[command]; | ||
wrap[key] = protoFunction; | ||
}); | ||
return exports; | ||
}; | ||
return wrap; | ||
}; |
{ | ||
"name": "co-redis", | ||
"description": "A node-redis wrapper to be used with visionmedia's co library", | ||
"version": "0.0.3", | ||
"version": "1.0.0", | ||
"author": { | ||
@@ -30,3 +30,3 @@ "name": "Martín Ciparelli", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha --harmony-generators" | ||
}, | ||
@@ -38,6 +38,9 @@ "engines": { | ||
"devDependencies": { | ||
"co": "1.5.2", | ||
"redis": "0.8.4", | ||
"request": "2.20.0" | ||
"co": "~3.0.2", | ||
"redis": "~0.10.0", | ||
"mocha": "~1.16.2" | ||
}, | ||
"dependencies": { | ||
"thunkify": "0.0.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
0
4836
1
5
48
1
+ Addedthunkify@0.0.1
+ Addedthunkify@0.0.1(transitive)