Registry / database / redis-commands

redis-commands

JSON →
library1.7.0jsnpmunverified

This package provides a comprehensive list of all Redis commands, their flags, and utility functions. Version 1.7.0 is stable and maintained as part of the NodeRedis ecosystem. It exports an array of all lowercased command names, a function to check command existence, a function to test for specific flags (e.g., 'readonly'), and a function to extract key indexes from command arguments. It is commonly used internally by Redis clients like node_redis to validate commands and parse key positions. The package is lightweight, has no runtime dependencies, and is primarily used in Node.js environments.

npm install redis-commands
INSTALL
IMPORT
SIG · REDIS-COMMANDS
R
redis-commands
databasejavascriptv1.7.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

list
const { list } = require('redis-commands');
import { list } from 'redis-commands';
Package is CommonJS-only, no ESM support. Use require().
exists
const { exists } = require('redis-commands');
const exists = require('redis-commands').exists;
Both patterns work, but destructuring is preferred.
hasFlag
const { hasFlag } = require('redis-commands');
const hasFlag = require('redis-commands').hasFlag;
Same as exists.
getKeyIndexes
const { getKeyIndexes } = require('redis-commands');
const getKeyIndexes = require('redis-commands').getKeyIndexes;
Same as exists.

Imports and demonstrates all four exported functions: list, exists, hasFlag, getKeyIndexes.

const { list, exists, hasFlag, getKeyIndexes } = require('redis-commands'); // List all commands console.log(list.length); // 200+ commands // Check if command exists console.log(exists('set')); // true console.log(exists('custom-command')); // false // Check flags console.log(hasFlag('set', 'readonly')); // false console.log(hasFlag('get', 'readonly')); // true // Get key indexes getKeyIndexes('set', ['key', 'value']); // [0] getKeyIndexes('mget', ['key1', 'key2']); // [0, 1] getKeyIndexes('hset', ['hash', 'field', 'value']); // [0]
Debug
Known issues
gotchaThe package does not expose a default export; attempting import * will fail.
fix
Use named exports with require or destructure.
affects: >=0.0.1
gotchaFunction arguments must be lowercase command names; passing uppercase will return false.
fix
Always lowercase command names: commands.exists('SET') returns false.
affects: >=0.0.1
gotchaThe list may not include Redis modules or custom commands added via Redis modules.
fix
Check the Redis server's command table if using modules.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: commands.list is not iterable
Using import { list } from 'redis-commands' in an ESM context.
fix
Use require('redis-commands') and destructure.
ReferenceError: commands is not defined
Forgetting to require the package.
fix
Add const commands = require('redis-commands'); or destructure.
Upgrade
Version history
1.7.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
redis-commands — npm install redis-commands · libregistry