From 67501a600ea72d7bd12f26bb6c0ee2bc03209783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Marie=20De=20Mey?= Date: Sun, 17 Nov 2024 06:10:25 +0200 Subject: [PATCH] before class->fct refactor --- CHANGELOG.md | 9 ++++++++- src/seclude.ts | 3 ++- src/utils.ts | 8 ++++---- test/prototypes.test.ts | 35 +++++++++++++++++++++++++++++++++++ tsconfig.json | 3 +++ 5 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 test/prototypes.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a94b0c..3a2af64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,17 @@ +# 1.0.11 + +## Fix + +- Source map restoration +- prototype line consistence + # 1.0.10 ## Change - linter from prettier+eslint to biome -## Bug-fix +## Fix - `KeySet` now rooted on `Object.create(null)` instead of `{}` so that `'constructor' in secludedProperties` is false - Temporary object (modified as head with `this` diamond as proxy) now has good constructor and `instanceof` diff --git a/src/seclude.ts b/src/seclude.ts index ef37c3a..92c0190 100644 --- a/src/seclude.ts +++ b/src/seclude.ts @@ -59,6 +59,7 @@ export function Seclude() diff --git a/test/prototypes.test.ts b/test/prototypes.test.ts new file mode 100644 index 0000000..509db33 --- /dev/null +++ b/test/prototypes.test.ts @@ -0,0 +1,35 @@ +import Diamond from '../src' + +class X {} + +class A extends Diamond(X) {} + +class B extends A {} +class C extends A {} + +class D extends Diamond(B, C) {} + +test('prototype console', () => { + const d = new D() + + for ( + let browser = Object.getPrototypeOf(d); + browser !== Object.prototype; + browser = Object.getPrototypeOf(browser) + ) { + console.log(browser.constructor.name) + } +}) +test('prototype line', () => { + const expected = ['D', 'Diamond', 'B', 'A', 'C', 'A', 'X', 'Object'] + const d = new D() + + for ( + let browser = Object.getPrototypeOf(d); + browser !== Object.prototype; + browser = Object.getPrototypeOf(browser) + ) { + expect(browser.constructor.name).toBe(expected.shift()) + } + expect(expected).toEqual(['Object']) +}) diff --git a/tsconfig.json b/tsconfig.json index e487b94..81783df 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,10 @@ "moduleResolution": "Node", "target": "ESNext", "module": "ESNext", + "sourceMap": true, "declaration": false, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, "strict": true, "esModuleInterop": true, "skipLibCheck": false,