Review funkt

This commit is contained in:
2026-08-09 21:56:00 +00:00
parent f522ae9953
commit fe9dfa4519
11366 changed files with 2335077 additions and 97 deletions

50
node_modules/ioredis/built/utils/Commander.d.ts generated vendored Normal file
View File

@@ -0,0 +1,50 @@
import Command from "../Command";
import { WriteableStream } from "../types";
import RedisCommander, { ClientContext } from "./RedisCommander";
export interface CommanderOptions {
keyPrefix?: string | undefined;
showFriendlyErrorStack?: boolean | undefined;
}
declare class Commander<Context extends ClientContext = {
type: "default";
}> {
options: CommanderOptions;
/**
* @ignore
*/
scriptsSet: {};
/**
* @ignore
*/
addedBuiltinSet: Set<string>;
/**
* Return supported builtin commands
*/
getBuiltinCommands(): string[];
/**
* Create a builtin command
*/
createBuiltinCommand(commandName: string): {
string: any;
buffer: any;
};
/**
* Create add builtin command
*/
addBuiltinCommand(commandName: string): void;
/**
* Define a custom command using lua script
*/
defineCommand(name: string, definition: {
lua: string;
numberOfKeys?: number;
readOnly?: boolean;
}): void;
/**
* @ignore
*/
sendCommand(command: Command, stream?: WriteableStream, node?: unknown): unknown;
}
interface Commander<Context> extends RedisCommander<Context> {
}
export default Commander;

117
node_modules/ioredis/built/utils/Commander.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commands_1 = require("@ioredis/commands");
const autoPipelining_1 = require("../autoPipelining");
const Command_1 = require("../Command");
const Script_1 = require("../Script");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
class Commander {
constructor() {
this.options = {};
/**
* @ignore
*/
this.scriptsSet = {};
/**
* @ignore
*/
this.addedBuiltinSet = new Set();
}
/**
* Return supported builtin commands
*/
getBuiltinCommands() {
return commands.slice(0);
}
/**
* Create a builtin command
*/
createBuiltinCommand(commandName) {
return {
string: generateFunction(null, commandName, "utf8"),
buffer: generateFunction(null, commandName, null),
};
}
/**
* Create add builtin command
*/
addBuiltinCommand(commandName) {
this.addedBuiltinSet.add(commandName);
this[commandName] = generateFunction(commandName, commandName, "utf8");
this[commandName + "Buffer"] = generateFunction(commandName + "Buffer", commandName, null);
}
/**
* Define a custom command using lua script
*/
defineCommand(name, definition) {
const script = new Script_1.default(definition.lua, definition.numberOfKeys, this.options.keyPrefix, definition.readOnly);
this.scriptsSet[name] = script;
this[name] = generateScriptingFunction(name, name, script, "utf8");
this[name + "Buffer"] = generateScriptingFunction(name + "Buffer", name, script, null);
}
/**
* @ignore
*/
sendCommand(command, stream, node) {
throw new Error('"sendCommand" is not implemented');
}
}
const commands = commands_1.list.filter((command) => command !== "monitor");
commands.push("sentinel");
commands.forEach(function (commandName) {
Commander.prototype[commandName] = generateFunction(commandName, commandName, "utf8");
Commander.prototype[commandName + "Buffer"] = generateFunction(commandName + "Buffer", commandName, null);
});
Commander.prototype.call = generateFunction("call", "utf8");
Commander.prototype.callBuffer = generateFunction("callBuffer", null);
// @ts-expect-error
Commander.prototype.send_command = Commander.prototype.call;
function generateFunction(functionName, _commandName, _encoding) {
if (typeof _encoding === "undefined") {
_encoding = _commandName;
_commandName = null;
}
return function (...args) {
const commandName = (_commandName || args.shift());
let callback = args[args.length - 1];
if (typeof callback === "function") {
args.pop();
}
else {
callback = undefined;
}
const options = {
errorStack: this.options.showFriendlyErrorStack ? new Error() : undefined,
keyPrefix: this.options.keyPrefix,
replyEncoding: _encoding,
};
// No auto pipeline, use regular command sending
if (!(0, autoPipelining_1.shouldUseAutoPipelining)(this, functionName, commandName)) {
return this.sendCommand(
// @ts-expect-error
new Command_1.default(commandName, args, options, callback));
}
// Create a new pipeline and make sure it's scheduled
return (0, autoPipelining_1.executeWithAutoPipelining)(this, functionName, commandName,
// @ts-expect-error
args, callback);
};
}
function generateScriptingFunction(functionName, commandName, script, encoding) {
return function (...args) {
const callback = typeof args[args.length - 1] === "function" ? args.pop() : undefined;
const options = {
replyEncoding: encoding,
};
if (this.options.showFriendlyErrorStack) {
options.errorStack = new Error();
}
// No auto pipeline, use regular command sending
if (!(0, autoPipelining_1.shouldUseAutoPipelining)(this, functionName, commandName)) {
return script.execute(this, args, options, callback);
}
// Create a new pipeline and make sure it's scheduled
return (0, autoPipelining_1.executeWithAutoPipelining)(this, functionName, commandName, args, callback);
};
}
exports.default = Commander;

