seyfert 2.2.1-dev-12970267967.0 → 2.2.1-dev-13162061448.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/deps/mixer.js +22 -28
- package/package.json +1 -1
package/lib/deps/mixer.js
CHANGED
|
@@ -26,11 +26,8 @@ function getNodeDescriptors(c) {
|
|
|
26
26
|
const result = [];
|
|
27
27
|
while (proto) {
|
|
28
28
|
const descriptors = Object.getOwnPropertyDescriptors(proto);
|
|
29
|
-
// @ts-expect-error this is not a function in all cases
|
|
30
|
-
if (descriptors.valueOf.configurable)
|
|
31
|
-
break;
|
|
32
29
|
result.push(descriptors);
|
|
33
|
-
proto = proto
|
|
30
|
+
proto = Object.getPrototypeOf(proto);
|
|
34
31
|
}
|
|
35
32
|
return result;
|
|
36
33
|
}
|
|
@@ -45,32 +42,29 @@ function getDescriptors(c) {
|
|
|
45
42
|
* @returns The mixed class.
|
|
46
43
|
*/
|
|
47
44
|
function Mixin(...args) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
continue;
|
|
58
|
-
if (descriptorK in MixedClass.prototype && descriptorK !== 'toString')
|
|
59
|
-
continue;
|
|
60
|
-
const descriptor = j[descriptorK];
|
|
61
|
-
if (descriptor.value) {
|
|
62
|
-
if (descriptorK === 'toString' && ignoreOverwriteToString) {
|
|
63
|
-
MixedClass.prototype[descriptorK] = args[0].prototype.toString;
|
|
45
|
+
const Base = args[0];
|
|
46
|
+
class MixedClass extends Base {
|
|
47
|
+
constructor(...constructorArgs) {
|
|
48
|
+
super(...constructorArgs);
|
|
49
|
+
for (const mixin of args.slice(1)) {
|
|
50
|
+
const descriptors = getDescriptors(mixin).reverse();
|
|
51
|
+
for (const desc of descriptors) {
|
|
52
|
+
for (const key in desc) {
|
|
53
|
+
if (key === 'constructor')
|
|
64
54
|
continue;
|
|
55
|
+
if (key in mixin.prototype)
|
|
56
|
+
continue;
|
|
57
|
+
const descriptor = desc[key];
|
|
58
|
+
if (descriptor.value) {
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
MixedClass.prototype[key] = descriptor.value;
|
|
61
|
+
}
|
|
62
|
+
else if (descriptor.get || descriptor.set) {
|
|
63
|
+
Object.defineProperty(MixedClass.prototype, key, {
|
|
64
|
+
get: descriptor.get,
|
|
65
|
+
set: descriptor.set,
|
|
66
|
+
});
|
|
65
67
|
}
|
|
66
|
-
MixedClass.prototype[descriptorK] = descriptor.value;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
if (descriptor.get || descriptor.set) {
|
|
70
|
-
Object.defineProperty(MixedClass.prototype, descriptorK, {
|
|
71
|
-
get: descriptor.get,
|
|
72
|
-
set: descriptor.set,
|
|
73
|
-
});
|
|
74
68
|
}
|
|
75
69
|
}
|
|
76
70
|
}
|