the projects in iter-tools that i checked ship with a is<instance>(inst) static method. Utilizing a static property Symbol.hasInstanceallows an object to be checked with the instanceof-operator which is also used by TypeScript for typechecking that way. eg:
class Instatiater {
static [Symbol.hasInstance] (inst: any): inst is Instatiater { /* ...some check */ }
}
these projects could also benefit from other well-known symbols like Symbol.toStringTag, Symbol.isConcatSpreadable or Symbol.species (MDN-page on symbols featuring the well-known symbols)
the projects in iter-tools that i checked ship with a
is<instance>(inst)static method. Utilizing a static propertySymbol.hasInstanceallows an object to be checked with theinstanceof-operator which is also used by TypeScript for typechecking that way. eg:these projects could also benefit from other well-known symbols like
Symbol.toStringTag,Symbol.isConcatSpreadableorSymbol.species(MDN-page on symbols featuring the well-known symbols)