(keyPrefix: RedisArgument | undefined, key: RedisArgument)
| 9 | * `Buffer.concat` when either side is a `Buffer`. |
| 10 | */ |
| 11 | export 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. |
no outgoing calls
no test coverage detected