Class MethodDisabler

A class that creates an object with methods for disabling/enabling a given method on a given object.

Example

const md = new MethodDisabler(process.stdout, 'write')

md.disable()
assert(!md.isEnabled)
console.log('This will not print')

md.enable()
assert(md.isEnabled)
console.log('This will print')

assert(md.original === process.stdout.write)

Hierarchy

  • MethodDisabler

Constructors

Properties

#hasOwn: boolean
#isEnabled: boolean = true
#key: string
#noopDescriptor: PropertyDescriptor
#obj: Record<ObjectKey, any>
#original: TFunctionNoNew
#originalDescriptor: PropertyDescriptor
#memoized: WeakMap<Record<ObjectKey, any>, Map<ObjectKey, MethodDisabler>> = ...
#noop: TFunctionNoNew = ...

Accessors

Methods

Generated using TypeDoc