Skip to content

Commit

Permalink
Merge pull request #14 from moaxaca/develop
Browse files Browse the repository at this point in the history
Release/v1.1.5
  • Loading branch information
moaxaca authored Jan 14, 2019
2 parents e02adc7 + c9bbb0e commit e9ca5d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": false,
"version": "1.1.4",
"version": "1.1.5",
"name": "async-redis",
"keywords": [
"redis",
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ const AsyncRedis = function (args) {

AsyncRedis.createClient = (...args) => new AsyncRedis(args);

// this is the set of commands to NOT promisify
const commandsToSkipSet = new Set(['multi']);
// this is the set of commands to promisify
const commandSet = new Set(commands.filter(c => !commandsToSkipSet.has(c)));

AsyncRedis.decorate = redisClient => objectDecorator(redisClient, (name, method) => {
if (commands.includes(name)) {
if (commandSet.has(name)) {
return (...args) => new Promise((resolve, reject) => {
args.push((error, ...results) => {
if (error) {
Expand Down
8 changes: 8 additions & 0 deletions test/integration/commands/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ describe('Commands - Common', function () {
assert.isRejected(promise, Error);
});
});

describe('test multi not a promise', function () {
it('should be not equal', async () => {
let notAPromise = redisClient.multi();
console.log(notAPromise);
assert.notEqual(Promise.resolve(notAPromise), notAPromise);
});
});
});

0 comments on commit e9ca5d4

Please sign in to comment.