You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-17 19:41:06 +03:00
change command options to work with Symbol rather then WeakSet
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
|
const symbol = Symbol('Command Options');
|
||||||
|
|
||||||
export type CommandOptions<T> = T & {
|
export type CommandOptions<T> = T & {
|
||||||
options: never;
|
readonly [symbol]: true
|
||||||
};
|
};
|
||||||
|
|
||||||
const set = new WeakSet();
|
export function commandOptions<T>(options: T): CommandOptions<T> {
|
||||||
|
(options as any)[symbol] = true;
|
||||||
export function commandOptions<T extends object>(options: T): CommandOptions<T> {
|
|
||||||
set.add(options);
|
|
||||||
return options as CommandOptions<T>;
|
return options as CommandOptions<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCommandOptions<T extends object>(options: any): options is CommandOptions<T> {
|
export function isCommandOptions<T>(options: any): options is CommandOptions<T> {
|
||||||
return set.delete(options);
|
return options && options[symbol] === true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user