mnemonica 1.0.1 → 1.0.6

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 (89) hide show
  1. package/.ai/ONBOARDING.md +1 -1
  2. package/.ai/ask/AGENTS.md +15 -9
  3. package/.ai/rules-skill/contributing.md +1 -1
  4. package/.ai/rules-skill/define-patterns.md +8 -2
  5. package/.ai/rules-skill/ecosystem.md +4 -4
  6. package/.ai/rules-skill/instance-methods.md +48 -15
  7. package/.ai/rules-skill/type-system.md +12 -2
  8. package/AGENTS.md +6 -2
  9. package/CONTRIBUTING.md +7 -1
  10. package/FOR_HUMANS.md +143 -199
  11. package/README.md +74 -39
  12. package/build/api/errors/exceptionConstructor.js +20 -12
  13. package/build/api/errors/index.js +9 -5
  14. package/build/api/errors/throwModificationError.js +15 -9
  15. package/build/api/index.js +35 -2
  16. package/build/api/types/InstanceCreator.js +5 -2
  17. package/build/api/types/Mnemosyne.d.ts +6 -6
  18. package/build/api/types/Mnemosyne.js +43 -120
  19. package/build/api/types/Props.js +5 -3
  20. package/build/api/types/TypeProxy.js +13 -9
  21. package/build/api/types/compileNewModificatorFunctionBody.js +14 -8
  22. package/build/api/types/index.js +56 -13
  23. package/build/api/utils/index.js +21 -12
  24. package/build/constants/index.js +11 -8
  25. package/build/descriptors/types/index.js +79 -26
  26. package/build/index.d.ts +4 -4
  27. package/build/index.js +62 -15
  28. package/build/types/index.d.ts +52 -31
  29. package/build/types/index.js +1 -1
  30. package/build/utils/clone.d.ts +1 -0
  31. package/build/utils/clone.js +11 -0
  32. package/build/utils/collectConstructors.js +5 -3
  33. package/build/utils/exception.d.ts +1 -0
  34. package/build/utils/exception.js +14 -0
  35. package/build/utils/extract.d.ts +2 -3
  36. package/build/utils/extract.js +3 -2
  37. package/build/utils/fork.d.ts +1 -0
  38. package/build/utils/fork.js +33 -0
  39. package/build/utils/index.d.ts +2 -3
  40. package/build/utils/index.js +21 -7
  41. package/build/utils/merge.d.ts +2 -1
  42. package/build/utils/merge.js +10 -6
  43. package/build/utils/parent.d.ts +1 -1
  44. package/build/utils/parent.js +3 -2
  45. package/build/utils/parse.d.ts +2 -12
  46. package/build/utils/parse.js +1 -1
  47. package/build/utils/pick.d.ts +4 -3
  48. package/build/utils/pick.js +4 -5
  49. package/build/utils/sibling.d.ts +1 -0
  50. package/build/utils/sibling.js +25 -0
  51. package/build/utils/toJSON.d.ts +1 -1
  52. package/build/utils/toJSON.js +3 -2
  53. package/docs/UTILS.md +184 -0
  54. package/docs/ai-learning-trajectory.md +1 -1
  55. package/docs/async-constructors.md +3 -1
  56. package/docs/empathy-in-ai.md +170 -0
  57. package/docs/hott-primer.md +47 -0
  58. package/docs/performance-vs-security.md +2 -2
  59. package/docs/purpose.md +38 -7
  60. package/docs/tactica-pattern.md +10 -10
  61. package/docs/theory-of-operations.md +224 -0
  62. package/docs/typed-lookup.md +12 -12
  63. package/package.json +12 -7
  64. package/src/api/errors/exceptionConstructor.ts +14 -9
  65. package/src/api/errors/index.ts +8 -4
  66. package/src/api/errors/throwModificationError.ts +10 -9
  67. package/src/api/types/InstanceCreator.ts +5 -8
  68. package/src/api/types/Mnemosyne.ts +72 -231
  69. package/src/api/types/Props.ts +4 -2
  70. package/src/api/types/TypeProxy.ts +7 -11
  71. package/src/api/types/compileNewModificatorFunctionBody.ts +13 -7
  72. package/src/api/types/index.ts +15 -8
  73. package/src/api/utils/index.ts +16 -14
  74. package/src/constants/index.ts +6 -9
  75. package/src/descriptors/types/index.ts +44 -24
  76. package/src/index.ts +28 -21
  77. package/src/types/index.ts +101 -69
  78. package/src/utils/clone.ts +11 -0
  79. package/src/utils/collectConstructors.ts +4 -2
  80. package/src/utils/exception.ts +16 -0
  81. package/src/utils/extract.ts +5 -2
  82. package/src/utils/fork.ts +57 -0
  83. package/src/utils/index.ts +32 -13
  84. package/src/utils/merge.ts +18 -6
  85. package/src/utils/parent.ts +4 -6
  86. package/src/utils/parse.ts +5 -4
  87. package/src/utils/pick.ts +10 -2
  88. package/src/utils/sibling.ts +33 -0
  89. package/src/utils/toJSON.ts +3 -2
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
- import { _Internal_TC_ } from '../../types';
3
+ import {
4
+ _Internal_TC_,
5
+ TypeDef
6
+ } from '../../types';
4
7
 