5545
node_modules/ioredis/built/utils/RedisCommander.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

7
node_modules/ioredis/built/utils/RedisCommander.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
"use strict";
/**
* This file is generated by @ioredis/interface-generator.
* Don't edit it manually. Instead, run `npm run generate` to update
* this file.
*/
Object.defineProperty(exports, "__esModule", { value: true });

3
node_modules/ioredis/built/utils/applyMixin.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
type Constructor = new (...args: any[]) => void;
declare function applyMixin(derivedConstructor: Constructor, mixinConstructor: Constructor): void;
export default applyMixin;

8
node_modules/ioredis/built/utils/applyMixin.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function applyMixin(derivedConstructor, mixinConstructor) {
Object.getOwnPropertyNames(mixinConstructor.prototype).forEach((name) => {
Object.defineProperty(derivedConstructor.prototype, name, Object.getOwnPropertyDescriptor(mixinConstructor.prototype, name));
});
}
exports.default = applyMixin;

14
node_modules/ioredis/built/utils/argumentParsers.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { CommandParameter } from "../types";
/**
* Parses a command parameter as seconds and converts to milliseconds.
* @param arg - The command parameter representing seconds
* @returns The value in milliseconds, 0 if value is <= 0, or undefined if parsing fails
*/
export declare const parseSecondsArgument: (arg: CommandParameter | undefined) => number | undefined;
/**
* Parses the BLOCK option from Redis command arguments (e.g., XREAD, XREADGROUP).
* @param args - Array of command parameters to search for the BLOCK option
* @returns The block duration in milliseconds, 0 if duration is <= 0,
* null if BLOCK option is not found, or undefined if BLOCK is found but duration is invalid
*/
export declare const parseBlockOption: (args: CommandParameter[]) => number | null | undefined;

