mnemonica 0.9.943 → 0.9.944

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.
@@ -1,2 +1,2 @@
1
- declare const compileNewModificatorFunctionBody: (FunctionName: string, asClass?: boolean) => Function;
1
+ declare const compileNewModificatorFunctionBody: (FunctionName: string, asClass?: boolean) => (ConstructHandler: any, CreationHandler: any, SymbolConstructorName: symbol) => any;
2
2
  export default compileNewModificatorFunctionBody;
@@ -1,32 +1,41 @@
1
1
  'use strict';
2
2
  Object.defineProperty(exports, '__esModule', { value : true });
3
+ const getClassConstructor = (ConstructHandler, CreationHandler) => {
4
+ return class extends ConstructHandler {
5
+ constructor (...args) {
6
+ const answer = super(...args);
7
+ return CreationHandler.call(this, answer);
8
+ }
9
+ };
10
+ };
11
+ const getFunctionConstructor = (ConstructHandler, CreationHandler) => {
12
+ return function (...args) {
13
+ const answer = ConstructHandler.call(this, ...args);
14
+ return CreationHandler.call(this, answer);
15
+ };
16
+ };
3
17
  const compileNewModificatorFunctionBody = function (FunctionName, asClass = false) {
4
- const dt = `${Date.now()}_${`${Math.random()}`.split('.')[1]}`;
5
- const modString = asClass ?
6
- `class ${FunctionName} extends ConstructHandler_${dt} {
7
- constructor(...args) {
8
- const answer = super(...args);
9
- return CreationHandler_${dt}.call(this, answer);
18
+ return function (ConstructHandler, CreationHandler, SymbolConstructorName) {
19
+ return function () {
20
+ let ModificationBody;
21
+ if (asClass) {
22
+ ModificationBody = getClassConstructor(ConstructHandler, CreationHandler);
10
23
  }
11
- }`
12
- :
13
- `const ${FunctionName} = function (...args) {
14
- const answer = ConstructHandler_${dt}.call(this, ...args);
15
- return CreationHandler_${dt}.call(this, answer);
16
- };`;
17
- return new Function(`ConstructHandler_${dt}`, `CreationHandler_${dt}`, 'SymbolConstructorName', `return function () {
18
-
19
- ${modString}
20
-
21
- Object.defineProperty(${FunctionName}, SymbolConstructorName, {
24
+ else {
25
+ ModificationBody = getFunctionConstructor(ConstructHandler, CreationHandler);
26
+ }
27
+ ModificationBody.prototype.constructor = ModificationBody;
28
+ Object.defineProperty(ModificationBody.prototype.constructor, 'name', {
29
+ value : FunctionName,
30
+ writable : false
31
+ });
32
+ Object.defineProperty(ModificationBody, SymbolConstructorName, {
22
33
  get () {
23
- return '${FunctionName}';
34
+ return FunctionName;
24
35
  }
25
36
  });
26
-
27
- return ${FunctionName};
28
-
37
+ return ModificationBody;
29
38
  };
30
- `);
39
+ };
31
40
  };
32
41
  exports.default = compileNewModificatorFunctionBody;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnemonica",
3
- "version": "0.9.943",
3
+ "version": "0.9.944",
4
4
  "description": "abstract technique that aids information retention : instance inheritance system",
5
5
  "type": "commonjs",
6
6
  "main": "./build/index.js",