5
8
  interface SubtypeEntry {
6
9
  TypeName: string;
@@ -21,148 +24,31 @@ const {
21
24
  reflectPrimitiveWrappers
22
25
  } = TypesUtils;
23
26
 
24
- import { extract } from '../../utils/extract';
25
- import { parent } from '../../utils/parent';
26
- import { pick } from '../../utils/pick';
27
-
28
- import exceptionConstructor from '../errors/exceptionConstructor';
29
-
30
27
  import { InstanceCreator } from './InstanceCreator';
31
28
 
32
29
  import {
33
- _getProps, Props
30
+ _getProps, Props
34
31
  } from './Props';
35
32
 
36
33
  const getDefaultPrototype = () => {
37
- return Object.create(null);
34
+ const result = Object.create(null);
35
+ return result;
38
36
  };
39
37
 
40
38
  // const InstanceRoots = new WeakMap;
41
39
 
42
- const MnemonicaProtoProps = {
43
-
44
- extract () {
45
- return function (this: object) {
46
- const result = extract(this);
47
- return result;
48
- };
49
- },
50
-
51
- pick () {
52
- return function (this: object, ...args: (string | string[])[]) {
53
- const result = pick(
54
- this,
55
- ...args
56
- );
57
- return result;
58
- };
59
- },
60
-
61
- parent () {
62
- return function (this: object, constructorLookupPath: string) {
63
- const result = parent(
64
- this,
65
- constructorLookupPath
66
- );
67
- return result;
68
- };
69
- },
70
-
71
- clone (this: { fork: () => object }) {
72
- return this.fork();
73
- },
74
-
75
- fork (this: object) {
76
-
77
- const props = _getProps(this) as Props;
78
-
79
- const {
80
- __type__: type,
81
- __collection__: collection,
82
- __parent__: existentInstance,
83
- __args__,
84
- __self__,
85
- } = props;
86
-
87
- const {
88
- isSubType,
89
- TypeName
90
- } = type;
91
-
92
- // 'function', cause might be called with 'new'
93
-
94
- return function (this: object, ...forkArgs: unknown[]) {
95
-
96
- let forked;
97
- const Constructor = isSubType ?
98
- existentInstance :
99
- collection;
100
-
101
- const args = forkArgs.length ? forkArgs : __args__;
102
-
103
-
104
- if (this === __self__) {
105
-
106
- // @ts-expect-error this is definitely a constructor
107
- forked = new (Constructor[ TypeName ])(...args);
108
- } else {
109
- // fork.call ? let's do it !
110
- forked = new InstanceCreator(
111
- type,
112
- reflectPrimitiveWrappers(this),
113
- args
114
- );
115
- }
116
-
117
- return forked;
118
-
119
- };
120
- },
121
-
122
- [ SymbolConstructorName ] () {
123
- return MNEMONICA;
124
- },
125
-
126
- exception () {
127
-
128
- const self = this;
129
- return function (error: Error, ...args: unknown[]) {
130
- const target = new.target;
131
- return exceptionConstructor.call(
132
- self,
133
- target,
134
- error,
135
- ...args
136
- );
137
- };
138
- },
139
-
140
- sibling () {
141
-
142
- const siblings = (SiblingTypeName: string) => {
143
-
144
- const props = _getProps(this) as Props;
145
- const { __collection__: collection, } = props;
146
- const sibling: unknown = collection[ SiblingTypeName ];
147
- return sibling;
148
- };
149
-
150
- return new Proxy(
151
- siblings,
152
- {
153
- get (_, prop: string) {
154
- const result = siblings(prop);
155
- return result;
156
- },
157
- apply (_, __, args,) {
158
- const result = siblings(args[ 0 ]);
159
- return result;
160
- }
161
- }
162
- );
163
- }
164
-
165
- };
40
+ // Names that used to be auto-injected instance methods. They must still be
41
+ // treated as static/reserved names so the Mnemosyne proxy does not try to
42
+ // construct a subtype when one of them is accessed.
43
+ const mnemonicaInstanceMethodNames = [
44
+ 'extract',
45
+ 'pick',
46
+ 'parent',
47
+ 'clone',
48
+ 'fork',
49
+ 'exception',
50
+ 'sibling',
51
+ ];
166
52
 
167
53
  const staticProps = [
168
54
 
@@ -186,7 +72,7 @@ const staticProps = [
186
72
  'showDiff',
187
73
 
188
74
  ]
189
- .concat(Object.keys(MnemonicaProtoProps))
75
+ .concat(mnemonicaInstanceMethodNames)
190
76
  .concat(Object.getOwnPropertyNames(Object.prototype))
191
77
  .concat(Object.getOwnPropertyNames(Function.prototype))
192
78
  .reduce(
@@ -200,52 +86,31 @@ const staticProps = [
200
86
  // tslint:disable-next-line: only-arrow-functions
201
87
  const makeSubTypeProxy = function (subtype: SubtypeEntry, inheritedInstance: unknown) {
202
88
 
203
- const subtypeProxy = new Proxy(
204
- InstanceCreator,
205
- {
206
-
207
- get (Target, _prop) {
208
-
209
- if (_prop === Symbol.hasInstance) {
210
- const result = getTypeChecker(subtype.TypeName);
211
- return result;
212
- }
213
-
214
- return Reflect.get(
215
- Target,
216
- _prop
217
- );
218
-
219
- },
220
-
221
- construct (Target, _args) {
222
- return new Target(
223
- subtype,
224
- inheritedInstance,
225
- _args
226
- );
227
- },
228
-
229
- apply (Target, thisArg, _args) {
230
-
231
- if (thisArg === undefined) {
232
- thisArg = inheritedInstance;
233
- }
234
-
235
- const existentInstance = reflectPrimitiveWrappers(thisArg);
236
-
237
- const entity = new Target(
238
- subtype,
239
- existentInstance,
240
- _args
241
- );
242
- return entity;
243
- },
244
-
89
+ const SubTypeProxy = function (this: unknown, ..._args: unknown[]) {
90
+ if (new.target) {
91
+ const instanceResult = new InstanceCreator(
92
+ subtype as TypeDef,
93
+ inheritedInstance as object,
94
+ _args
95
+ );
96
+ return instanceResult;
245
97
  }
246
- );
98
+ const thisArg = this === undefined ? inheritedInstance : this;
99
+ const existentInstance = reflectPrimitiveWrappers(thisArg);
100
+ const instance = new InstanceCreator(
101
+ subtype as TypeDef,
102
+ existentInstance as object,
103
+ _args
104
+ );
105
+ return instance;
106
+ };
247
107
 
248
- return subtypeProxy;
108
+ const typeChecker = getTypeChecker(subtype.TypeName);
109
+ Object.defineProperty(SubTypeProxy, Symbol.hasInstance, {
110
+ value : typeChecker
111
+ });
112
+
113
+ return SubTypeProxy;
249
114
  };
250
115
 
251
116
  const prepareSubtypeForConstruction = function (subtypeName: string, inheritedInstance: unknown) {
@@ -270,14 +135,15 @@ const prepareSubtypeForConstruction = function (subtypeName: string, inheritedIn
270
135
  strictChain ?
271
136
  undefined :
272
137
  findSubTypeFromParent(
273
- inheritedInstance as object,
274
- subtypeName
138
+ inheritedInstance as object,
139
+ subtypeName
275
140
  );
276
141
 
277
- return subtype ? makeSubTypeProxy(
142
+ const result = subtype ? makeSubTypeProxy(
278
143
  subtype,
279
144
  inheritedInstance
280
145
  ) : undefined;
146
+ return result;
281
147
  };
282
148
 
283
149
  const mnemosyneProxyHandlerGet = (target: object, prop: string, receiver: unknown) => {
@@ -316,11 +182,12 @@ const mnemosyneProxyHandlerGet = (target: object, prop: string, receiver: unknow
316
182
  prop,
317
183
  receiver
318
184
  );
319
- return subtype || result;
185
+ const subTypeResult = subtype || result;
186
+ return subTypeResult;
320
187
  };
321
188
 
322
- export const Mnemosyne = function (this: object, mnemonica: object, exposeInstanceMethods: boolean) {
323
-
189
+ export const Mnemosyne = function (this: object, mnemonica: object) {
190
+
324
191
  const instance = this;
325
192
 
326
193
  // because we must instantiate new chain for root
@@ -336,8 +203,8 @@ export const Mnemosyne = function (this: object, mnemonica: object, exposeInstan
336
203
  }
337
204
  }
338
205
  );
339
- } as _Internal_TC_<typeof MnemonicaProtoProps>;
340
-
206
+ } as _Internal_TC_<object>;
207
+
341
208
  // this throws an error
342
209
  Object.setPrototypeOf(
343
210
  Mnemonica.prototype,
@@ -346,38 +213,15 @@ export const Mnemosyne = function (this: object, mnemonica: object, exposeInstan
346
213
  // while this just returns false, silently ... unfortunately
347
214
  // Reflect.setPrototypeOf(Mnemonica.prototype, mnemonica);
348
215
 
349
- // Only add MnemonicaProtoProps methods if exposeInstanceMethods is true
350
- if (exposeInstanceMethods) {
351
- Object.entries(MnemonicaProtoProps).forEach(([ name, method ]: [string, unknown]) => {
352
- odp(
353
- Mnemonica.prototype,
354
- name,
355
- {
356
- get () {
357
-
358
- // @ts-expect-error there is a proxy and next line is callable
359
- return method.call(this);
360
- }
361
- }
362
- );
363
- });
364
-
365
- Object.getOwnPropertySymbols(MnemonicaProtoProps).forEach((symbol: symbol) => {
366
- odp(
367
- Mnemonica.prototype,
368
- symbol,
369
- {
370
- get () {
371
- const symbolMethod = Reflect.get(
372
- MnemonicaProtoProps,
373
- symbol
374
- );
375
- return symbolMethod.call(this);
376
- }
377
- }
378
- );
379
- });
380
- }
216
+ odp(
217
+ Mnemonica.prototype,
218
+ SymbolConstructorName,
219
+ {
220
+ get () {
221
+ return MNEMONICA;
222
+ }
223
+ }
224
+ );
381
225
 
382
226
  // instance of self Constructor type
383
227
  odp(
@@ -401,21 +245,18 @@ export const Mnemosyne = function (this: object, mnemonica: object, exposeInstan
401
245
 
402
246
  } as _Internal_TC_<object>;
403
247
 
404
- const createMnemosyne = function (Uranus: unknown, exposeInstanceMethods: boolean) {
405
- // const createMnemosyne = function (Uranus: unknown, typeProxy: unknown) {
406
- // if (typeof Uranus === 'undefined') {
407
- // const { __type__: type, Uranus: _uranus } = typeProxy;
408
- // console.log(type, _uranus);
409
- // // eslint-disable-next-line no-debugger
410
- // debugger;
411
- // throw new Error('createMnemosyne Uranus is not defined for typeProxy.');
412
- // }
248
+ const createMnemosyne = function (Uranus: unknown) {
249
+ // const createMnemosyne = function (Uranus: unknown, typeProxy: unknown) {
250
+ // if (typeof Uranus === 'undefined') {
251
+ // const { __type__: type, Uranus: _uranus } = typeProxy;
252
+ // console.log(type, _uranus);
253
+ // // eslint-disable-next-line no-debugger
254
+ // debugger;
255
+ // throw new Error('createMnemosyne Uranus is not defined for typeProxy.');
256
+ // }
413
257
 
414
258
  const uranus = reflectPrimitiveWrappers(Uranus);
415
- const mnemosyne = new Mnemosyne(
416
- uranus,
417
- exposeInstanceMethods
418
- );
259
+ const mnemosyne = new Mnemosyne(uranus);
419
260
  const mnemosyneProxy = new Proxy(
420
261
  mnemosyne,
421
262
  {
@@ -113,7 +113,8 @@ export const _addProps = function (this: InstanceCreatorContext): void {
113
113
  '__stack__',
114
114
  {
115
115
  get () {
116
- return stack!.join('\n');
116
+ const result = stack!.join('\n');
117
+ return result;
117
118
  }
118
119
  }
119
120
  );
@@ -215,7 +216,8 @@ export const getProps = (instance: object): PropsType | undefined => {
215
216
  answer,
216
217
  descriptors
217
218
  );
218
- return answer as PropsType;
219
+ const result = answer as PropsType;
220
+ return result;
219
221
  } else {
220
222
  return props;
221
223
  }
@@ -85,13 +85,15 @@ TypeProxy.prototype.get = function (this: TypeProxyInstance, target: _Internal_T
85
85
 
86
86
  // SomeType.SomeSubType
87
87
  if (type.subtypes.has(prop)) {
88
- return type.subtypes.get(prop);
88
+ const subtypeResult = type.subtypes.get(prop);
89
+ return subtypeResult;
89
90
  }
90
91
 
91
- return Reflect.get(
92
+ const reflectResult = Reflect.get(
92
93
  target,
93
94
  prop
94
95
  );
96
+ return reflectResult;
95
97
 
96
98
  };
97
99
 
@@ -137,7 +139,8 @@ const subTypeApply = (
137
139
  cstr,
138
140
  cfg
139
141
  );
140
- return defineResult as unknown as T;
142
+ const result = defineResult as unknown as T;
143
+ return result;
141
144
  };
142
145
  return decorator;
143
146
  };
@@ -196,14 +199,7 @@ TypeProxy.prototype.construct = function (this: TypeProxyInstance, _target: unkn
196
199
  // then we should rely on that somehow
197
200
  const uranus = type.isSubType ? getDefaultPrototype() : Uranus;
198
201
 
199
- // Get exposeInstanceMethods from type config, defaulting to false
200
- const config = type.config as { exposeInstanceMethods?: boolean } | undefined;
201
- const exposeInstanceMethods = config!.exposeInstanceMethods as unknown as boolean;
202
-
203
- const mnemosyneProxy = createMnemosyne(
204
- uranus,
205
- exposeInstanceMethods
206
- );
202
+ const mnemosyneProxy = createMnemosyne(uranus);
207
203
  const instance = new InstanceCreator(
208
204
  type,
209
205
  mnemosyneProxy,
@@ -51,18 +51,20 @@ const getClassConstructor = (
51
51
  ConstructHandler: ClassConstructHandler,
52
52
  CreationHandler: CreationHandler,
53
53
  ) => {
54
- return class extends ConstructHandler {
54
+ const result = class extends ConstructHandler {
55
55
  // oxlint-disable-next-line constructor-super
56
56
  constructor ( ...args: unknown[] ) {
57
57
  const answer = super( ...args );
58
58
  // debugger;
59
- const result = CreationHandler.call(
59
+ const creationResult = CreationHandler.call(
60
60
  this,
61
61
  answer
62
62
  );
63
- return result as object;
63
+ const castResult = creationResult as object;
64
+ return castResult;
64
65
  }
65
66
  };
67
+ return result;
66
68
  };
67
69
 
68
70
  const getFunctionConstructor = (
@@ -79,7 +81,7 @@ const getFunctionConstructor = (
79
81
  ) &&
80
82
  (ConstructHandler.prototype.constructor == ConstructHandler);
81
83
 
82
- return function ( this: object, ...args: unknown[] ) {
84
+ const funcResult = function ( this: object, ...args: unknown[] ) {
83
85
  let answer;
84
86
  // if (!new.target) {
85
87
  // debugger;
@@ -103,17 +105,18 @@ const getFunctionConstructor = (
103
105
  );
104
106
  return result;
105
107
  };
108
+ return funcResult;
106
109
  };
107
110
 
108
111
  type ModificationBody = new (...args: unknown[]) => object;
109
112
 
110
113
  const compileNewModificatorFunctionBody = function ( FunctionName: string, asClass = false ) {
111
- return function (
114
+ const outerResult = function (
112
115
  ConstructHandler: ConstructHandler,
113
116
  CreationHandler: CreationHandler,
114
117
  SymbolConstructorName: symbol
115
118
  ): () => ModificationBody {
116
- return function (): ModificationBody {
119
+ const innerResult = function (): ModificationBody {
117
120
  let ModificationBody: ModificationBody;
118
121
  if ( asClass ) {
119
122
  ModificationBody = getClassConstructor(
@@ -151,9 +154,12 @@ const compileNewModificatorFunctionBody = function ( FunctionName: string, asCla
151
154
  // Object.freeze( ModificationBody.prototype.constructor );
152
155
  // Object.freeze( ModificationBody.prototype );
153
156
  // Object.freeze( ModificationBody );
154
- return ModificationBody;
157
+ const result = ModificationBody;
158
+ return result;
155
159
  };
160
+ return innerResult;
156
161
  };
162
+ return outerResult;
157
163
  };
158
164
 
159
165
  export default compileNewModificatorFunctionBody;
@@ -182,7 +182,8 @@ const TypeDescriptor = function (
182
182
 
183
183
  // types.set( TypeName, new TypeProxy( type ) );
184
184
 
185
- return types.get(TypeName);
185
+ const result = types.get(TypeName);
186
+ return result;
186
187
 
187
188
  } as unknown as _Internal_TC_<TypeDescriptorInstance>;
188
189
 
@@ -197,23 +198,25 @@ TypeDescriptor.prototype.define = function (
197
198
  constructHandlerOrConfig?: CallableFunction | object,
198
199
  config?: object
199
200
  ) {
200
- return define.call(
201
+ const result = define.call(
201
202
  define,
202
203
  this.subtypes as TypesMap,
203
204
  TypeOrTypeName,
204
205
  constructHandlerOrConfig,
205
206
  config
206
207
  );
208
+ return result;
207
209
  };
208
210
 
209
211
  TypeDescriptor.prototype.lookup = function (
210
212
  this: TypeDescriptorInstance,
211
213
  TypeNestedPath: string
212
214
  ) {
213
- return lookup.call(
215
+ const result = lookup.call(
214
216
  this.subtypes as TypesMap,
215
217
  TypeNestedPath
216
218
  );
219
+ return result;
217
220
  };
218
221
 
219
222
  odp(
@@ -297,8 +300,9 @@ const isLazyGetter = function (handler: ConstructHandler | LazyTypeGetter): bool
297
300
  // Probe: try to call as a lazy getter. If it succeeds and returns a named
298
301
  // function, it's a lazy getter. Otherwise (throws or returns non-function),
299
302
  // it's a direct handler. The cast is the probe — runtime decides which it is.
300
- const result = (handler as LazyTypeGetter)();
301
- return result instanceof Function && result.name.length > 0;
303
+ const lazyResult = (handler as LazyTypeGetter)();
304
+ const result = lazyResult instanceof Function && lazyResult.name.length > 0;
305
+ return result;
302
306
  } catch {
303
307
  return false;
304
308
  }
@@ -346,7 +350,7 @@ const createFromDirectHandler = function (
346
350
  (typeof handler.prototype === 'object')
347
351
  ) ? handler.prototype : getDefaultPrototype();
348
352
 
349
- return new TypeDescriptor(
353
+ const result = new TypeDescriptor(
350
354
  defineOrigin,
351
355
  target,
352
356
  name,
@@ -354,6 +358,7 @@ const createFromDirectHandler = function (
354
358
  proto,
355
359
  config
356
360
  ) as unknown as TypeClass;
361
+ return result;
357
362
  };
358
363
 
359
364
  const createFromLazyGetter = function (
@@ -406,7 +411,7 @@ const createFromLazyGetter = function (
406
411
 
407
412
  config.asClass = asClass;
408
413
 
409
- return new TypeDescriptor(
414
+ const result = new TypeDescriptor(
410
415
  defineOrigin,
411
416
  target,
412
417
  TypeName,
@@ -414,6 +419,7 @@ const createFromLazyGetter = function (
414
419
  type.prototype,
415
420
  config
416
421
  ) as unknown as TypeClass;
422
+ return result;
417
423
  };
418
424
 
419
425
  // ============================================================
@@ -545,10 +551,11 @@ export const lookup = function (
545
551
  if (!type) {
546
552
  return undefined;
547
553
  }
548
- return lookup.call(
554
+ const result = lookup.call(
549
555
  type.subtypes as unknown as TypesMap,
550
556
  NextNestedPath
551
557
  );
558
+ return result;
552
559
 
553
560
  };
554
561
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { constants } from '../../constants';
4
4
  import { ErrorsTypes } from '../../descriptors/errors';
5
- import { utils } from '../../utils';
5
+ import { collectConstructors } from '../../utils/collectConstructors';
6
6
 
7
7
  const {
8
8
  odp,
@@ -13,8 +13,6 @@ const {
13
13
 
14
14
  const { WRONG_TYPE_DEFINITION, } = ErrorsTypes;
15
15
 
16
- const { collectConstructors } = utils;
17
-
18
16
  import {
19
17
  _getProps, Props
20
18
  } from '../types/Props';
@@ -51,15 +49,14 @@ const getTypeChecker = (TypeName: string) => {
51
49
  // if ( instance instanceof Promise ) {
52
50
 
53
51
  // @ts-expect-error I'm too lazy for that
54
- return instance[ SymbolConstructorName ] === TypeName;
52
+ const checkResult = instance[ SymbolConstructorName ] === TypeName;
53
+ return checkResult;
55
54
  }
56
55
 
57
- const constructors: {
58
- string: new () => unknown
59
- } = collectConstructors(instance);
56
+ const constructors = collectConstructors(instance) as Record<string, new () => unknown>;
60
57
 
61
- // @ts-expect-error I'm too lazy for that
62
- return constructors[ TypeName ] || false;
58
+ const constructorResult = constructors[ TypeName ] || false;
59
+ return constructorResult;
63
60
 
64
61
  };
65
62
  return seeker;
@@ -204,7 +201,8 @@ const findSubTypeFromParent = (instance: parentSub | object | undefined, subType
204
201
  const isClass = (fn: ConstructHandler) => {
205
202
 
206
203
  const str = String(fn);
207
- return str.indexOf('class ') === 0;
204
+ const result = str.indexOf('class ') === 0;
205
+ return result;
208
206
 
209
207
  /*
210
208
 
@@ -253,7 +251,8 @@ const makeErrorModificatorType = (
253
251
  );
254
252
 
255
253
  const result = modificatorType();
256
- return result as MnemonicaConstructor;
254
+ const constructorResult = result as MnemonicaConstructor;
255
+ return constructorResult;
257
256
 
258
257
  };
259
258
 
@@ -269,9 +268,10 @@ const reflectPrimitiveWrappers = (_thisArg: unknown) => {
269
268
  Symbol.toPrimitive,
270
269
  {
271
270
  get () {
272
- return () => {
271
+ const result = () => {
273
272
  return _thisArg;
274
273
  };
274
+ return result;
275
275
  }
276
276
  }
277
277
  );
@@ -287,9 +287,11 @@ const reflectPrimitiveWrappers = (_thisArg: unknown) => {
287
287
  Symbol.toPrimitive,
288
288
  {
289
289
  get () {
290
- return () => {
291
- return (_thisArg as String | Number | Boolean).valueOf();
290
+ const result = () => {
291
+ const valueResult = (_thisArg as String | Number | Boolean).valueOf();
292
+ return valueResult;
292
293
  };
294
+ return result;
293
295
  }
294
296
  }
295
297
  );