@duplojs/utils 1.5.11 → 1.5.12
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.
- package/dist/dataParser/parsers/record/findRecordRequiredKey.cjs +6 -9
- package/dist/dataParser/parsers/record/findRecordRequiredKey.d.ts +2 -2
- package/dist/dataParser/parsers/record/findRecordRequiredKey.mjs +6 -9
- package/dist/dataParser/parsers/record/index.cjs +19 -13
- package/dist/dataParser/parsers/record/index.d.ts +9 -7
- package/dist/dataParser/parsers/record/index.mjs +19 -13
- package/dist/string/types/pop.d.ts +3 -1
- package/dist/string/types/split.d.ts +4 -2
- package/dist/string/types/templateLiteralContainLargeType.d.ts +1 -6
- package/package.json +1 -1
|
@@ -12,36 +12,33 @@ var nil = require('../nil.cjs');
|
|
|
12
12
|
var pipe = require('../../../common/pipe.cjs');
|
|
13
13
|
var reduce = require('../../../array/reduce.cjs');
|
|
14
14
|
var when = require('../../../pattern/when.cjs');
|
|
15
|
-
var justReturn = require('../../../common/justReturn.cjs');
|
|
16
|
-
var isType = require('../../../common/isType.cjs');
|
|
17
15
|
var map = require('../../../array/map.cjs');
|
|
18
16
|
var concat = require('../../../string/concat.cjs');
|
|
17
|
+
var isType = require('../../../common/isType.cjs');
|
|
19
18
|
var flatMap = require('../../../array/flatMap.cjs');
|
|
20
19
|
var prepend = require('../../../string/prepend.cjs');
|
|
21
20
|
var exhaustive = require('../../../pattern/exhaustive.cjs');
|
|
22
21
|
var innerPipe = require('../../../common/innerPipe.cjs');
|
|
23
|
-
var notIncludes = require('../../../array/notIncludes.cjs');
|
|
24
22
|
var flat = require('../../../array/flat.cjs');
|
|
25
|
-
var
|
|
23
|
+
var justReturn = require('../../../common/justReturn.cjs');
|
|
26
24
|
var when$1 = require('../../../common/when.cjs');
|
|
25
|
+
var to = require('../../../string/to.cjs');
|
|
27
26
|
var or = require('../../../common/or.cjs');
|
|
28
|
-
var includes = require('../../../array/includes.cjs');
|
|
29
|
-
var filter = require('../../../array/filter.cjs');
|
|
30
27
|
|
|
31
28
|
function findRecordRequiredKeyOnTemplateLiteralPart(templatePart) {
|
|
32
29
|
return pipe.pipe(templatePart, map.map(innerPipe.innerPipe(when.when((value) => index$1.stringKind.has(value)
|
|
33
30
|
|| index$2.numberKind.has(value)
|
|
34
|
-
|| index$3.bigIntKind.has(value), justReturn.justReturn(
|
|
31
|
+
|| index$3.bigIntKind.has(value), justReturn.justReturn([])), when.when(or.or([
|
|
35
32
|
isType.isType("bigint"),
|
|
36
33
|
isType.isType("boolean"),
|
|
37
34
|
isType.isType("null"),
|
|
38
35
|
isType.isType("number"),
|
|
39
36
|
isType.isType("string"),
|
|
40
37
|
isType.isType("undefined"),
|
|
41
|
-
]), innerPipe.innerPipe(when$1.when(isType.isType("bigint"), (value) => `${value}n`),
|
|
38
|
+
]), innerPipe.innerPipe(when$1.when(isType.isType("bigint"), (value) => `${value}n`), to.to)), when.when(literal.literalKind.has, (value) => pipe.pipe(value.definition.value, map.map((element) => findRecordRequiredKeyOnTemplateLiteralPart([element])), flat.flat)), when.when(index.templateLiteralKind.has, (value) => findRecordRequiredKeyOnTemplateLiteralPart(value.definition.template)), when.when(boolean.booleanKind.has, justReturn.justReturn(["true", "false"])), when.when(empty.emptyKind.has, justReturn.justReturn("undefined")), when.when(nil.nilKind.has, justReturn.justReturn("null")), when.when(union.unionKind.has, (dataParser) => pipe.pipe(dataParser.definition.options, map.map((element) => findRecordRequiredKeyOnTemplateLiteralPart([element])), flat.flat)), exhaustive.exhaustive)), reduce.reduce(reduce.reduceFrom([""]), ({ lastValue, element, next }) => pipe.pipe(element, when.when(isType.isType("string"), (element) => next(map.map(lastValue, concat.concat(element)))), when.when(isType.isType("array"), (elements) => next(flatMap.flatMap(lastValue, (value) => map.map(elements, prepend.prepend(value))))), exhaustive.exhaustive)));
|
|
42
39
|
}
|
|
43
40
|
function findRecordRequiredKey(keyParser) {
|
|
44
|
-
return pipe.pipe(keyParser, when.when((value) => index$1.stringKind.has(value) || index$2.numberKind.has(value), justReturn.justReturn(
|
|
41
|
+
return pipe.pipe(keyParser, when.when((value) => index$1.stringKind.has(value) || index$2.numberKind.has(value), justReturn.justReturn([])), when.when(literal.literalKind.has, (dataParser) => dataParser.definition.value), when.when(union.unionKind.has, (dataParser) => pipe.pipe(dataParser.definition.options, map.map(findRecordRequiredKey), flat.flat)), when.when(index.templateLiteralKind.has, (dataParser) => findRecordRequiredKeyOnTemplateLiteralPart(dataParser.definition.template)), exhaustive.exhaustive);
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
exports.findRecordRequiredKey = findRecordRequiredKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type DataParserRecordKey } from ".";
|
|
2
2
|
import { type TemplateLiteralParts } from "../templateLiteral";
|
|
3
|
-
export declare function findRecordRequiredKeyOnTemplateLiteralPart(templatePart: readonly TemplateLiteralParts[]): string[]
|
|
4
|
-
export declare function findRecordRequiredKey(keyParser: DataParserRecordKey): string[]
|
|
3
|
+
export declare function findRecordRequiredKeyOnTemplateLiteralPart(templatePart: readonly TemplateLiteralParts[]): readonly string[];
|
|
4
|
+
export declare function findRecordRequiredKey(keyParser: DataParserRecordKey): readonly string[];
|
|
@@ -10,36 +10,33 @@ import { nilKind } from '../nil.mjs';
|
|
|
10
10
|
import { pipe } from '../../../common/pipe.mjs';
|
|
11
11
|
import { reduce, reduceFrom } from '../../../array/reduce.mjs';
|
|
12
12
|
import { when } from '../../../pattern/when.mjs';
|
|
13
|
-
import { justReturn } from '../../../common/justReturn.mjs';
|
|
14
|
-
import { isType } from '../../../common/isType.mjs';
|
|
15
13
|
import { map } from '../../../array/map.mjs';
|
|
16
14
|
import { concat } from '../../../string/concat.mjs';
|
|
15
|
+
import { isType } from '../../../common/isType.mjs';
|
|
17
16
|
import { flatMap } from '../../../array/flatMap.mjs';
|
|
18
17
|
import { prepend } from '../../../string/prepend.mjs';
|
|
19
18
|
import { exhaustive } from '../../../pattern/exhaustive.mjs';
|
|
20
19
|
import { innerPipe } from '../../../common/innerPipe.mjs';
|
|
21
|
-
import { notIncludes } from '../../../array/notIncludes.mjs';
|
|
22
20
|
import { flat } from '../../../array/flat.mjs';
|
|
23
|
-
import {
|
|
21
|
+
import { justReturn } from '../../../common/justReturn.mjs';
|
|
24
22
|
import { when as when$1 } from '../../../common/when.mjs';
|
|
23
|
+
import { to } from '../../../string/to.mjs';
|
|
25
24
|
import { or } from '../../../common/or.mjs';
|
|
26
|
-
import { includes } from '../../../array/includes.mjs';
|
|
27
|
-
import { filter } from '../../../array/filter.mjs';
|
|
28
25
|
|
|
29
26
|
function findRecordRequiredKeyOnTemplateLiteralPart(templatePart) {
|
|
30
27
|
return pipe(templatePart, map(innerPipe(when((value) => stringKind.has(value)
|
|
31
28
|
|| numberKind.has(value)
|
|
32
|
-
|| bigIntKind.has(value), justReturn(
|
|
29
|
+
|| bigIntKind.has(value), justReturn([])), when(or([
|
|
33
30
|
isType("bigint"),
|
|
34
31
|
isType("boolean"),
|
|
35
32
|
isType("null"),
|
|
36
33
|
isType("number"),
|
|
37
34
|
isType("string"),
|
|
38
35
|
isType("undefined"),
|
|
39
|
-
]), innerPipe(when$1(isType("bigint"), (value) => `${value}n`),
|
|
36
|
+
]), innerPipe(when$1(isType("bigint"), (value) => `${value}n`), to)), when(literalKind.has, (value) => pipe(value.definition.value, map((element) => findRecordRequiredKeyOnTemplateLiteralPart([element])), flat)), when(templateLiteralKind.has, (value) => findRecordRequiredKeyOnTemplateLiteralPart(value.definition.template)), when(booleanKind.has, justReturn(["true", "false"])), when(emptyKind.has, justReturn("undefined")), when(nilKind.has, justReturn("null")), when(unionKind.has, (dataParser) => pipe(dataParser.definition.options, map((element) => findRecordRequiredKeyOnTemplateLiteralPart([element])), flat)), exhaustive)), reduce(reduceFrom([""]), ({ lastValue, element, next }) => pipe(element, when(isType("string"), (element) => next(map(lastValue, concat(element)))), when(isType("array"), (elements) => next(flatMap(lastValue, (value) => map(elements, prepend(value))))), exhaustive)));
|
|
40
37
|
}
|
|
41
38
|
function findRecordRequiredKey(keyParser) {
|
|
42
|
-
return pipe(keyParser, when((value) => stringKind.has(value) || numberKind.has(value), justReturn(
|
|
39
|
+
return pipe(keyParser, when((value) => stringKind.has(value) || numberKind.has(value), justReturn([])), when(literalKind.has, (dataParser) => dataParser.definition.value), when(unionKind.has, (dataParser) => pipe(dataParser.definition.options, map(findRecordRequiredKey), flat)), when(templateLiteralKind.has, (dataParser) => findRecordRequiredKeyOnTemplateLiteralPart(dataParser.definition.template)), exhaustive);
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
export { findRecordRequiredKey, findRecordRequiredKeyOnTemplateLiteralPart };
|
|
@@ -4,6 +4,10 @@ var base = require('../../base.cjs');
|
|
|
4
4
|
var error = require('../../error.cjs');
|
|
5
5
|
var kind = require('../../kind.cjs');
|
|
6
6
|
var findRecordRequiredKey = require('./findRecordRequiredKey.cjs');
|
|
7
|
+
var pipe = require('../../../common/pipe.cjs');
|
|
8
|
+
var map = require('../../../array/map.cjs');
|
|
9
|
+
var entry = require('../../../object/entry.cjs');
|
|
10
|
+
var fromEntries = require('../../../object/fromEntries.cjs');
|
|
7
11
|
var override = require('../../../common/override.cjs');
|
|
8
12
|
|
|
9
13
|
const recordKind = kind.createDataParserKind("record");
|
|
@@ -11,12 +15,14 @@ const recordKind = kind.createDataParserKind("record");
|
|
|
11
15
|
* {@include dataParser/classic/record/index.md}
|
|
12
16
|
*/
|
|
13
17
|
function record(key, value, definition) {
|
|
18
|
+
const requireKey = findRecordRequiredKey.findRecordRequiredKey(key);
|
|
14
19
|
const self = base.dataParserInit(recordKind, {
|
|
15
20
|
errorMessage: definition?.errorMessage,
|
|
16
21
|
checkers: definition?.checkers ?? [],
|
|
17
22
|
key,
|
|
18
23
|
value,
|
|
19
|
-
requireKey
|
|
24
|
+
requireKey,
|
|
25
|
+
baseData: pipe.pipe(requireKey, map.map((key) => entry.entry(key, undefined)), fromEntries.fromEntries),
|
|
20
26
|
}, {
|
|
21
27
|
sync: (data, error$1, self) => {
|
|
22
28
|
if (!data
|
|
@@ -25,8 +31,12 @@ function record(key, value, definition) {
|
|
|
25
31
|
return error.SymbolDataParserErrorIssue;
|
|
26
32
|
}
|
|
27
33
|
let output = {};
|
|
34
|
+
const fromData = {
|
|
35
|
+
...self.definition.baseData,
|
|
36
|
+
...data,
|
|
37
|
+
};
|
|
28
38
|
const currentIndexPath = error$1.currentPath.length;
|
|
29
|
-
for (const key in
|
|
39
|
+
for (const key in fromData) {
|
|
30
40
|
error.setErrorPath(error$1, key, currentIndexPath);
|
|
31
41
|
const resultKey = self
|
|
32
42
|
.definition
|
|
@@ -38,7 +48,7 @@ function record(key, value, definition) {
|
|
|
38
48
|
const resultValue = self
|
|
39
49
|
.definition
|
|
40
50
|
.value
|
|
41
|
-
.exec(
|
|
51
|
+
.exec(fromData[key], error$1);
|
|
42
52
|
if (resultValue === base.SymbolDataParserError) {
|
|
43
53
|
output = base.SymbolDataParserError;
|
|
44
54
|
}
|
|
@@ -50,10 +60,6 @@ function record(key, value, definition) {
|
|
|
50
60
|
if (output === base.SymbolDataParserError) {
|
|
51
61
|
return output;
|
|
52
62
|
}
|
|
53
|
-
if (self.definition.requireKey
|
|
54
|
-
&& self.definition.requireKey.length !== Object.keys(output).length) {
|
|
55
|
-
return error.SymbolDataParserErrorIssue;
|
|
56
|
-
}
|
|
57
63
|
return output;
|
|
58
64
|
},
|
|
59
65
|
async: async (data, error$1, self) => {
|
|
@@ -63,8 +69,12 @@ function record(key, value, definition) {
|
|
|
63
69
|
return error.SymbolDataParserErrorIssue;
|
|
64
70
|
}
|
|
65
71
|
let output = {};
|
|
72
|
+
const fromData = {
|
|
73
|
+
...self.definition.baseData,
|
|
74
|
+
...data,
|
|
75
|
+
};
|
|
66
76
|
const currentIndexPath = error$1.currentPath.length;
|
|
67
|
-
for (const key in
|
|
77
|
+
for (const key in fromData) {
|
|
68
78
|
error.setErrorPath(error$1, key, currentIndexPath);
|
|
69
79
|
const resultKey = await self
|
|
70
80
|
.definition
|
|
@@ -76,7 +86,7 @@ function record(key, value, definition) {
|
|
|
76
86
|
const resultValue = await self
|
|
77
87
|
.definition
|
|
78
88
|
.value
|
|
79
|
-
.asyncExec(
|
|
89
|
+
.asyncExec(fromData[key], error$1);
|
|
80
90
|
if (resultValue === base.SymbolDataParserError) {
|
|
81
91
|
output = base.SymbolDataParserError;
|
|
82
92
|
}
|
|
@@ -88,10 +98,6 @@ function record(key, value, definition) {
|
|
|
88
98
|
if (output === base.SymbolDataParserError) {
|
|
89
99
|
return output;
|
|
90
100
|
}
|
|
91
|
-
if (self.definition.requireKey
|
|
92
|
-
&& self.definition.requireKey.length !== Object.keys(output).length) {
|
|
93
|
-
return error.SymbolDataParserErrorIssue;
|
|
94
|
-
}
|
|
95
101
|
return output;
|
|
96
102
|
},
|
|
97
103
|
isAsynchronous: (self) => self.definition.value.isAsynchronous(),
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { type NeverCoalescing, type Kind, type FixDeepFunctionInfer, type
|
|
1
|
+
import { type NeverCoalescing, type Kind, type FixDeepFunctionInfer, type IsEqual } from "../../../common";
|
|
2
2
|
import { type DataParserDefinition, type DataParser, type Output, type Input, type DataParserChecker } from "../../base";
|
|
3
3
|
import { type AddCheckersToDefinition, type MergeDefinition } from "../../../dataParser/types";
|
|
4
4
|
import { type DataParserString } from "../string";
|
|
5
5
|
import { type DataParserTemplateLiteral } from "../templateLiteral";
|
|
6
|
-
import { type DataParserLiteral } from "../literal";
|
|
6
|
+
import { type DataParserDefinitionLiteral, type DataParserLiteral } from "../literal";
|
|
7
7
|
import { type DataParserDefinitionNumber, type DataParserNumber } from "../number";
|
|
8
8
|
import { type DataParserDefinitionUnion, type DataParserUnion } from "../union";
|
|
9
9
|
import { type CheckerRefineImplementation } from "../refine";
|
|
10
|
-
import { type TemplateLiteralContainLargeType } from "../../../string";
|
|
11
10
|
import { type GetPropsWithValueExtends } from "../../../object";
|
|
12
11
|
export * from "./findRecordRequiredKey";
|
|
13
|
-
export type DataParserRecordKey = (DataParserString | DataParserTemplateLiteral | DataParserLiteral
|
|
12
|
+
export type DataParserRecordKey = (DataParserString | DataParserTemplateLiteral | DataParserLiteral<DataParserDefinitionLiteral & {
|
|
13
|
+
value: readonly string[];
|
|
14
|
+
}> | DataParserNumber<DataParserDefinitionNumber & {
|
|
14
15
|
coerce: true;
|
|
15
16
|
}> | DataParserUnion<DataParserDefinitionUnion & {
|
|
16
17
|
options: DataParserRecordKey[];
|
|
@@ -21,11 +22,12 @@ export type DataParserRecordCheckers<GenericInput extends Record<string, unknown
|
|
|
21
22
|
export interface DataParserDefinitionRecord extends DataParserDefinition<DataParserRecordCheckers<Record<string, unknown>>> {
|
|
22
23
|
readonly key: DataParserRecordKey;
|
|
23
24
|
readonly value: DataParser;
|
|
24
|
-
readonly
|
|
25
|
+
readonly baseData: Partial<Record<string, undefined>>;
|
|
26
|
+
readonly requireKey: readonly string[];
|
|
25
27
|
}
|
|
26
28
|
export declare const recordKind: import("../../../common").KindHandler<import("../../../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>>;
|
|
27
|
-
export type DataParserRecordShapeOutput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser> = Extract<Record<Output<GenericDataParserKey> extends infer InferredKey extends string | number ? `${InferredKey}` : never, Output<GenericDataParserValue> extends infer InferredValue ? InferredValue : never
|
|
28
|
-
export type DataParserRecordShapeInput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser> = Extract<Record<Input<GenericDataParserKey> extends infer InferredKey extends string | number ? `${InferredKey}` : never, Input<GenericDataParserValue> extends infer InferredValue ? InferredValue : never
|
|
29
|
+
export type DataParserRecordShapeOutput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser> = Extract<Record<Output<GenericDataParserKey> extends infer InferredKey extends string | number ? `${InferredKey}` : never, Output<GenericDataParserValue> extends infer InferredValue ? InferredValue : never> extends infer InferredResult extends Record<string, unknown> ? IsEqual<Extract<InferredResult[keyof InferredResult], undefined>, never> extends true ? InferredResult : Partial<InferredResult> : never, any>;
|
|
30
|
+
export type DataParserRecordShapeInput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser> = Extract<Record<Input<GenericDataParserKey> extends infer InferredKey extends string | number ? `${InferredKey}` : never, Input<GenericDataParserValue> extends infer InferredValue ? InferredValue : never> extends infer InferredResult extends Record<string, unknown> ? IsEqual<Extract<InferredResult[keyof InferredResult], undefined>, never> extends true ? InferredResult : Partial<InferredResult> : never, any>;
|
|
29
31
|
type _DataParserRecord<GenericDefinition extends DataParserDefinitionRecord> = (DataParser<GenericDefinition, DataParserRecordShapeOutput<GenericDefinition["key"], GenericDefinition["value"]>, DataParserRecordShapeInput<GenericDefinition["key"], GenericDefinition["value"]>> & Kind<typeof recordKind.definition>);
|
|
30
32
|
export interface DataParserRecord<GenericDefinition extends DataParserDefinitionRecord = DataParserDefinitionRecord> extends _DataParserRecord<GenericDefinition> {
|
|
31
33
|
addChecker<GenericChecker extends readonly [
|
|
@@ -3,6 +3,10 @@ import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../er
|
|
|
3
3
|
import { createDataParserKind } from '../../kind.mjs';
|
|
4
4
|
import { findRecordRequiredKey } from './findRecordRequiredKey.mjs';
|
|
5
5
|
export { findRecordRequiredKeyOnTemplateLiteralPart } from './findRecordRequiredKey.mjs';
|
|
6
|
+
import { pipe } from '../../../common/pipe.mjs';
|
|
7
|
+
import { map } from '../../../array/map.mjs';
|
|
8
|
+
import { entry } from '../../../object/entry.mjs';
|
|
9
|
+
import { fromEntries } from '../../../object/fromEntries.mjs';
|
|
6
10
|
import { createOverride } from '../../../common/override.mjs';
|
|
7
11
|
|
|
8
12
|
const recordKind = createDataParserKind("record");
|
|
@@ -10,12 +14,14 @@ const recordKind = createDataParserKind("record");
|
|
|
10
14
|
* {@include dataParser/classic/record/index.md}
|
|
11
15
|
*/
|
|
12
16
|
function record(key, value, definition) {
|
|
17
|
+
const requireKey = findRecordRequiredKey(key);
|
|
13
18
|
const self = dataParserInit(recordKind, {
|
|
14
19
|
errorMessage: definition?.errorMessage,
|
|
15
20
|
checkers: definition?.checkers ?? [],
|
|
16
21
|
key,
|
|
17
22
|
value,
|
|
18
|
-
requireKey
|
|
23
|
+
requireKey,
|
|
24
|
+
baseData: pipe(requireKey, map((key) => entry(key, undefined)), fromEntries),
|
|
19
25
|
}, {
|
|
20
26
|
sync: (data, error, self) => {
|
|
21
27
|
if (!data
|
|
@@ -24,8 +30,12 @@ function record(key, value, definition) {
|
|
|
24
30
|
return SymbolDataParserErrorIssue;
|
|
25
31
|
}
|
|
26
32
|
let output = {};
|
|
33
|
+
const fromData = {
|
|
34
|
+
...self.definition.baseData,
|
|
35
|
+
...data,
|
|
36
|
+
};
|
|
27
37
|
const currentIndexPath = error.currentPath.length;
|
|
28
|
-
for (const key in
|
|
38
|
+
for (const key in fromData) {
|
|
29
39
|
setErrorPath(error, key, currentIndexPath);
|
|
30
40
|
const resultKey = self
|
|
31
41
|
.definition
|
|
@@ -37,7 +47,7 @@ function record(key, value, definition) {
|
|
|
37
47
|
const resultValue = self
|
|
38
48
|
.definition
|
|
39
49
|
.value
|
|
40
|
-
.exec(
|
|
50
|
+
.exec(fromData[key], error);
|
|
41
51
|
if (resultValue === SymbolDataParserError) {
|
|
42
52
|
output = SymbolDataParserError;
|
|
43
53
|
}
|
|
@@ -49,10 +59,6 @@ function record(key, value, definition) {
|
|
|
49
59
|
if (output === SymbolDataParserError) {
|
|
50
60
|
return output;
|
|
51
61
|
}
|
|
52
|
-
if (self.definition.requireKey
|
|
53
|
-
&& self.definition.requireKey.length !== Object.keys(output).length) {
|
|
54
|
-
return SymbolDataParserErrorIssue;
|
|
55
|
-
}
|
|
56
62
|
return output;
|
|
57
63
|
},
|
|
58
64
|
async: async (data, error, self) => {
|
|
@@ -62,8 +68,12 @@ function record(key, value, definition) {
|
|
|
62
68
|
return SymbolDataParserErrorIssue;
|
|
63
69
|
}
|
|
64
70
|
let output = {};
|
|
71
|
+
const fromData = {
|
|
72
|
+
...self.definition.baseData,
|
|
73
|
+
...data,
|
|
74
|
+
};
|
|
65
75
|
const currentIndexPath = error.currentPath.length;
|
|
66
|
-
for (const key in
|
|
76
|
+
for (const key in fromData) {
|
|
67
77
|
setErrorPath(error, key, currentIndexPath);
|
|
68
78
|
const resultKey = await self
|
|
69
79
|
.definition
|
|
@@ -75,7 +85,7 @@ function record(key, value, definition) {
|
|
|
75
85
|
const resultValue = await self
|
|
76
86
|
.definition
|
|
77
87
|
.value
|
|
78
|
-
.asyncExec(
|
|
88
|
+
.asyncExec(fromData[key], error);
|
|
79
89
|
if (resultValue === SymbolDataParserError) {
|
|
80
90
|
output = SymbolDataParserError;
|
|
81
91
|
}
|
|
@@ -87,10 +97,6 @@ function record(key, value, definition) {
|
|
|
87
97
|
if (output === SymbolDataParserError) {
|
|
88
98
|
return output;
|
|
89
99
|
}
|
|
90
|
-
if (self.definition.requireKey
|
|
91
|
-
&& self.definition.requireKey.length !== Object.keys(output).length) {
|
|
92
|
-
return SymbolDataParserErrorIssue;
|
|
93
|
-
}
|
|
94
100
|
return output;
|
|
95
101
|
},
|
|
96
102
|
isAsynchronous: (self) => self.definition.value.isAsynchronous(),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { IsEqual } from "../../common";
|
|
2
2
|
import type { TemplateLiteralContainLargeType } from "./templateLiteralContainLargeType";
|
|
3
|
-
|
|
3
|
+
type _Pop<GenericValue extends string, GenericCount extends never[] = []> = IsEqual<GenericCount["length"], 250> extends true ? string : GenericValue extends `${infer InferredFirst}${infer InferredRest}` ? IsEqual<InferredRest, ""> extends true ? "" : _Pop<InferredRest, [...GenericCount, never]> extends infer InferredResult extends string ? `${InferredFirst}${InferredResult}` : never : string;
|
|
4
|
+
export type Pop<GenericValue extends string> = TemplateLiteralContainLargeType<GenericValue> extends true ? string : IsEqual<GenericValue, ""> extends true ? "" : _Pop<GenericValue>;
|
|
5
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Or, type IsEqual } from "../../common";
|
|
2
2
|
import { type Includes } from "./includes";
|
|
3
3
|
import { type TemplateLiteralContainLargeType } from "./templateLiteralContainLargeType";
|
|
4
|
-
|
|
4
|
+
type _Split<GenericString extends string, GenericSeparator extends string, GenericLimit extends number = number, GenericLastResult extends string[] = []> = GenericString extends `${infer InferredBefore}${GenericSeparator}${infer InferredAfter}` ? [...GenericLastResult, InferredBefore] extends infer InferredResult extends any[] ? IsEqual<InferredAfter, ""> extends true ? InferredResult : IsEqual<InferredResult["length"], 250> extends true ? Includes<InferredAfter, GenericSeparator> extends true ? [...InferredResult, ...string[]] : InferredResult : IsEqual<InferredResult["length"], GenericLimit> extends true ? InferredResult : _Split<InferredAfter, GenericSeparator, GenericLimit, InferredResult> : never : [...GenericLastResult, GenericString];
|
|
5
|
+
export type Split<GenericString extends string, GenericSeparator extends string, GenericLimit extends number = number> = IsEqual<GenericLimit, 0> extends true ? [] : Or<[
|
|
5
6
|
TemplateLiteralContainLargeType<GenericString>,
|
|
6
7
|
TemplateLiteralContainLargeType<GenericSeparator>
|
|
7
|
-
]> extends true ? [string, ...string[]] : GenericString
|
|
8
|
+
]> extends true ? [string, ...string[]] : _Split<GenericString, GenericSeparator, GenericLimit>;
|
|
9
|
+
export {};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type TemplateLiteralContainLargeType<GenericValue extends string> = (GenericValue extends `${infer InferredFirst}${infer InferredLast}` ? Or<[
|
|
3
|
-
IsEqual<InferredFirst, `${number}`>,
|
|
4
|
-
IsEqual<InferredFirst, `${bigint}`>,
|
|
5
|
-
IsEqual<InferredFirst, string>
|
|
6
|
-
]> extends false ? TemplateLiteralContainLargeType<InferredLast> : true : GenericValue extends "" ? false : true) extends false ? false : true;
|
|
1
|
+
export type TemplateLiteralContainLargeType<GenericValue extends string> = (GenericValue extends string ? {} extends Record<GenericValue, never> ? true : false : never) extends false ? false : true;
|