mnemonica 0.9.93 → 0.9.98

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 (53) hide show
  1. package/README.md +40 -13
  2. package/build/api/errors/bindedMethodErrorHandler.js +52 -51
  3. package/build/api/errors/exceptionConstructor.js +98 -98
  4. package/build/api/errors/index.d.ts +1 -1
  5. package/build/api/errors/index.js +51 -48
  6. package/build/api/errors/throwModificationError.js +96 -95
  7. package/build/api/hooks/flowCheckers.d.ts +1 -1
  8. package/build/api/hooks/flowCheckers.js +11 -10
  9. package/build/api/hooks/index.js +7 -7
  10. package/build/api/hooks/invokeHook.js +46 -45
  11. package/build/api/hooks/registerHook.js +19 -18
  12. package/build/api/index.d.ts +1 -1
  13. package/build/api/index.js +9 -9
  14. package/build/api/types/InstanceCreator.d.ts +2 -4
  15. package/build/api/types/InstanceCreator.js +237 -239
  16. package/build/api/types/InstanceModificator.js +10 -8
  17. package/build/api/types/Mnemosyne.d.ts +3 -2
  18. package/build/api/types/Mnemosyne.js +127 -111
  19. package/build/api/types/TypeProxy.js +132 -132
  20. package/build/api/types/addProps.d.ts +1 -0
  21. package/build/api/types/addProps.js +68 -0
  22. package/build/api/types/compileNewModificatorFunctionBody.d.ts +1 -1
  23. package/build/api/types/compileNewModificatorFunctionBody.js +37 -27
  24. package/build/api/types/createInstanceModificator.js +26 -24
  25. package/build/api/types/createInstanceModificator200XthWay.js +29 -28
  26. package/build/api/types/index.js +161 -159
  27. package/build/api/types/obeyConstructor.d.ts +1 -0
  28. package/build/api/types/obeyConstructor.js +30 -0
  29. package/build/api/utils/index.d.ts +20 -8
  30. package/build/api/utils/index.js +122 -122
  31. package/build/constants/index.d.ts +2 -0
  32. package/build/constants/index.js +62 -57
  33. package/build/descriptors/errors/index.js +7 -7
  34. package/build/descriptors/index.js +5 -5
  35. package/build/descriptors/namespaces/index.js +70 -70
  36. package/build/descriptors/types/index.js +141 -141
  37. package/build/index.d.ts +39 -5
  38. package/build/index.js +63 -31
  39. package/build/types/index.d.ts +16 -17
  40. package/build/types/index.js +1 -1
  41. package/build/utils/collectConstructors.js +52 -51
  42. package/build/utils/defineStackCleaner.js +9 -8
  43. package/build/utils/extract.js +16 -15
  44. package/build/utils/hop.js +3 -2
  45. package/build/utils/index.js +27 -27
  46. package/build/utils/merge.js +15 -14
  47. package/build/utils/parent.js +17 -16
  48. package/build/utils/parse.js +42 -41
  49. package/build/utils/pick.js +21 -20
  50. package/build/utils/toJSON.js +27 -26
  51. package/package.json +92 -92
  52. package/build/api/types/InstanceCreatorProto.d.ts +0 -3
  53. package/build/api/types/InstanceCreatorProto.js +0 -88
@@ -1,102 +1,103 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value : true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.throwModificationError = void 0;
4
- const constants_1 = require('../../constants');
4
+ const constants_1 = require("../../constants");
5
5
  const { odp, SymbolReplaceGaia, } = constants_1.constants;
6
- const errors_1 = require('../../descriptors/errors');
6
+ const errors_1 = require("../../descriptors/errors");
7
7
  const { BASE_MNEMONICA_ERROR } = errors_1.ErrorsTypes;
8
- const _1 = require('./');
9
- const utils_1 = require('../utils');
8
+ const _1 = require("./");
9
+ const utils_1 = require("../utils");
10
10
  const { makeFakeModificatorType } = utils_1.default;
11
- const utils_2 = require('../../utils');
11
+ const utils_2 = require("../../utils");
12
12
  const { parse } = utils_2.utils;
