typia 7.0.0-dev.20240928 → 7.0.0-dev.20240930

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 (40) hide show
  1. package/lib/factories/internal/metadata/emplace_metadata_object.js +2 -1
  2. package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
  3. package/lib/programmers/AssertProgrammer.js +14 -10
  4. package/lib/programmers/AssertProgrammer.js.map +1 -1
  5. package/lib/programmers/CheckerProgrammer.d.ts +5 -1
  6. package/lib/programmers/CheckerProgrammer.js +161 -135
  7. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  8. package/lib/programmers/FeatureProgrammer.d.ts +91 -28
  9. package/lib/programmers/FeatureProgrammer.js +158 -139
  10. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  11. package/lib/programmers/IsProgrammer.d.ts +5 -1
  12. package/lib/programmers/IsProgrammer.js +70 -67
  13. package/lib/programmers/IsProgrammer.js.map +1 -1
  14. package/lib/programmers/ValidateProgrammer.js +7 -3
  15. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  16. package/lib/programmers/helpers/UnionExplorer.js +31 -6
  17. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  18. package/lib/programmers/internal/feature_object_entries.js +18 -14
  19. package/lib/programmers/internal/feature_object_entries.js.map +1 -1
  20. package/lib/programmers/json/JsonStringifyProgrammer.js +101 -62
  21. package/lib/programmers/json/JsonStringifyProgrammer.js.map +1 -1
  22. package/lib/programmers/misc/MiscCloneProgrammer.js +101 -62
  23. package/lib/programmers/misc/MiscCloneProgrammer.js.map +1 -1
  24. package/lib/programmers/misc/MiscPruneProgrammer.js +97 -62
  25. package/lib/programmers/misc/MiscPruneProgrammer.js.map +1 -1
  26. package/lib/programmers/notations/NotationGeneralProgrammer.js +118 -60
  27. package/lib/programmers/notations/NotationGeneralProgrammer.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/factories/internal/metadata/emplace_metadata_object.ts +2 -1
  30. package/src/programmers/AssertProgrammer.ts +14 -10
  31. package/src/programmers/CheckerProgrammer.ts +139 -134
  32. package/src/programmers/FeatureProgrammer.ts +324 -266
  33. package/src/programmers/IsProgrammer.ts +80 -77
  34. package/src/programmers/ValidateProgrammer.ts +7 -3
  35. package/src/programmers/helpers/UnionExplorer.ts +33 -12
  36. package/src/programmers/internal/feature_object_entries.ts +18 -15
  37. package/src/programmers/json/JsonStringifyProgrammer.ts +103 -76
  38. package/src/programmers/misc/MiscCloneProgrammer.ts +122 -95
  39. package/src/programmers/misc/MiscPruneProgrammer.ts +111 -90
  40. package/src/programmers/notations/NotationGeneralProgrammer.ts +138 -91
@@ -20,8 +20,8 @@ import { feature_object_entries } from "./internal/feature_object_entries";
20
20
 
21
21
  export namespace FeatureProgrammer {
22
22
  /* -----------------------------------------------------------
23
- PARAMETERS
24
- ----------------------------------------------------------- */
23
+ PARAMETERS
24
+ ----------------------------------------------------------- */
25
25
  export interface IConfig<Output extends ts.ConciseBody = ts.ConciseBody> {
26
26
  types: IConfig.ITypes;
27
27
 
@@ -45,16 +45,20 @@ export namespace FeatureProgrammer {
45
45
  /**
46
46
  * Initializer of metadata.
47
47
  */
48
- initializer: (
49
- context: ITypiaContext,
50
- ) => (
51
- importer: FunctionImporter,
52
- ) => (type: ts.Type) => [MetadataCollection, Metadata];
48
+ initializer: (props: {
49
+ context: ITypiaContext;
50
+ importer: FunctionImporter;
51
+ type: ts.Type;
52
+ }) => [MetadataCollection, Metadata];
53
53
 
54
54
  /**
55
55
  * Decoder, station of every types.
56
56
  */
57
- decoder: () => Decoder<Metadata, Output>;
57
+ decoder: (props: {
58
+ metadata: Metadata;
59
+ input: ts.Expression;
60
+ explore: IExplore;
61
+ }) => Output;
58
62
 
59
63
  /**
60
64
  * Object configurator.
@@ -76,12 +80,20 @@ export namespace FeatureProgrammer {
76
80
  /**
77
81
  * Type checker when union object type comes.
78
82
  */
79
- checker: () => Decoder<Metadata, ts.Expression>;
83
+ checker: (props: {
84
+ metadata: Metadata;
85
+ input: ts.Expression;
86
+ explore: IExplore;
87
+ }) => ts.Expression;
80
88
 
81
89
  /**
82
90
  * Decoder, function call expression generator of specific typed objects.
83
91
  */
84
- decoder: () => Decoder<MetadataObject, ts.Expression>;
92
+ decoder: (props: {
93
+ input: ts.Expression;
94
+ object: MetadataObject;
95
+ explore: IExplore;
96
+ }) => ts.Expression;
85
97
 
86
98
  /**
87
99
  * Joiner of expressions from properties.
@@ -98,21 +110,23 @@ export namespace FeatureProgrammer {
98
110
  * Expression of an algorithm specifying object type and calling
99
111
  * the `decoder` function of the specified object type.
100
112
  */
101
- unionizer: Decoder<MetadataObject[], ts.Expression>;
113
+ unionizer: (props: {
114
+ objects: MetadataObject[];
115
+ input: ts.Expression;
116
+ explore: IExplore;
117
+ }) => ts.Expression;
102
118
 
103
119
  /**
104
120
  * Handler of union type specification failure.
105
121
  *
106
- * @param value Expression of input parameter
107
- * @param expected Expected type name
108
- * @param explore Exploration info
122
+ * @param props Properties of failure
109
123
  * @returns Statement of failure
110
124
  */
111
- failure(
112
- value: ts.Expression,
113
- expected: string,
114
- explore?: undefined | IExplore,
115
- ): ts.Statement;
125
+ failure(props: {
126
+ input: ts.Expression;
127
+ expected: string;
128
+ explore?: undefined | IExplore;
129
+ }): ts.Statement;
116
130
 
117
131
  /**
118
132
  * Transformer of type checking expression by discrimination.
@@ -153,18 +167,17 @@ export namespace FeatureProgrammer {
153
167
  * iteration type checking would be happend. In such circumstance, you
154
168
  * can wrap the condition with additional function.
155
169
  *
156
- * @param condition Current condition
157
- * @returns A function wrapped current condition
170
+ * @param props Properties of condition
171
+ * @returns The wrapper expression
158
172
  */
159
173
  full?:
160
174
  | undefined
161
- | ((
162
- condition: ts.Expression,
163
- ) => (
164
- input: ts.Expression,
165
- expected: string,
166
- explore: IExplore,
167
- ) => ts.Expression);
175
+ | ((props: {
176
+ condition: ts.Expression;
177
+ input: ts.Expression;
178
+ expected: string;
179
+ explore: IExplore;
180
+ }) => ts.Expression);
168
181
 
169
182
  /**
170
183
  * Return type.
@@ -174,12 +187,12 @@ export namespace FeatureProgrammer {
174
187
  export interface IGenerator {
175
188
  objects?:
176
189
  | undefined
177
- | (() => (col: MetadataCollection) => ts.VariableStatement[]);
190
+ | ((collection: MetadataCollection) => ts.VariableStatement[]);
178
191
  unions?:
179
192
  | undefined
180
- | (() => (col: MetadataCollection) => ts.VariableStatement[]);
181
- arrays(): (col: MetadataCollection) => ts.VariableStatement[];
182
- tuples(): (col: MetadataCollection) => ts.VariableStatement[];
193
+ | ((collection: MetadataCollection) => ts.VariableStatement[]);
194
+ arrays: (collection: MetadataCollection) => ts.VariableStatement[];
195
+ tuples: (collection: MetadataCollection) => ts.VariableStatement[];
183
196
  }
184
197
  }
185
198
 
@@ -191,9 +204,14 @@ export namespace FeatureProgrammer {
191
204
  start?: undefined | number;
192
205
  }
193
206
 
194
- export interface Decoder<T, Output extends ts.ConciseBody = ts.ConciseBody> {
195
- (input: ts.Expression, target: T, explore: IExplore): Output;
196
- }
207
+ export type Decoder<
208
+ T,
209
+ Output extends ts.ConciseBody = ts.ConciseBody,
210
+ > = (props: {
211
+ input: ts.Expression;
212
+ definition: T;
213
+ explore: IExplore;
214
+ }) => Output;
197
215
 
198
216
  /* -----------------------------------------------------------
199
217
  GENERATORS
@@ -218,15 +236,17 @@ export namespace FeatureProgrammer {
218
236
  type: ts.Type;
219
237
  name: string | undefined;
220
238
  }): IComposed => {
221
- const [collection, meta] = props.config.initializer(props.context)(
222
- props.importer,
223
- )(props.type);
239
+ const [collection, metadata] = props.config.initializer(props);
224
240
  return {
225
- body: props.config.decoder()(ValueFactory.INPUT(), meta, {
226
- tracable: props.config.path || props.config.trace,
227
- source: "top",
228
- from: "top",
229
- postfix: '""',
241
+ body: props.config.decoder({
242
+ input: ValueFactory.INPUT(),
243
+ metadata,
244
+ explore: {
245
+ tracable: props.config.path || props.config.trace,
246
+ source: "top",
247
+ from: "top",
248
+ postfix: '""',
249
+ },
230
250
  }),
231
251
  statements: props.config.addition
232
252
  ? props.config.addition(collection)
@@ -234,7 +254,7 @@ export namespace FeatureProgrammer {
234
254
  functions: {
235
255
  ...Object.fromEntries(
236
256
  (
237
- props.config.generator.objects?.()(collection) ??
257
+ props.config.generator.objects?.(collection) ??
238
258
  write_object_functions({
239
259
  ...props,
240
260
  collection,
@@ -243,24 +263,29 @@ export namespace FeatureProgrammer {
243
263
  ),
244
264
  ...Object.fromEntries(
245
265
  (
246
- props.config.generator.unions?.() ??
247
- write_union_functions(props.config)
248
- )(collection).map((v, i) => [`${props.config.prefix}u${i}`, v]),
266
+ props.config.generator.unions?.(collection) ??
267
+ write_union_functions({
268
+ config: props.config,
269
+ collection,
270
+ })
271
+ ).map((v, i) => [`${props.config.prefix}u${i}`, v]),
249
272
  ),
250
273
  ...Object.fromEntries(
251
274
  props.config.generator
252
- .arrays()(collection)
275
+ .arrays(collection)
253
276
  .map((v, i) => [`${props.config.prefix}a${i}`, v]),
254
277
  ),
255
278
  ...Object.fromEntries(
256
279
  props.config.generator
257
- .tuples()(collection)
280
+ .tuples(collection)
258
281
  .map((v, i) => [`${props.config.prefix}t${i}`, v]),
259
282
  ),
260
283
  },
261
- parameters: parameterDeclarations(props.config)(
262
- props.config.types.input(props.type, props.name),
263
- )(ValueFactory.INPUT()),
284
+ parameters: parameterDeclarations({
285
+ config: props.config,
286
+ type: props.config.types.input(props.type, props.name),
287
+ input: ValueFactory.INPUT(),
288
+ }),
264
289
  response: props.config.types.output(props.type, props.name),
265
290
  };
266
291
  };
@@ -290,73 +315,81 @@ export namespace FeatureProgrammer {
290
315
  undefined,
291
316
  );
292
317
 
293
- export const write =
294
- (context: ITypiaContext) =>
295
- (config: IConfig) =>
296
- (importer: FunctionImporter) =>
297
- (type: ts.Type, name?: string): ts.ArrowFunction => {
298
- const [collection, meta] = config.initializer(context)(importer)(type);
299
-
300
- // ITERATE OVER ALL METADATA
301
- const output: ts.ConciseBody = config.decoder()(
302
- ValueFactory.INPUT(),
303
- meta,
304
- {
305
- tracable: config.path || config.trace,
306
- source: "top",
307
- from: "top",
308
- postfix: '""',
309
- },
310
- );
311
-
312
- // RETURNS THE OPTIMAL ARROW FUNCTION
313
- const functions = {
314
- objects:
315
- config.generator.objects?.()(collection) ??
316
- write_object_functions({
317
- config,
318
- importer,
319
- collection,
320
- }),
321
- unions: (config.generator.unions?.() ?? write_union_functions(config))(
318
+ export const write = (props: {
319
+ context: ITypiaContext;
320
+ config: IConfig;
321
+ importer: FunctionImporter;
322
+ type: ts.Type;
323
+ name?: string | undefined;
324
+ }): ts.ArrowFunction => {
325
+ // ITERATE OVER ALL METADATA
326
+ const [collection, metadata] = props.config.initializer(props);
327
+ const output: ts.ConciseBody = props.config.decoder({
328
+ metadata,
329
+ input: ValueFactory.INPUT(),
330
+ explore: {
331
+ tracable: props.config.path || props.config.trace,
332
+ source: "top",
333
+ from: "top",
334
+ postfix: '""',
335
+ },
336
+ });
337
+
338
+ // RETURNS THE OPTIMAL ARROW FUNCTION
339
+ const functions = {
340
+ objects:
341
+ props.config.generator.objects?.(collection) ??
342
+ write_object_functions({
343
+ config: props.config,
344
+ importer: props.importer,
322
345
  collection,
323
- ),
324
- arrays: config.generator.arrays()(collection),
325
- tuples: config.generator.tuples()(collection),
326
- };
327
- const added: ts.Statement[] = (config.addition ?? (() => []))(collection);
328
-
329
- return ts.factory.createArrowFunction(
330
- undefined,
331
- undefined,
332
- parameterDeclarations(config)(config.types.input(type, name))(
333
- ValueFactory.INPUT(),
334
- ),
335
- config.types.output(type, name),
336
- undefined,
337
- ts.factory.createBlock(
338
- [
339
- ...added,
340
- ...functions.objects.filter((_, i) =>
341
- importer.hasLocal(`${config.prefix}o${i}`),
342
- ),
343
- ...functions.unions.filter((_, i) =>
344
- importer.hasLocal(`${config.prefix}u${i}`),
345
- ),
346
- ...functions.arrays.filter((_, i) =>
347
- importer.hasLocal(`${config.prefix}a${i}`),
348
- ),
349
- ...functions.tuples.filter((_, i) =>
350
- importer.hasLocal(`${config.prefix}t${i}`),
351
- ),
352
- ...(ts.isBlock(output)
353
- ? output.statements
354
- : [ts.factory.createReturnStatement(output)]),
355
- ],
356
- true,
357
- ),
358
- );
346
+ }),
347
+ unions:
348
+ props.config.generator.unions?.(collection) ??
349
+ write_union_functions({
350
+ config: props.config,
351
+ collection,
352
+ }),
353
+ arrays: props.config.generator.arrays(collection),
354
+ tuples: props.config.generator.tuples(collection),
359
355
  };
356
+ const added: ts.Statement[] = (props.config.addition ?? (() => []))(
357
+ collection,
358
+ );
359
+
360
+ return ts.factory.createArrowFunction(
361
+ undefined,
362
+ undefined,
363
+ parameterDeclarations({
364
+ config: props.config,
365
+ type: props.config.types.input(props.type, props.name),
366
+ input: ValueFactory.INPUT(),
367
+ }),
368
+ props.config.types.output(props.type, props.name),
369
+ undefined,
370
+ ts.factory.createBlock(
371
+ [
372
+ ...added,
373
+ ...functions.objects.filter((_, i) =>
374
+ props.importer.hasLocal(`${props.config.prefix}o${i}`),
375
+ ),
376
+ ...functions.unions.filter((_, i) =>
377
+ props.importer.hasLocal(`${props.config.prefix}u${i}`),
378
+ ),
379
+ ...functions.arrays.filter((_, i) =>
380
+ props.importer.hasLocal(`${props.config.prefix}a${i}`),
381
+ ),
382
+ ...functions.tuples.filter((_, i) =>
383
+ props.importer.hasLocal(`${props.config.prefix}t${i}`),
384
+ ),
385
+ ...(ts.isBlock(output)
386
+ ? output.statements
387
+ : [ts.factory.createReturnStatement(output)]),
388
+ ],
389
+ true,
390
+ ),
391
+ );
392
+ };
360
393
 
361
394
  export const write_object_functions = (props: {
362
395
  config: IConfig;
@@ -369,9 +402,11 @@ export namespace FeatureProgrammer {
369
402
  ts.factory.createArrowFunction(
370
403
  undefined,
371
404
  undefined,
372
- parameterDeclarations(props.config)(TypeFactory.keyword("any"))(
373
- ValueFactory.INPUT(),
374
- ),
405
+ parameterDeclarations({
406
+ config: props.config,
407
+ type: TypeFactory.keyword("any"),
408
+ input: ValueFactory.INPUT(),
409
+ }),
375
410
  props.config.objector.type ?? TypeFactory.keyword("any"),
376
411
  undefined,
377
412
  props.config.objector.joiner({
@@ -385,172 +420,195 @@ export namespace FeatureProgrammer {
385
420
  ),
386
421
  );
387
422
 
388
- export const write_union_functions =
389
- (config: IConfig) => (collection: MetadataCollection) =>
390
- collection
391
- .unions()
392
- .map((union, i) =>
393
- StatementFactory.constant(
394
- `${config.prefix}u${i}`,
395
- write_union(config)(union),
396
- ),
397
- );
423
+ export const write_union_functions = (props: {
424
+ config: IConfig;
425
+ collection: MetadataCollection;
426
+ }) =>
427
+ props.collection.unions().map((union, i) =>
428
+ StatementFactory.constant(
429
+ `${props.config.prefix}u${i}`,
430
+ write_union({
431
+ config: props.config,
432
+ objects: union,
433
+ }),
434
+ ),
435
+ );
398
436
 
399
- const write_union = (config: IConfig) => {
400
- const explorer = UnionExplorer.object(config);
437
+ const write_union = (props: {
438
+ config: IConfig;
439
+ objects: MetadataObject[];
440
+ }) => {
441
+ const explorer = UnionExplorer.object(props.config);
401
442
  const input = ValueFactory.INPUT();
402
-
403
- return (meta: MetadataObject[]) =>
404
- ts.factory.createArrowFunction(
405
- undefined,
406
- undefined,
407
- parameterDeclarations(config)(TypeFactory.keyword("any"))(
408
- ValueFactory.INPUT(),
409
- ),
410
- TypeFactory.keyword("any"),
411
- undefined,
412
- explorer(input, meta, {
413
- tracable: config.path || config.trace,
414
- source: "function",
415
- from: "object",
416
- postfix: "",
417
- }),
418
- );
443
+ return ts.factory.createArrowFunction(
444
+ undefined,
445
+ undefined,
446
+ parameterDeclarations({
447
+ config: props.config,
448
+ type: TypeFactory.keyword("any"),
449
+ input: ValueFactory.INPUT(),
450
+ }),
451
+ TypeFactory.keyword("any"),
452
+ undefined,
453
+ explorer(input, props.objects, {
454
+ tracable: props.config.path || props.config.trace,
455
+ source: "function",
456
+ from: "object",
457
+ postfix: "",
458
+ }),
459
+ );
419
460
  };
420
461
 
421
462
  /* -----------------------------------------------------------
422
463
  DECODERS
423
464
  ----------------------------------------------------------- */
424
- export const decode_array =
425
- (config: Pick<IConfig, "trace" | "path" | "decoder" | "prefix">) =>
426
- (importer: FunctionImporter) =>
427
- (
428
- combiner: (props: {
429
- input: ts.Expression;
430
- arrow: ts.ArrowFunction;
431
- }) => ts.Expression,
432
- ) => {
433
- const rand: string = importer.increment().toString();
434
- const tail =
435
- config.path || config.trace
436
- ? [
437
- IdentifierFactory.parameter(
438
- "_index" + rand,
439
- TypeFactory.keyword("number"),
440
- ),
441
- ]
442
- : [];
443
- return (
444
- input: ts.Expression,
445
- array: MetadataArray,
446
- explore: IExplore,
447
- ) => {
448
- const arrow: ts.ArrowFunction = ts.factory.createArrowFunction(
449
- undefined,
450
- undefined,
451
- [
452
- IdentifierFactory.parameter("elem", TypeFactory.keyword("any")),
453
- ...tail,
454
- ],
455
- undefined,
456
- undefined,
457
- config.decoder()(ValueFactory.INPUT("elem"), array.type.value, {
458
- tracable: explore.tracable,
459
- source: explore.source,
460
- from: "array",
461
- postfix: index(explore.start ?? null)(explore.postfix)(rand),
465
+ export const decode_array = (props: {
466
+ config: Pick<IConfig, "trace" | "path" | "decoder" | "prefix">;
467
+ importer: FunctionImporter;
468
+ combiner: (next: {
469
+ input: ts.Expression;
470
+ arrow: ts.ArrowFunction;
471
+ }) => ts.Expression;
472
+ array: MetadataArray;
473
+ input: ts.Expression;
474
+ explore: IExplore;
475
+ }) => {
476
+ const rand: string = props.importer.increment().toString();
477
+ const tail =
478
+ props.config.path || props.config.trace
479
+ ? [
480
+ IdentifierFactory.parameter(
481
+ "_index" + rand,
482
+ TypeFactory.keyword("number"),
483
+ ),
484
+ ]
485
+ : [];
486
+ const arrow: ts.ArrowFunction = ts.factory.createArrowFunction(
487
+ undefined,
488
+ undefined,
489
+ [
490
+ IdentifierFactory.parameter("elem", TypeFactory.keyword("any")),
491
+ ...tail,
492
+ ],
493
+ undefined,
494
+ undefined,
495
+ props.config.decoder({
496
+ input: ValueFactory.INPUT("elem"),
497
+ metadata: props.array.type.value,
498
+ explore: {
499
+ tracable: props.explore.tracable,
500
+ source: props.explore.source,
501
+ from: "array",
502
+ postfix: index({
503
+ start: props.explore.start ?? null,
504
+ postfix: props.explore.postfix,
505
+ rand,
462
506
  }),
463
- );
464
- return combiner({
465
- input,
466
- arrow,
467
- });
468
- };
469
- };
507
+ },
508
+ }),
509
+ );
510
+ return props.combiner({
511
+ input: props.input,
512
+ arrow,
513
+ });
514
+ };
470
515
 
471
- export const decode_object =
472
- (config: Pick<IConfig, "trace" | "path" | "prefix">) =>
473
- (importer: FunctionImporter) =>
474
- (input: ts.Expression, obj: MetadataObject, explore: IExplore) =>
475
- ts.factory.createCallExpression(
476
- ts.factory.createIdentifier(
477
- importer.useLocal(`${config.prefix}o${obj.index}`),
478
- ),
479
- undefined,
480
- argumentsArray(config)(explore)(input),
481
- );
516
+ export const decode_object = (props: {
517
+ config: Pick<IConfig, "trace" | "path" | "prefix">;
518
+ importer: FunctionImporter;
519
+ object: MetadataObject;
520
+ input: ts.Expression;
521
+ explore: IExplore;
522
+ }) =>
523
+ ts.factory.createCallExpression(
524
+ ts.factory.createIdentifier(
525
+ props.importer.useLocal(`${props.config.prefix}o${props.object.index}`),
526
+ ),
527
+ undefined,
528
+ argumentsArray(props),
529
+ );
482
530
 
483
531
  /* -----------------------------------------------------------
484
532
  UTILITIES FOR INTERNAL FUNCTIONS
485
533
  ----------------------------------------------------------- */
486
- export const index =
487
- (start: number | null) => (prev: string) => (rand: string) => {
488
- const tail: string =
489
- start !== null
490
- ? `"[" + (${start} + _index${rand}) + "]"`
491
- : `"[" + _index${rand} + "]"`;
492
- if (prev === "") return tail;
493
- else if (prev[prev.length - 1] === `"`)
494
- return prev.substring(0, prev.length - 1) + tail.substring(1);
495
- return prev + ` + ${tail}`;
496
- };
534
+ export const index = (props: {
535
+ start: number | null;
536
+ postfix: string;
537
+ rand: string;
538
+ }) => {
539
+ const tail: string =
540
+ props.start !== null
541
+ ? `"[" + (${props.start} + _index${props.rand}) + "]"`
542
+ : `"[" + _index${props.rand} + "]"`;
543
+ if (props.postfix === "") return tail;
544
+ else if (props.postfix[props.postfix.length - 1] === `"`)
545
+ return (
546
+ props.postfix.substring(0, props.postfix.length - 1) + tail.substring(1)
547
+ );
548
+ return props.postfix + ` + ${tail}`;
549
+ };
497
550
 
498
- export const argumentsArray =
499
- (config: Pick<IConfig, "path" | "trace">) =>
500
- (explore: FeatureProgrammer.IExplore) => {
501
- const tail: ts.Expression[] =
502
- config.path === false && config.trace === false
503
- ? []
504
- : config.path === true && config.trace === true
551
+ export const argumentsArray = (props: {
552
+ config: Pick<IConfig, "path" | "trace">;
553
+ input: ts.Expression;
554
+ explore: FeatureProgrammer.IExplore;
555
+ }) => {
556
+ const tail: ts.Expression[] =
557
+ props.config.path === false && props.config.trace === false
558
+ ? []
559
+ : props.config.path === true && props.config.trace === true
560
+ ? [
561
+ ts.factory.createIdentifier(
562
+ props.explore.postfix
563
+ ? `_path + ${props.explore.postfix}`
564
+ : "_path",
565
+ ),
566
+ props.explore.source === "function"
567
+ ? ts.factory.createIdentifier(
568
+ `${props.explore.tracable} && _exceptionable`,
569
+ )
570
+ : props.explore.tracable
571
+ ? ts.factory.createTrue()
572
+ : ts.factory.createFalse(),
573
+ ]
574
+ : props.config.path === true
505
575
  ? [
506
576
  ts.factory.createIdentifier(
507
- explore.postfix ? `_path + ${explore.postfix}` : "_path",
577
+ props.explore.postfix
578
+ ? `_path + ${props.explore.postfix}`
579
+ : "_path",
508
580
  ),
509
- explore.source === "function"
581
+ ]
582
+ : [
583
+ props.explore.source === "function"
510
584
  ? ts.factory.createIdentifier(
511
- `${explore.tracable} && _exceptionable`,
585
+ `${props.explore.tracable} && _exceptionable`,
512
586
  )
513
- : explore.tracable
587
+ : props.explore.tracable
514
588
  ? ts.factory.createTrue()
515
589
  : ts.factory.createFalse(),
516
- ]
517
- : config.path === true
518
- ? [
519
- ts.factory.createIdentifier(
520
- explore.postfix ? `_path + ${explore.postfix}` : "_path",
521
- ),
522
- ]
523
- : [
524
- explore.source === "function"
525
- ? ts.factory.createIdentifier(
526
- `${explore.tracable} && _exceptionable`,
527
- )
528
- : explore.tracable
529
- ? ts.factory.createTrue()
530
- : ts.factory.createFalse(),
531
- ];
532
- return (input: ts.Expression) => [input, ...tail];
533
- };
590
+ ];
591
+ return [props.input, ...tail];
592
+ };
534
593
 
535
- export const parameterDeclarations =
536
- (props: Pick<CheckerProgrammer.IConfig, "path" | "trace">) =>
537
- (type: ts.TypeNode) => {
538
- const tail: ts.ParameterDeclaration[] = [];
539
- if (props.path)
540
- tail.push(
541
- IdentifierFactory.parameter("_path", TypeFactory.keyword("string")),
542
- );
543
- if (props.trace)
544
- tail.push(
545
- IdentifierFactory.parameter(
546
- "_exceptionable",
547
- TypeFactory.keyword("boolean"),
548
- ts.factory.createTrue(),
549
- ),
550
- );
551
- return (input: ts.Identifier): ts.ParameterDeclaration[] => [
552
- IdentifierFactory.parameter(input, type),
553
- ...tail,
554
- ];
555
- };
594
+ export const parameterDeclarations = (props: {
595
+ config: Pick<CheckerProgrammer.IConfig, "path" | "trace">;
596
+ type: ts.TypeNode;
597
+ input: ts.Identifier;
598
+ }) => {
599
+ const tail: ts.ParameterDeclaration[] = [];
600
+ if (props.config.path)
601
+ tail.push(
602
+ IdentifierFactory.parameter("_path", TypeFactory.keyword("string")),
603
+ );
604
+ if (props.config.trace)
605
+ tail.push(
606
+ IdentifierFactory.parameter(
607
+ "_exceptionable",
608
+ TypeFactory.keyword("boolean"),
609
+ ts.factory.createTrue(),
610
+ ),
611
+ );
612
+ return [IdentifierFactory.parameter(props.input, props.type), ...tail];
613
+ };
556
614
  }