MCPcopy
hub / github.com/redis/node-redis / prefixKey

Function prefixKey

packages/client/lib/client/parser.ts:11–22  ·  view source on GitHub ↗
(keyPrefix: RedisArgument | undefined, key: RedisArgument)

Source from the content-addressed store, hash-verified

9 * `Buffer.concat` when either side is a `Buffer`.
10 */
11export function prefixKey(keyPrefix: RedisArgument | undefined, key: RedisArgument): RedisArgument {
12 if (keyPrefix === undefined) return key;
13
14 if (typeof keyPrefix === 'string' && typeof key === 'string') {
15 return keyPrefix + key;
16 }
17
18 return Buffer.concat([
19 typeof keyPrefix === 'string' ? Buffer.from(keyPrefix) : keyPrefix,
20 typeof key === 'string' ? Buffer.from(key) : key
21 ]);
22}
23
24/**
25 * Applies {@link prefixKey} to every key in a variadic argument, returning a new array.

Callers 4

parser.spec.tsFile · 0.90
constructorMethod · 0.90
prefixKeysFunction · 0.85
#addKeyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected