+11
-3
@@ -17,5 +17,13 @@ "use strict"; | ||
| static Wrapper = class extends EventEmitter { | ||
| constructor() { | ||
| #extends; | ||
| constructor(extendTarget) { | ||
| super(); | ||
| if (extendTarget) { | ||
| Object.setPrototypeOf(this.__proto__, extendTarget.prototype); | ||
| this.#extends = true; | ||
| } | ||
| return new Proxy(this, { | ||
@@ -26,3 +34,3 @@ map: new Map(), | ||
| const isEventSubscription = name === "on"; | ||
| const isEventSubscription = name === "on" || target.#extends; | ||
@@ -39,3 +47,3 @@ const key = JSON.stringify({ | ||
| return function (...args) { | ||
| return (...args) => { | ||
| const output = target[name].bind(target)(...args); | ||
@@ -42,0 +50,0 @@ |
+2
-2
| { | ||
| "name": "cipherio", | ||
| "version": "1.4.4", | ||
| "version": "1.5.4", | ||
| "description": "Make secure parts in shared code", | ||
@@ -24,2 +24,2 @@ "main": "index.js", | ||
| "license": "ISC" | ||
| } | ||
| } |
+16
-0
@@ -92,2 +92,18 @@ # cipherio | ||
| Dynamic inheriting | ||
| ```js | ||
| const Parent = class { | ||
| noop() {} | ||
| }; | ||
| const instance = new (class extends cipherio.Wrapper { | ||
| constructor() { | ||
| super(Parent); | ||
| } | ||
| })(); | ||
| instance.noop(); | ||
| ``` | ||
| ## Test | ||
@@ -94,0 +110,0 @@ |
10508
3.63%284
1.79%113
16.49%