initial commit
This commit is contained in:
23
node_modules/@ioredis/commands/LICENSE
generated
vendored
Normal file
23
node_modules/@ioredis/commands/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2022 Zihua Li
|
||||
Copyright (c) 2015 NodeRedis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
43
node_modules/@ioredis/commands/README.md
generated
vendored
Normal file
43
node_modules/@ioredis/commands/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# Redis Commands
|
||||
|
||||
This module exports all the commands that Redis supports.
|
||||
|
||||
## Install
|
||||
|
||||
```shell
|
||||
$ npm install @ioredis/commands
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const commands = require('@ioredis/commands');
|
||||
```
|
||||
|
||||
`.list` is an array contains all the lowercased commands:
|
||||
|
||||
```js
|
||||
commands.list.forEach((command) => {
|
||||
console.log(command);
|
||||
});
|
||||
```
|
||||
|
||||
`.exists()` is used to check if the command exists:
|
||||
|
||||
```js
|
||||
commands.exists('set') // true
|
||||
commands.exists('other-command') // false
|
||||
```
|
||||
|
||||
`.hasFlag()` is used to check if the command has the flag:
|
||||
|
||||
```js
|
||||
commands.hasFlag('set', 'readonly') // false
|
||||
```
|
||||
|
||||
`.getKeyIndexes()` is used to get the indexes of keys in the command arguments:
|
||||
|
||||
```js
|
||||
commands.getKeyIndexes('set', ['key', 'value']) // [0]
|
||||
commands.getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
|
||||
```
|
||||
2447
node_modules/@ioredis/commands/built/commands.json
generated
vendored
Normal file
2447
node_modules/@ioredis/commands/built/commands.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
29
node_modules/@ioredis/commands/built/index.d.ts
generated
vendored
Normal file
29
node_modules/@ioredis/commands/built/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/// <reference types="node" />
|
||||
/**
|
||||
* Redis command list
|
||||
*
|
||||
* All commands are lowercased.
|
||||
*/
|
||||
export declare const list: string[];
|
||||
/**
|
||||
* Check if the command exists
|
||||
*/
|
||||
export declare function exists(commandName: string): boolean;
|
||||
/**
|
||||
* Check if the command has the flag
|
||||
*
|
||||
* Some of possible flags: readonly, noscript, loading
|
||||
*/
|
||||
export declare function hasFlag(commandName: string, flag: string): boolean;
|
||||
/**
|
||||
* Get indexes of keys in the command arguments
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* getKeyIndexes('set', ['key', 'value']) // [0]
|
||||
* getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
|
||||
* ```
|
||||
*/
|
||||
export declare function getKeyIndexes(commandName: string, args: (string | Buffer | number)[], options?: {
|
||||
parseExternalKey: boolean;
|
||||
}): number[];
|
||||
208
node_modules/@ioredis/commands/built/index.js
generated
vendored
Normal file
208
node_modules/@ioredis/commands/built/index.js
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getKeyIndexes = exports.hasFlag = exports.exists = exports.list = void 0;
|
||||
const commands_json_1 = __importDefault(require("./commands.json"));
|
||||
/**
|
||||
* Redis command list
|
||||
*
|
||||
* All commands are lowercased.
|
||||
*/
|
||||
exports.list = Object.keys(commands_json_1.default);
|
||||
const flags = {};
|
||||
exports.list.forEach((commandName) => {
|
||||
flags[commandName] = commands_json_1.default[commandName].flags.reduce(function (flags, flag) {
|
||||
flags[flag] = true;
|
||||
return flags;
|
||||
}, {});
|
||||
});
|
||||
/**
|
||||
* Check if the command exists
|
||||
*/
|
||||
function exists(commandName) {
|
||||
return Boolean(commands_json_1.default[commandName]);
|
||||
}
|
||||
exports.exists = exists;
|
||||
/**
|
||||
* Check if the command has the flag
|
||||
*
|
||||
* Some of possible flags: readonly, noscript, loading
|
||||
*/
|
||||
function hasFlag(commandName, flag) {
|
||||
if (!flags[commandName]) {
|
||||
throw new Error("Unknown command " + commandName);
|
||||
}
|
||||
return Boolean(flags[commandName][flag]);
|
||||
}
|
||||
exports.hasFlag = hasFlag;
|
||||
/**
|
||||
* Get indexes of keys in the command arguments
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* getKeyIndexes('set', ['key', 'value']) // [0]
|
||||
* getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
|
||||
* ```
|
||||
*/
|
||||
function getKeyIndexes(commandName, args, options) {
|
||||
const command = commands_json_1.default[commandName];
|
||||
if (!command) {
|
||||
throw new Error("Unknown command " + commandName);
|
||||
}
|
||||
if (!Array.isArray(args)) {
|
||||
throw new Error("Expect args to be an array");
|
||||
}
|
||||
const keys = [];
|
||||
const parseExternalKey = Boolean(options && options.parseExternalKey);
|
||||
const takeDynamicKeys = (args, startIndex) => {
|
||||
const keys = [];
|
||||
const keyStop = Number(args[startIndex]);
|
||||
for (let i = 0; i < keyStop; i++) {
|
||||
keys.push(i + startIndex + 1);
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
const takeKeyAfterToken = (args, startIndex, token) => {
|
||||
for (let i = startIndex; i < args.length - 1; i += 1) {
|
||||
if (String(args[i]).toLowerCase() === token.toLowerCase()) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
switch (commandName) {
|
||||
case "zunionstore":
|
||||
case "zinterstore":
|
||||
case "zdiffstore":
|
||||
keys.push(0, ...takeDynamicKeys(args, 1));
|
||||
break;
|
||||
case "eval":
|
||||
case "evalsha":
|
||||
case "eval_ro":
|
||||
case "evalsha_ro":
|
||||
case "fcall":
|
||||
case "fcall_ro":
|
||||
case "blmpop":
|
||||
case "bzmpop":
|
||||
keys.push(...takeDynamicKeys(args, 1));
|
||||
break;
|
||||
case "sintercard":
|
||||
case "lmpop":
|
||||
case "zunion":
|
||||
case "zinter":
|
||||
case "zmpop":
|
||||
case "zintercard":
|
||||
case "zdiff": {
|
||||
keys.push(...takeDynamicKeys(args, 0));
|
||||
break;
|
||||
}
|
||||
case "georadius": {
|
||||
keys.push(0);
|
||||
const storeKey = takeKeyAfterToken(args, 5, "STORE");
|
||||
if (storeKey)
|
||||
keys.push(storeKey);
|
||||
const distKey = takeKeyAfterToken(args, 5, "STOREDIST");
|
||||
if (distKey)
|
||||
keys.push(distKey);
|
||||
break;
|
||||
}
|
||||
case "georadiusbymember": {
|
||||
keys.push(0);
|
||||
const storeKey = takeKeyAfterToken(args, 4, "STORE");
|
||||
if (storeKey)
|
||||
keys.push(storeKey);
|
||||
const distKey = takeKeyAfterToken(args, 4, "STOREDIST");
|
||||
if (distKey)
|
||||
keys.push(distKey);
|
||||
break;
|
||||
}
|
||||
case "sort":
|
||||
case "sort_ro":
|
||||
keys.push(0);
|
||||
for (let i = 1; i < args.length - 1; i++) {
|
||||
let arg = args[i];
|
||||
if (typeof arg !== "string") {
|
||||
continue;
|
||||
}
|
||||
const directive = arg.toUpperCase();
|
||||
if (directive === "GET") {
|
||||
i += 1;
|
||||
arg = args[i];
|
||||
if (arg !== "#") {
|
||||
if (parseExternalKey) {
|
||||
keys.push([i, getExternalKeyNameLength(arg)]);
|
||||
}
|
||||
else {
|
||||
keys.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (directive === "BY") {
|
||||
i += 1;
|
||||
if (parseExternalKey) {
|
||||
keys.push([i, getExternalKeyNameLength(args[i])]);
|
||||
}
|
||||
else {
|
||||
keys.push(i);
|
||||
}
|
||||
}
|
||||
else if (directive === "STORE") {
|
||||
i += 1;
|
||||
keys.push(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "migrate":
|
||||
if (args[2] === "") {
|
||||
for (let i = 5; i < args.length - 1; i++) {
|
||||
const arg = args[i];
|
||||
if (typeof arg === "string" && arg.toUpperCase() === "KEYS") {
|
||||
for (let j = i + 1; j < args.length; j++) {
|
||||
keys.push(j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
keys.push(2);
|
||||
}
|
||||
break;
|
||||
case "xreadgroup":
|
||||
case "xread":
|
||||
// Keys are 1st half of the args after STREAMS argument.
|
||||
for (let i = commandName === "xread" ? 0 : 3; i < args.length - 1; i++) {
|
||||
if (String(args[i]).toUpperCase() === "STREAMS") {
|
||||
for (let j = i + 1; j <= i + (args.length - 1 - i) / 2; j++) {
|
||||
keys.push(j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Step has to be at least one in this case, otherwise the command does
|
||||
// not contain a key.
|
||||
if (command.step > 0) {
|
||||
const keyStart = command.keyStart - 1;
|
||||
const keyStop = command.keyStop > 0
|
||||
? command.keyStop
|
||||
: args.length + command.keyStop + 1;
|
||||
for (let i = keyStart; i < keyStop; i += command.step) {
|
||||
keys.push(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
exports.getKeyIndexes = getKeyIndexes;
|
||||
function getExternalKeyNameLength(key) {
|
||||
if (typeof key !== "string") {
|
||||
key = String(key);
|
||||
}
|
||||
const hashPos = key.indexOf("->");
|
||||
return hashPos === -1 ? key.length : hashPos;
|
||||
}
|
||||
52
node_modules/@ioredis/commands/package.json
generated
vendored
Normal file
52
node_modules/@ioredis/commands/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "@ioredis/commands",
|
||||
"version": "1.2.0",
|
||||
"description": "Redis commands",
|
||||
"main": "built/index.js",
|
||||
"files": [
|
||||
"built/",
|
||||
"commands.json"
|
||||
],
|
||||
"scripts": {
|
||||
"pretest": "npm run lint",
|
||||
"test": "mocha",
|
||||
"build": "rm -rf built && tsc",
|
||||
"gen": "node tools/build",
|
||||
"lint": "standard --fix --verbose | snazzy",
|
||||
"release": "release-it"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ioredis/commands.git"
|
||||
},
|
||||
"keywords": [
|
||||
"redis",
|
||||
"commands",
|
||||
"prefix"
|
||||
],
|
||||
"author": "Zihua Li <i@zihua.li> (http://zihua.li)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ioredis/commands/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ioredis/commands",
|
||||
"devDependencies": {
|
||||
"@release-it/conventional-changelog": "^4.2.0",
|
||||
"@semantic-release/changelog": "^6.0.1",
|
||||
"@semantic-release/commit-analyzer": "^9.0.2",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"chai": "^4.3.6",
|
||||
"ioredis": "^5.0.6",
|
||||
"mocha": "^9.2.1",
|
||||
"release-it": "^14.12.5",
|
||||
"safe-stable-stringify": "^2.3.1",
|
||||
"semantic-release": "^19.0.2",
|
||||
"snazzy": "^9.0.0",
|
||||
"standard": "^16.0.4",
|
||||
"typescript": "^4.6.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user