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.
Files changed (2) hide show
  1. package/lib/deps/mixer.js +22 -28
  2. 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.__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 ignoreOverwriteToString = Object.keys(Object.getOwnPropertyDescriptors(args[0].prototype)).includes('toString');
49
- function MixedClass(...constructorArgs) {
50
- for (const i of args) {
51
- const descriptors = getDescriptors(i).reverse();
52
- for (const j of descriptors) {
53
- // @ts-expect-error
54
- Object.assign(this, new j.constructor.value(...constructorArgs));
55
- for (const descriptorK in j) {
56
- if (descriptorK === 'constructor')
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seyfert",
3
- "version": "2.2.1-dev-12970267967.0",
3
+ "version": "2.2.1-dev-13162061448.0",
4
4
  "description": "The most advanced framework for discord bots",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",