74
node_modules/ioredis/built/utils/argumentParsers.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseBlockOption = exports.parseSecondsArgument = void 0;
/**
* Parses a command parameter to a number.
* @param arg - The command parameter to parse (number, string, or Buffer)
* @returns The parsed number, or undefined if parsing fails or arg is undefined
*/
const parseNumberArgument = (arg) => {
if (typeof arg === "number") {
return arg;
}
if (Buffer.isBuffer(arg)) {
return parseNumberArgument(arg.toString());
}
if (typeof arg === "string") {
const value = Number(arg);
return Number.isFinite(value) ? value : undefined;
}
return undefined;
};
/**
* Parses a command parameter to a string.
* @param arg - The command parameter to parse (string or Buffer)
* @returns The parsed string, or undefined if arg is not a string/Buffer or is undefined
*/
const parseStringArgument = (arg) => {
if (typeof arg === "string") {
return arg;
}
if (Buffer.isBuffer(arg)) {
return arg.toString();
}
return undefined;
};
/**
* Parses a command parameter as seconds and converts to milliseconds.
* @param arg - The command parameter representing seconds
* @returns The value in milliseconds, 0 if value is <= 0, or undefined if parsing fails
*/
const parseSecondsArgument = (arg) => {
const value = parseNumberArgument(arg);
if (value === undefined) {
return undefined;
}
if (value <= 0) {
return 0;
}
return value * 1000;
};
exports.parseSecondsArgument = parseSecondsArgument;
/**
* Parses the BLOCK option from Redis command arguments (e.g., XREAD, XREADGROUP).
* @param args - Array of command parameters to search for the BLOCK option
* @returns The block duration in milliseconds, 0 if duration is <= 0,
* null if BLOCK option is not found, or undefined if BLOCK is found but duration is invalid
*/
const parseBlockOption = (args) => {
for (let i = 0; i < args.length; i++) {
const token = parseStringArgument(args[i]);
if (token && token.toLowerCase() === "block") {
const duration = parseNumberArgument(args[i + 1]);
if (duration === undefined) {
return undefined;
}
if (duration <= 0) {
return 0;
}
return duration;
}
}
return null;
};
exports.parseBlockOption = parseBlockOption;

16
node_modules/ioredis/built/utils/debug.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
declare const MAX_ARGUMENT_LENGTH = 200;
/**
* helper function that tried to get a string value for
* arbitrary "debug" arg
*/
declare function getStringValue(v: any): string | void;
/**
* helper function that redacts a string representation of a "debug" arg
*/
declare function genRedactedString(str: string, maxLen: number): string;
/**
* a wrapper for the `debug` module, used to generate
* "debug functions" that trim the values in their output
*/
export default function genDebugFunction(namespace: string): (...args: any[]) => void;
export { MAX_ARGUMENT_LENGTH, getStringValue, genRedactedString };

95
node_modules/ioredis/built/utils/debug.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.genRedactedString = exports.getStringValue = exports.MAX_ARGUMENT_LENGTH = void 0;
const debug_1 = require("debug");
const MAX_ARGUMENT_LENGTH = 200;
exports.MAX_ARGUMENT_LENGTH = MAX_ARGUMENT_LENGTH;
const NAMESPACE_PREFIX = "ioredis";
/**
* helper function that tried to get a string value for
* arbitrary "debug" arg
*/
function getStringValue(v) {
if (v === null) {
return;
}
switch (typeof v) {
case "boolean":
return;
case "number":
return;
case "object":
if (Buffer.isBuffer(v)) {
return v.toString("hex");
}
if (Array.isArray(v)) {
return v.join(",");
}
try {
return JSON.stringify(v);
}
catch (e) {
return;
}
case "string":
return v;
}
}
exports.getStringValue = getStringValue;
/**
* helper function that redacts a string representation of a "debug" arg
*/
function genRedactedString(str, maxLen) {
const { length } = str;
return length <= maxLen
? str
: str.slice(0, maxLen) + ' ... <REDACTED full-length="' + length + '">';
}
exports.genRedactedString = genRedactedString;
/**
* a wrapper for the `debug` module, used to generate
* "debug functions" that trim the values in their output
*/
function genDebugFunction(namespace) {
const fn = (0, debug_1.default)(`${NAMESPACE_PREFIX}:${namespace}`);
function wrappedDebug(...args) {
if (!fn.enabled) {
return; // no-op
}
// we skip the first arg because that is the message
for (let i = 1; i < args.length; i++) {
const str = getStringValue(args[i]);
if (typeof str === "string" && str.length > MAX_ARGUMENT_LENGTH) {
args[i] = genRedactedString(str, MAX_ARGUMENT_LENGTH);
}
}
return fn.apply(null, args);
}
Object.defineProperties(wrappedDebug, {
namespace: {
get() {
return fn.namespace;
},
},
enabled: {
get() {
return fn.enabled;
},
},
destroy: {
get() {
return fn.destroy;
},
},
log: {
get() {
return fn.log;
},
set(l) {
fn.log = l;
},
},
});
return wrappedDebug;
}
exports.default = genDebugFunction;