13
- const InstanceModificator_1 = require('../types/InstanceModificator');
14
- exports.throwModificationError = function (error) {
15
- const self = this;
16
- const { TypeName, type: { stack: typeStack }, args } = self;
17
- const exceptionReason = error.exceptionReason || error;
18
- if (error.exceptionReason !== undefined) {
19
- error.reasons.push(error.exceptionReason);
20
- error.surplus.push(error);
21
- throw error;
22
- }
23
- odp(error, 'exceptionReason', {
24
- get () {
25
- return exceptionReason;
26
- },
27
- enumerable : true
28
- });
29
- const reasons = [exceptionReason];
30
- odp(error, 'reasons', {
31
- get () {
32
- return reasons;
33
- },
34
- enumerable : true
35
- });
36
- const surplus = [];
37
- odp(error, 'surplus', {
38
- get () {
39
- return surplus;
40
- },
41
- enumerable : true
42
- });
43
- self.ModificatorType = makeFakeModificatorType(TypeName);
44
- self.InstanceModificator = InstanceModificator_1.makeInstanceModificator(self);
45
- const erroredInstance = new self.InstanceModificator();
46
- erroredInstance[SymbolReplaceGaia](error);
47
- const stack = [];
48
- if (error instanceof BASE_MNEMONICA_ERROR) {
49
- stack.push(error.stack);
50
- }
51
- else {
52
- const title = `\n<-- creation of [ ${TypeName} ] traced -->`;
53
- _1.getStack.call(erroredInstance, title, [], exports.throwModificationError);
54
- stack.push(...erroredInstance.stack);
55
- const errorStack = error.stack.split('\n');
56
- stack.push('<-- with the following error -->');
57
- errorStack.forEach((line) => {
58
- if (!stack.includes(line)) {
59
- stack.push(line);
60
- }
61
- });
62
- stack.push('\n<-- of constructor definitions stack -->');
63
- stack.push(...typeStack);
64
- }
65
- erroredInstance.stack = _1.cleanupStack(stack).join('\n');
66
- self.inheritedInstance = erroredInstance;
67
- const results = self.invokePostHooks();
68
- const { type, collection, namespace } = results;
69
- if (type.has(true) || collection.has(true) || namespace.has(true)) {
70
- return;
71
- }
72
- odp(erroredInstance, 'args', {
73
- get () {
74
- return args;
75
- }
76
- });
77
- odp(erroredInstance, 'originalError', {
78
- get () {
79
- return error;
80
- }
81
- });
82
- odp(erroredInstance, 'instance', {
83
- get () {
84
- return erroredInstance;
85
- }
86
- });
87
- odp(erroredInstance, 'extract', {
88
- get () {
89
- return () => {
90
- return erroredInstance.__self__.extract();
91
- };
92
- }
93
- });
94
- odp(erroredInstance, 'parse', {
95
- get () {
96
- return () => {
97
- return parse(erroredInstance);
98
- };
99
- }
100
- });
101
- throw erroredInstance;
13
+ const InstanceModificator_1 = require("../types/InstanceModificator");
14
+ const throwModificationError = function (error) {
15
+ const self = this;
16
+ const { TypeName, type: { stack: typeStack }, args } = self;
17
+ const exceptionReason = error.exceptionReason || error;
18
+ if (error.exceptionReason !== undefined) {
19
+ error.reasons.push(error.exceptionReason);
20
+ error.surplus.push(error);
21
+ throw error;
22
+ }
23
+ odp(error, 'exceptionReason', {
24
+ get() {
25
+ return exceptionReason;
26
+ },
27
+ enumerable: true
28
+ });
29
+ const reasons = [exceptionReason];
30
+ odp(error, 'reasons', {
31
+ get() {
32
+ return reasons;
33
+ },
34
+ enumerable: true
35
+ });
36
+ const surplus = [];
37
+ odp(error, 'surplus', {
38
+ get() {
39
+ return surplus;
40
+ },
41
+ enumerable: true
42
+ });
43
+ self.ModificatorType = makeFakeModificatorType(TypeName);
44
+ self.InstanceModificator = (0, InstanceModificator_1.makeInstanceModificator)(self);
45
+ const erroredInstance = new self.InstanceModificator();
46
+ erroredInstance[SymbolReplaceGaia](error);
47
+ const stack = [];
48
+ if (error instanceof BASE_MNEMONICA_ERROR) {
49
+ stack.push(error.stack);
50
+ }
51
+ else {
52
+ const title = `\n<-- creation of [ ${TypeName} ] traced -->`;
53
+ _1.getStack.call(erroredInstance, title, [], exports.throwModificationError);
54
+ stack.push(...erroredInstance.stack);
55
+ const errorStack = error.stack.split('\n');
56
+ stack.push('<-- with the following error -->');
57
+ errorStack.forEach((line) => {
58
+ if (!stack.includes(line)) {
59
+ stack.push(line);
60
+ }
61
+ });
62
+ stack.push('\n<-- of constructor definitions stack -->');
63
+ stack.push(...typeStack);
64
+ }
65
+ erroredInstance.stack = (0, _1.cleanupStack)(stack).join('\n');
66
+ self.inheritedInstance = erroredInstance;
67
+ const results = self.invokePostHooks();
68
+ const { type, collection, namespace } = results;
69
+ if (type.has(true) || collection.has(true) || namespace.has(true)) {
70
+ return;
71
+ }
72
+ odp(erroredInstance, 'args', {
73
+ get() {
74
+ return args;
75
+ }
76
+ });
77
+ odp(erroredInstance, 'originalError', {
78
+ get() {
79
+ return error;
80
+ }
81
+ });
82
+ odp(erroredInstance, 'instance', {
83
+ get() {
84
+ return erroredInstance;
85
+ }
86
+ });
87
+ odp(erroredInstance, 'extract', {
88
+ get() {
89
+ return () => {
90
+ return erroredInstance.__self__.extract();
91
+ };
92
+ }
93
+ });
94
+ odp(erroredInstance, 'parse', {
95
+ get() {
96
+ return () => {
97
+ return parse(erroredInstance);
98
+ };
99
+ }
100
+ });
101
+ throw erroredInstance;
102
102
  };
103
+ exports.throwModificationError = throwModificationError;
@@ -1,2 +1,2 @@
1
1
  export declare const flowCheckers: WeakMap<object, any>;
2
- export declare const registerFlowChecker: (this: any, cb: Function) => void;
2
+ export declare const registerFlowChecker: (this: any, cb: () => unknown) => void;
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value : true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerFlowChecker = exports.flowCheckers = void 0;
4
- const errors_1 = require('../../descriptors/errors');
4
+ const errors_1 = require("../../descriptors/errors");
5
5
  const { MISSING_CALLBACK_ARGUMENT, FLOW_CHECKER_REDEFINITION, } = errors_1.ErrorsTypes;
6
6
  exports.flowCheckers = new WeakMap();
7
- exports.registerFlowChecker = function (cb) {
8
- if (typeof cb !== 'function') {
9
- throw new MISSING_CALLBACK_ARGUMENT;
10
- }
11
- if (exports.flowCheckers.has(this)) {
12
- throw new FLOW_CHECKER_REDEFINITION;
13
- }
14
- exports.flowCheckers.set(this, cb);
7
+ const registerFlowChecker = function (cb) {
8
+ if (typeof cb !== 'function') {
9
+ throw new MISSING_CALLBACK_ARGUMENT;
10
+ }
11
+ if (exports.flowCheckers.has(this)) {
12
+ throw new FLOW_CHECKER_REDEFINITION;
13
+ }
14
+ exports.flowCheckers.set(this, cb);
15
15
  };
16
+ exports.registerFlowChecker = registerFlowChecker;
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value : true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerFlowChecker = exports.registerHook = exports.invokeHook = void 0;
4
- var invokeHook_1 = require('./invokeHook');
5
- Object.defineProperty(exports, 'invokeHook', { enumerable : true, get : function () { return invokeHook_1.invokeHook; } });
6
- var registerHook_1 = require('./registerHook');
7
- Object.defineProperty(exports, 'registerHook', { enumerable : true, get : function () { return registerHook_1.registerHook; } });
8
- var flowCheckers_1 = require('./flowCheckers');
9
- Object.defineProperty(exports, 'registerFlowChecker', { enumerable : true, get : function () { return flowCheckers_1.registerFlowChecker; } });
4
+ var invokeHook_1 = require("./invokeHook");
5
+ Object.defineProperty(exports, "invokeHook", { enumerable: true, get: function () { return invokeHook_1.invokeHook; } });
6
+ var registerHook_1 = require("./registerHook");
7
+ Object.defineProperty(exports, "registerHook", { enumerable: true, get: function () { return registerHook_1.registerHook; } });
8
+ var flowCheckers_1 = require("./flowCheckers");
9
+ Object.defineProperty(exports, "registerFlowChecker", { enumerable: true, get: function () { return flowCheckers_1.registerFlowChecker; } });
@@ -1,49 +1,50 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value : true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.invokeHook = void 0;
4
- const constants_1 = require('../../constants');
4
+ const constants_1 = require("../../constants");
5
5
  const { MNEMONICA, } = constants_1.constants;
6
- const flowCheckers_1 = require('./flowCheckers');
7
- const hop_1 = require('../../utils/hop');
8
- exports.invokeHook = function (hookType, opts) {
9
- const { type, existentInstance, inheritedInstance, args, creator } = opts;
10
- const invocationResults = new Set();
11
- const self = this;
12
- if (hop_1.hop(self.hooks, hookType)) {
13
- const { TypeName, } = type;
14
- const hookArgs = {
15
- type,
16
- TypeName,
17
- existentInstance : existentInstance.constructor.name === MNEMONICA ?
18
- null : existentInstance,
19
- args,
20
- };
21
- if (typeof inheritedInstance === 'object') {
22
- Object.assign(hookArgs, {
23
- inheritedInstance,
24
- bindMethod (name, method) {
25
- creator.bindMethod(inheritedInstance, name, method);
26
- },
27
- bindProtoMethods () {
28
- creator.bindProtoMethods();
29
- },
30
- throwModificationError (error) {
31
- creator.throwModificationError(error);
32
- }
33
- });
34
- }
35
- this.hooks[hookType].forEach((hook) => {
36
- const result = hook.call(self, hookArgs);
37
- invocationResults.add(result);
38
- });
39
- const flowChecker = flowCheckers_1.flowCheckers.get(this);
40
- if (typeof flowChecker === 'function') {
41
- flowChecker
42
- .call(this, Object.assign({}, {
43
- invocationResults,
44
- hookType,
45
- }, hookArgs));
46
- }
47
- }
48
- return invocationResults;
6
+ const flowCheckers_1 = require("./flowCheckers");
7
+ const hop_1 = require("../../utils/hop");
8
+ const invokeHook = function (hookType, opts) {
9
+ const { type, existentInstance, inheritedInstance, args, creator } = opts;
10
+ const invocationResults = new Set();
11
+ const self = this;
12
+ if ((0, hop_1.hop)(self.hooks, hookType)) {
13
+ const { TypeName, } = type;
14
+ const hookArgs = {
15
+ type,
16
+ TypeName,
17
+ existentInstance: existentInstance.constructor.name === MNEMONICA ?
18
+ null : existentInstance,
19
+ args,
20
+ };
21
+ if (typeof inheritedInstance === 'object') {
22
+ Object.assign(hookArgs, {
23
+ inheritedInstance,
24
+ bindMethod(name, method) {
25
+ creator.bindMethod(inheritedInstance, name, method);
26
+ },
27
+ bindProtoMethods() {
28
+ creator.bindProtoMethods();
29
+ },
30
+ throwModificationError(error) {
31
+ creator.throwModificationError(error);
32
+ }
33
+ });
34
+ }
35
+ this.hooks[hookType].forEach((hook) => {
36
+ const result = hook.call(self, hookArgs);
37
+ invocationResults.add(result);
38
+ });
39
+ const flowChecker = flowCheckers_1.flowCheckers.get(this);
40
+ if (typeof flowChecker === 'function') {
41
+ flowChecker
42
+ .call(this, Object.assign({}, {
43
+ invocationResults,
44
+ hookType,
45
+ }, hookArgs));
46
+ }
47
+ }
48
+ return invocationResults;
49
49
  };
50
+ exports.invokeHook = invokeHook;
@@ -1,24 +1,25 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value : true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerHook = void 0;
4
- const errors_1 = require('../../descriptors/errors');
4
+ const errors_1 = require("../../descriptors/errors");
5
5
  const { WRONG_HOOK_TYPE, MISSING_HOOK_CALLBACK, } = errors_1.ErrorsTypes;
6
6
  const hooksTypes = [
7
- 'preCreation',
8
- 'postCreation',
9
- 'creationError',
7
+ 'preCreation',
8
+ 'postCreation',
9
+ 'creationError',
10
10
  ];
11
- exports.registerHook = function (hookType, cb) {
12
- if (!hooksTypes.includes(hookType)) {
13
- throw new WRONG_HOOK_TYPE;
14
- }
15
- if (typeof cb !== 'function') {
16
- throw new MISSING_HOOK_CALLBACK;
17
- }
18
- if (!this.hooks[hookType]) {
19
- this.hooks[hookType] = new Set([cb]);
20
- }
21
- else {
22
- this.hooks[hookType].add(cb);
23
- }
11
+ const registerHook = function (hookType, cb) {
12
+ if (!hooksTypes.includes(hookType)) {
13
+ throw new WRONG_HOOK_TYPE;
14
+ }
15
+ if (typeof cb !== 'function') {
16
+ throw new MISSING_HOOK_CALLBACK;
17
+ }
18
+ if (!this.hooks[hookType]) {
19
+ this.hooks[hookType] = new Set([cb]);
20
+ }
21
+ else {
22
+ this.hooks[hookType].add(cb);
23
+ }
24
24
  };
25
+ exports.registerHook = registerHook;
@@ -4,7 +4,7 @@ export declare const hooks: {
4
4
  [index: string]: any;
5
5
  }) => Set<unknown>;
6
6
  registerHook: (this: any, hookType: string, cb: CallableFunction) => void;
7
- registerFlowChecker: (this: any, cb: Function) => void;
7
+ registerFlowChecker: (this: any, cb: () => unknown) => void;
8
8
  };
9
9
  export declare const types: {
10
10
  define: any;
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value : true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.types = exports.hooks = exports.errors = void 0;
4
- const hooks_1 = require('./hooks');
5
- const types_1 = require('./types');
6
- exports.errors = require('./errors');
4
+ const hooks_1 = require("./hooks");
5
+ const types_1 = require("./types");
6
+ exports.errors = require("./errors");
7
7
  exports.hooks = {
8
- invokeHook : hooks_1.invokeHook,
9
- registerHook : hooks_1.registerHook,
10
- registerFlowChecker : hooks_1.registerFlowChecker,
8
+ invokeHook: hooks_1.invokeHook,
9
+ registerHook: hooks_1.registerHook,
10
+ registerFlowChecker: hooks_1.registerFlowChecker,
11
11
  };
12
12
  exports.types = {
13
- define : types_1.define,
14
- lookup : types_1.lookup,
13
+ define: types_1.define,
14
+ lookup: types_1.lookup,
15
15
  };
@@ -1,14 +1,12 @@
1
1
  import { ConstructorFunction } from '../../types';
2
2
  export declare const InstanceCreator: ConstructorFunction<{
3
- getExistentAsyncStack: (existentInstance: any) => any[];
3
+ getExistentAsyncStack: (existentInstance: import("../utils").asyncStack) => unknown;
4
4
  postProcessing: (this: any, continuationOf: any) => void;
5
5
  bindMethod: (this: any, instance: any, methodName: string, MethodItself: any) => void;
6
6
  bindProtoMethods: (this: any) => void;
7
7
  makeWaiter: (this: any, type: any, then: any) => any;
8
- proceedProto: (this: any) => void;
9
- addProps: (this: any) => void;
8
+ addProps: (this: any) => any;
10
9
  addThen: (this: any, then: any) => void;
11
- undefineParentSubTypes: (this: any) => void;
12
10
  invokePreHooks: (this: any) => void;
13
11
  invokePostHooks: (this: any) => {
14
12
  type: any;