diff --git a/src/helpers.ts b/src/helpers.ts index 29de7d4..0313e87 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -25,24 +25,3 @@ export function instanceOf(obj: any, ctor: Ctor) { if (base === ctor || base.prototype instanceof ctor) return true return false } - -type Method = ( - this: InstanceType, - ...args: Args -) => Return - -/** - * - * @param target - * @param factory - * @deprecated Not deprecated but incomplete - just pushed away with other changes : *unreliable!* - */ -export function overrideMethods( - target: Class, - factory: (source: InstanceType) => Record> -) { - Object.defineProperties( - target.prototype, - Object.getOwnPropertyDescriptors(factory(Object.getPrototypeOf(target.prototype))) - ) -} diff --git a/test/utils.test.ts b/test/utils.test.ts deleted file mode 100644 index 07c0a01..0000000 --- a/test/utils.test.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { overrideMethods } from '~/helpers' -import { log, logs } from './logger' - -beforeEach(() => { - logs() -}) -test('overrideMethods', () => { - class A { - method() { - log('A', 'method') - } - get value() { - return 42 - } - } - class B extends A { - method() { - log('B', 'method') - super.method() - } - get value() { - return 5 + super.value - } - } - const b = new B() - b.method() - expect(logs()).toEqual(['B method', 'A method']) - expect(b.value).toBe(47) - overrideMethods(B, (source) => ({ - method() { - log('B', 'modified method') - source.method() - } /* - get value() { - return 15 + source.value - }*/ - })) -})