6
node_modules/ioredis/built/utils/defaults.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export declare function defaults<T, S>(object: T, source: S): NonNullable<S & T>;
export declare function defaults<T, S1, S2>(object: T, source1: S1, source2: S2): NonNullable<S2 & S1 & T>;
export declare function defaults<T, S1, S2, S3>(object: T, source1: S1, source2: S2, source3: S3): NonNullable<S3 & S2 & S1 & T>;
export declare function defaults<T, S1, S2, S3, S4>(object: T, source1: S1, source2: S2, source3: S3, source4: S4): NonNullable<S4 & S3 & S2 & S1 & T>;
export declare function defaults<T>(object: T): NonNullable<T>;
export declare function defaults(object: any, ...sources: any[]): any;

102
node_modules/ioredis/built/utils/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
"use strict";
/*
* Derived from `src/compat/object/defaults.ts` in es-toolkit
* (https://github.com/toss/es-toolkit).
*
* Copyright (c) 2024 Viva Republica, Inc
* Copyright OpenJS Foundation and other contributors
*
* Parts of the compatibility layer in `es-toolkit/compat` are derived from
* Lodash (https://github.com/lodash/lodash) by the OpenJS Foundation
* (https://openjsf.org/) and Underscore.js by Jeremy Ashkenas, DocumentCloud
* and Investigative Reporters & Editors (http://underscorejs.org/).
*
* This file has been modified from the original source to create a standalone
* adaptation.
*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaults = void 0;
const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
function isNil(value) {
return value == null;
}
function eq(value, other) {
return value === other || (Number.isNaN(value) && Number.isNaN(other));
}
function isLength(value) {
return Number.isSafeInteger(value) && value >= 0;
}
function isArrayLike(value) {
return (value != null &&
typeof value !== "function" &&
isLength(value.length));
}
function isObject(value) {
return (value !== null && (typeof value === "object" || typeof value === "function"));
}
function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
switch (typeof value) {
case "number":
return Number.isInteger(value) && value >= 0 && value < length;
case "symbol":
return false;
case "string":
return IS_UNSIGNED_INTEGER.test(value);
}
}
function isIterateeCall(value, index, object) {
if (!isObject(object)) {
return false;
}
if ((typeof index === "number" &&
isArrayLike(object) &&
isIndex(index) &&
index < object.length) ||
(typeof index === "string" && index in object)) {
return eq(object[index], value);
}
return false;
}
function defaults(object, ...sources) {
object = Object(object);
const objectProto = Object.prototype;
let length = sources.length;
const guard = length > 2 ? sources[2] : undefined;
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
length = 1;
}
for (let i = 0; i < length; i++) {
if (isNil(sources[i])) {
continue;
}
const source = sources[i];
for (const key in source) {
const value = object[key];
if (value === undefined ||
(!objectProto.hasOwnProperty.call(object, key) &&
eq(value, objectProto[key]))) {
object[key] = source[key];
}
}
}
return object;
}
exports.defaults = defaults;

125
node_modules/ioredis/built/utils/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,125 @@
/// <reference types="node" />
import { defaults, isArguments, noop } from "./lodash";
import { Callback, ProtocolVersion } from "../types";
import Debug from "./debug";
/**
* Convert a buffer to string, supports buffer array and plain objects
* (RESP3 map replies decoded with `replyMapping: "resp3"`)
*
* @example
* ```js
* const input = [Buffer.from('foo'), [Buffer.from('bar')]]
* const res = convertBufferToString(input, 'utf8')
* expect(res).to.eql(['foo', ['bar']])
* ```
*/
export declare function convertBufferToString(value: any, encoding?: BufferEncoding): any;
/**
* Convert a list of results to node-style
*
* @example
* ```js
* const input = ['a', 'b', new Error('c'), 'd']
* const output = exports.wrapMultiResult(input)
* expect(output).to.eql([[null, 'a'], [null, 'b'], [new Error('c')], [null, 'd'])
* ```
*/
export declare function wrapMultiResult(arr: unknown[] | null): unknown[][] | null;
/**
* Detect if the argument is a int
* @example
* ```js
* > isInt('123')
* true
* > isInt('123.3')
* false
* > isInt('1x')
* false
* > isInt(123)
* true
* > isInt(true)
* false
* ```
*/
export declare function isInt(value: any): value is string;
/**
* Pack an array to an Object
*
* @example
* ```js
* > packObject(['a', 'b', 'c', 'd'])
* { a: 'b', c: 'd' }
* ```
*/
export declare function packObject(array: any[]): Record<string, any>;
/**
* Return a callback with timeout
*/
export declare function timeout<T>(callback: Callback<T>, timeout: number): Callback<T>;
/**
* Convert an object to an array
* @example
* ```js
* > convertObjectToArray({ a: '1' })
* ['a', '1']
* ```
*/
export declare function convertObjectToArray<T>(obj: Record<string, T>): (string | T)[];
/**
* Convert a map to an array
* @example
* ```js
* > convertMapToArray(new Map([[1, '2']]))
* [1, '2']
* ```
*/
export declare function convertMapToArray<K, V>(map: Map<K, V>): (K | V)[];
/**
* Convert a non-string arg to a string
*/
export declare function toArg(arg: any): string;
/**
* Optimize error stack
*
* @param error actually error
* @param friendlyStack the stack that more meaningful
* @param filterPath only show stacks with the specified path
*/
export declare function optimizeErrorStack(error: Error, friendlyStack: string, filterPath: string): Error;
/**
* Parse the redis protocol url
*/
export declare function parseURL(url: string): Record<string, unknown>;
interface TLSOptions {
port: number;
host: string;
[key: string]: any;
}
/**
* Resolve TLS profile shortcut in connection options
*/
export declare function resolveTLSProfile(options: TLSOptions): TLSOptions;
/**
* Get a random element from `array`
*/
export declare function sample<T>(array: T[], from?: number): T;
/**
* Shuffle the array using the Fisher-Yates Shuffle.
* This method will mutate the original array.
*/
export declare function shuffle<T>(array: T[]): T[];
/**
* Error message for connection being disconnected
*/
export declare const CONNECTION_CLOSED_ERROR_MSG = "Connection is closed.";
/**
* Whether a connection is restricted to subscriber commands.
* Only RESP2 has a restricted subscriber mode; with RESP3 (HELLO 3),
* regular commands remain allowed while subscribed.
*/
export declare function isResp2SubscriberMode(condition: {
subscriber: false | object;
protocol: ProtocolVersion;
} | null | undefined): boolean;
export declare function zipMap<K, V>(keys: K[], values: V[]): Map<K, V>;
export { Debug, defaults, isArguments, noop };

