From ce0b3463af538a65f5b4f8a77d3e293cbe459797 Mon Sep 17 00:00:00 2001 From: leibale Date: Tue, 25 May 2021 11:41:55 -0400 Subject: [PATCH] change command options to work with Symbol rather then WeakSet --- lib/command-options.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/command-options.ts b/lib/command-options.ts index f0a0cb4691..9b3f2a6850 100644 --- a/lib/command-options.ts +++ b/lib/command-options.ts @@ -1,14 +1,14 @@ +const symbol = Symbol('Command Options'); + export type CommandOptions = T & { - options: never; + readonly [symbol]: true }; -const set = new WeakSet(); - -export function commandOptions(options: T): CommandOptions { - set.add(options); +export function commandOptions(options: T): CommandOptions { + (options as any)[symbol] = true; return options as CommandOptions; } -export function isCommandOptions(options: any): options is CommandOptions { - return set.delete(options); +export function isCommandOptions(options: any): options is CommandOptions { + return options && options[symbol] === true; }