Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
});