392
node_modules/ioredis/built/utils/index.js generated vendored Normal file
View File

@@ -0,0 +1,392 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noop = exports.isArguments = exports.defaults = exports.Debug = exports.zipMap = exports.isResp2SubscriberMode = exports.CONNECTION_CLOSED_ERROR_MSG = exports.shuffle = exports.sample = exports.resolveTLSProfile = exports.parseURL = exports.optimizeErrorStack = exports.toArg = exports.convertMapToArray = exports.convertObjectToArray = exports.timeout = exports.packObject = exports.isInt = exports.wrapMultiResult = exports.convertBufferToString = void 0;
const lodash_1 = require("./lodash");
Object.defineProperty(exports, "defaults", { enumerable: true, get: function () { return lodash_1.defaults; } });
Object.defineProperty(exports, "isArguments", { enumerable: true, get: function () { return lodash_1.isArguments; } });
Object.defineProperty(exports, "noop", { enumerable: true, get: function () { return lodash_1.noop; } });
const debug_1 = require("./debug");
exports.Debug = debug_1.default;
const TLSProfiles_1 = require("../constants/TLSProfiles");
/**
* Convert a buffer to string, supports buffer array and plain objects
* (RESP3 map replies decoded with `replyMapping: "resp3"`)
*
* @example
* ```js
* const input = [Buffer.from('foo'), [Buffer.from('bar')]]
* const res = convertBufferToString(input, 'utf8')
* expect(res).to.eql(['foo', ['bar']])
* ```
*/
function convertBufferToString(value, encoding) {
if (value instanceof Buffer) {
return value.toString(encoding);
}
if (Array.isArray(value)) {
const length = value.length;
const res = Array(length);
for (let i = 0; i < length; ++i) {
res[i] =
value[i] instanceof Buffer && encoding === "utf8"
? value[i].toString()
: convertBufferToString(value[i], encoding);
}
return res;
}
if (isPlainObject(value)) {
const keys = Object.keys(value);
const res = {};
for (const element of keys) {
const item = value[element];
const converted = item instanceof Buffer && encoding === "utf8"
? item.toString()
: convertBufferToString(item, encoding);
// Guard "__proto__"/"constructor" via defineProperty, where a bare
// assignment would tamper with the object. Issue #1267. Normal keys take
// the fast plain-assignment path.
if (element === "__proto__" || element === "constructor") {
Object.defineProperty(res, element, {
value: converted,
configurable: true,
enumerable: true,
writable: true,
});
}
else {
res[element] = converted;
}
}
return res;
}
return value;
}
exports.convertBufferToString = convertBufferToString;
/**
* Matches only the plain objects produced by RESP3 map replies, so other
* object types (class instances etc.) pass through reply conversion untouched.
*/
function isPlainObject(value) {
if (value === null || typeof value !== "object") {
return false;
}
const proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null;
}
/**
* Convert a list of results to node-style
*
* @example
* ```js
* const input = ['a', 'b', new Error('c'), 'd']
* const output = exports.wrapMultiResult(input)
* expect(output).to.eql([[null, 'a'], [null, 'b'], [new Error('c')], [null, 'd'])
* ```
*/
function wrapMultiResult(arr) {
// When using WATCH/EXEC transactions, the EXEC will return
// a null instead of an array
if (!arr) {
return null;
}
const result = [];
const length = arr.length;
for (let i = 0; i < length; ++i) {
const item = arr[i];
if (item instanceof Error) {
result.push([item]);
}
else {
result.push([null, item]);
}
}
return result;
}
exports.wrapMultiResult = wrapMultiResult;
/**
* Detect if the argument is a int
* @example
* ```js
* > isInt('123')
* true
* > isInt('123.3')
* false
* > isInt('1x')
* false
* > isInt(123)
* true
* > isInt(true)
* false
* ```
*/
function isInt(value) {
const x = parseFloat(value);
return !isNaN(value) && (x | 0) === x;
}
exports.isInt = isInt;
/**
* Pack an array to an Object
*
* @example
* ```js
* > packObject(['a', 'b', 'c', 'd'])
* { a: 'b', c: 'd' }
* ```
*/
function packObject(array) {
const result = {};
const length = array.length;
for (let i = 1; i < length; i += 2) {
result[array[i - 1]] = array[i];
}
return result;
}
exports.packObject = packObject;
/**
* Return a callback with timeout
*/
function timeout(callback, timeout) {
let timer = null;
const run = function () {
if (timer) {
clearTimeout(timer);
timer = null;
callback.apply(this, arguments);
}
};
timer = setTimeout(run, timeout, new Error("timeout"));
return run;
}
exports.timeout = timeout;
/**
* Convert an object to an array
* @example
* ```js
* > convertObjectToArray({ a: '1' })
* ['a', '1']
* ```
*/
function convertObjectToArray(obj) {
const result = [];
const keys = Object.keys(obj); // Object.entries requires node 7+
for (let i = 0, l = keys.length; i < l; i++) {
result.push(keys[i], obj[keys[i]]);
}
return result;
}
exports.convertObjectToArray = convertObjectToArray;
/**
* Convert a map to an array
* @example
* ```js
* > convertMapToArray(new Map([[1, '2']]))
* [1, '2']
* ```
*/
function convertMapToArray(map) {
const result = [];
let pos = 0;
map.forEach(function (value, key) {
result[pos] = key;
result[pos + 1] = value;
pos += 2;
});
return result;
}
exports.convertMapToArray = convertMapToArray;
/**
* Convert a non-string arg to a string
*/
function toArg(arg) {
if (arg === null || typeof arg === "undefined") {
return "";
}
if (typeof arg === "number" &&
Number.isInteger(arg) &&
!Number.isSafeInteger(arg)) {
return BigInt(arg).toString();
}
return String(arg);
}
exports.toArg = toArg;
/**
* Optimize error stack
*
* @param error actually error
* @param friendlyStack the stack that more meaningful
* @param filterPath only show stacks with the specified path
*/
function optimizeErrorStack(error, friendlyStack, filterPath) {
const stacks = friendlyStack.split("\n");
let lines = "";
let i;
for (i = 1; i < stacks.length; ++i) {
if (stacks[i].indexOf(filterPath) === -1) {
break;
}
}
for (let j = i; j < stacks.length; ++j) {
lines += "\n" + stacks[j];
}
if (error.stack) {
const pos = error.stack.indexOf("\n");
error.stack = error.stack.slice(0, pos) + lines;
}
return error;
}
exports.optimizeErrorStack = optimizeErrorStack;
/**
* Parse the redis protocol url
*/
function parseURL(url) {
if (isInt(url)) {
return { port: url };
}
// Re-assert string type: isInt's type guard (value is string) incorrectly
// narrows url to 'never' in the false branch since url is already string.
const rawUrl = url;
// Determine if the URL has a known protocol (redis:// or rediss://)
const hasProtocol = /^rediss?:\/\//i.test(rawUrl);
const isProtocolRelative = rawUrl.startsWith("//");
// TODO(next major): Consider rejecting protocol-relative Redis URLs early and
// requiring explicit redis:// or rediss:// schemes instead. Keep them working
// in 5.x for backward compatibility.
// Unix socket paths (starting with "/") are not valid URLs — handle separately.
// Preserve query params (e.g., /tmp/redis.sock?db=2)
if (rawUrl[0] === "/" && !isProtocolRelative) {
const qIdx = rawUrl.indexOf("?");
const result = {
path: qIdx === -1 ? rawUrl : rawUrl.slice(0, qIdx),
};
if (qIdx !== -1) {
const options = {};
const params = new URLSearchParams(rawUrl.slice(qIdx + 1));
params.forEach((value, key) => {
options[key] = parseURLQueryItem(key, value);
});
(0, lodash_1.defaults)(result, options);
}
return result;
}
let parsed;
if (hasProtocol) {
parsed = new URL(rawUrl);
}
else if (isProtocolRelative) {
parsed = new URL("redis:" + rawUrl);
}
else {
// Prepend a dummy protocol so new URL() can parse "host:port?query" correctly
parsed = new URL("redis://" + rawUrl);
}
// Convert searchParams to a plain object (equivalent to url.parse(url, true).query)
const options = {};
parsed.searchParams.forEach((value, key) => {
options[key] = parseURLQueryItem(key, value);
});
const result = {};
// Extract auth — WHATWG URL percent-encodes special chars, so decode them.
// Check both username AND password: redis://:password@host has empty username but valid password.
if (parsed.username || parsed.password) {
result.username = decodeURIComponent(parsed.username);
result.password = decodeURIComponent(parsed.password);
}
if (parsed.pathname && parsed.pathname !== "/") {
if (hasProtocol || isProtocolRelative) {
// For redis://, rediss://, and protocol-relative URLs, the path after /
// is the db number
if (parsed.pathname.length > 1) {
result.db = parsed.pathname.slice(1);
}
}
else {
result.path = parsed.pathname;
}
}
if (parsed.hostname) {
// WHATWG URL keeps brackets around IPv6 addresses (e.g., "[::1]").
// Strip them to match the old url.parse() behavior.
result.host = parsed.hostname.replace(/^\[|\]$/g, "");
}
if (parsed.port) {
result.port = parsed.port;
}
(0, lodash_1.defaults)(result, options);
return result;
}
exports.parseURL = parseURL;
function parseURLQueryItem(key, value) {
if (key === "family") {
const intFamily = Number.parseInt(value, 10);
if (!Number.isNaN(intFamily)) {
return intFamily;
}
}
return value;
}
/**
* Resolve TLS profile shortcut in connection options
*/
function resolveTLSProfile(options) {
let tls = options?.tls;
if (typeof tls === "string")
tls = { profile: tls };
const profile = TLSProfiles_1.default[tls?.profile];
if (profile) {
tls = Object.assign({}, profile, tls);
delete tls.profile;
options = Object.assign({}, options, { tls });
}
return options;
}
exports.resolveTLSProfile = resolveTLSProfile;
/**
* Get a random element from `array`
*/
function sample(array, from = 0) {
const length = array.length;
if (from >= length) {
return null;
}
return array[from + Math.floor(Math.random() * (length - from))];
}
exports.sample = sample;
/**
* Shuffle the array using the Fisher-Yates Shuffle.
* This method will mutate the original array.
*/
function shuffle(array) {
let counter = array.length;
// While there are elements in the array
while (counter > 0) {
// Pick a random index
const index = Math.floor(Math.random() * counter);
// Decrease counter by 1
counter--;
// And swap the last element with it
[array[counter], array[index]] = [array[index], array[counter]];
}
return array;
}
exports.shuffle = shuffle;
/**
* Error message for connection being disconnected
*/
exports.CONNECTION_CLOSED_ERROR_MSG = "Connection is closed.";
/**
* Whether a connection is restricted to subscriber commands.
* Only RESP2 has a restricted subscriber mode; with RESP3 (HELLO 3),
* regular commands remain allowed while subscribed.
*/
function isResp2SubscriberMode(condition) {
return Boolean(condition?.subscriber) && condition?.protocol !== 3;
}
exports.isResp2SubscriberMode = isResp2SubscriberMode;
function zipMap(keys, values) {
const map = new Map();
keys.forEach((key, index) => {
map.set(key, values[index]);
});
return map;
}
exports.zipMap = zipMap;

