How to use the redis-commands.list.forEach function in redis-commands

To help you get started, we’ve selected a few redis-commands examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maxbrieiev / promise-redis / index.js View on Github external
if (typeof args[args.length - 1] === 'function') {
                // Okay. Someone supplied a callback. Most likely some internal
                // node-redis call (ready probe etc.). Oh, as a result of
                // supporting internal callback-style calls, one can now use
                // promise-redis as a dropin replacement for node-redis.
                f.apply(this, args);
            } else {
                return promiseFactory(function (resolve, reject) {
                    args.push(createCb(resolve, reject));
                    f.apply(that, args);
                });
            }
        };
    }

    redisCmds.forEach(function (fullCommand) {
        var cmd = fullCommand.split(' ')[0];

        if (cmd !== 'multi') {
            clproto[cmd] = promisify(clproto[cmd]);
            clproto[cmd.toUpperCase()] = clproto[cmd];
        }

    });

    // For Multi only `exec` command returns promise.
    mlproto.exec_transaction = promisify(mlproto.exec_transaction);
    mlproto.exec = mlproto.exec_transaction;
    mlproto.EXEC = mlproto.exec;

    return redis;
};