1
node_modules/ioredis/built/utils/isArguments.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare function isArguments(value?: unknown): value is IArguments;

48
node_modules/ioredis/built/utils/isArguments.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
/*
* Derived from `src/compat/predicate/isArguments.ts` in es-toolkit
* (https://github.com/toss/es-toolkit).
*
* Copyright (c) 2024 Viva Republica, Inc
* Copyright OpenJS Foundation and other contributors
*
* Parts of the compatibility layer in `es-toolkit/compat` are derived from
* Lodash (https://github.com/lodash/lodash) by the OpenJS Foundation
* (https://openjsf.org/) and Underscore.js by Jeremy Ashkenas, DocumentCloud
* and Investigative Reporters & Editors (http://underscorejs.org/).
*
* This file has been modified from the original source to create a standalone
* adaptation.
*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArguments = void 0;
function getTag(value) {
if (value == null) {
return value === undefined ? "[object Undefined]" : "[object Null]";
}
return Object.prototype.toString.call(value);
}
function isArguments(value) {
return (value !== null &&
typeof value === "object" &&
getTag(value) === "[object Arguments]");
}
exports.isArguments = isArguments;

3
node_modules/ioredis/built/utils/lodash.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export declare function noop(): void;
export * from "./defaults";
export * from "./isArguments";

21
node_modules/ioredis/built/utils/lodash.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.noop = void 0;
function noop() { }
exports.noop = noop;
__exportStar(require("./defaults"), exports);
__exportStar(require("./isArguments"), exports);

1
node_modules/ioredis/built/utils/version.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare const PACKAGE_VERSION = "6.0.0";

5
node_modules/ioredis/built/utils/version.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PACKAGE_VERSION = void 0;
// Generated by bin/generate-version.js. Do not edit.
exports.PACKAGE_VERSION = "6.0.0";