@duplojs/utils 1.6.1 → 1.6.3
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/array/types/createTuple.d.ts +1 -1
- package/dist/clean/constraint/base.cjs +7 -0
- package/dist/clean/constraint/base.d.ts +26 -6
- package/dist/clean/constraint/base.mjs +7 -0
- package/dist/clean/constraint/cast.cjs +18 -0
- package/dist/clean/constraint/cast.d.ts +29 -0
- package/dist/clean/constraint/cast.mjs +16 -0
- package/dist/clean/constraint/defaultConstraint/number.cjs +2 -10
- package/dist/clean/constraint/defaultConstraint/number.d.ts +12 -37
- package/dist/clean/constraint/defaultConstraint/number.mjs +3 -10
- package/dist/clean/constraint/defaultConstraint/string.d.ts +9 -5
- package/dist/clean/constraint/index.d.ts +1 -0
- package/dist/clean/constraint/set.cjs +7 -1
- package/dist/clean/constraint/set.d.ts +25 -5
- package/dist/clean/constraint/set.mjs +7 -1
- package/dist/clean/entity/index.cjs +14 -4
- package/dist/clean/entity/index.d.ts +11 -1
- package/dist/clean/entity/index.mjs +15 -6
- package/dist/clean/index.cjs +5 -1
- package/dist/clean/index.d.ts +1 -0
- package/dist/clean/index.mjs +4 -2
- package/dist/clean/newType.cjs +6 -1
- package/dist/clean/newType.d.ts +20 -5
- package/dist/clean/newType.mjs +6 -1
- package/dist/clean/primitive/operations/equal.cjs +3 -0
- package/dist/clean/primitive/operations/equal.d.ts +2 -2
- package/dist/clean/primitive/operations/equal.mjs +3 -0
- package/dist/clean/toMapDataParser.cjs +52 -0
- package/dist/clean/toMapDataParser.d.ts +53 -0
- package/dist/clean/toMapDataParser.mjs +50 -0
- package/dist/common/asserts.cjs +12 -0
- package/dist/common/asserts.d.ts +26 -0
- package/dist/common/asserts.mjs +12 -1
- package/dist/common/callThen.cjs +14 -0
- package/dist/common/callThen.d.ts +35 -0
- package/dist/common/callThen.mjs +12 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/printer.cjs +73 -0
- package/dist/common/printer.d.ts +139 -0
- package/dist/common/printer.mjs +73 -0
- package/dist/common/queue.cjs +90 -0
- package/dist/common/queue.d.ts +46 -0
- package/dist/common/queue.mjs +87 -0
- package/dist/common/types/and.d.ts +1 -2
- package/dist/common/types/or.d.ts +1 -2
- package/dist/dataParser/base.cjs +12 -35
- package/dist/dataParser/base.d.ts +6 -9
- package/dist/dataParser/base.mjs +8 -30
- package/dist/dataParser/error.cjs +39 -21
- package/dist/dataParser/error.d.ts +19 -19
- package/dist/dataParser/error.mjs +37 -18
- package/dist/dataParser/extended/index.cjs +3 -4
- package/dist/dataParser/extended/index.mjs +1 -1
- package/dist/dataParser/identifier.d.ts +6 -6
- package/dist/dataParser/index.cjs +3 -6
- package/dist/dataParser/index.mjs +2 -2
- package/dist/dataParser/parsers/array/checkers/max.cjs +3 -6
- package/dist/dataParser/parsers/array/checkers/max.mjs +4 -7
- package/dist/dataParser/parsers/array/checkers/min.cjs +3 -6
- package/dist/dataParser/parsers/array/checkers/min.mjs +4 -7
- package/dist/dataParser/parsers/array/index.cjs +8 -8
- package/dist/dataParser/parsers/array/index.mjs +4 -4
- package/dist/dataParser/parsers/bigint/checkers/max.cjs +2 -2
- package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/bigint/checkers/min.cjs +2 -2
- package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/bigint/index.cjs +2 -2
- package/dist/dataParser/parsers/bigint/index.mjs +3 -3
- package/dist/dataParser/parsers/boolean.cjs +3 -3
- package/dist/dataParser/parsers/boolean.mjs +4 -4
- package/dist/dataParser/parsers/date.cjs +4 -4
- package/dist/dataParser/parsers/date.mjs +5 -5
- package/dist/dataParser/parsers/empty.cjs +2 -2
- package/dist/dataParser/parsers/empty.mjs +3 -3
- package/dist/dataParser/parsers/literal.cjs +2 -2
- package/dist/dataParser/parsers/literal.mjs +3 -3
- package/dist/dataParser/parsers/nil.cjs +2 -2
- package/dist/dataParser/parsers/nil.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/int.cjs +2 -2
- package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/number/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/number/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/number/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/number/index.cjs +2 -2
- package/dist/dataParser/parsers/number/index.mjs +3 -3
- package/dist/dataParser/parsers/object/index.cjs +8 -8
- package/dist/dataParser/parsers/object/index.mjs +4 -4
- package/dist/dataParser/parsers/pipe.cjs +25 -10
- package/dist/dataParser/parsers/pipe.mjs +22 -7
- package/dist/dataParser/parsers/record/index.cjs +18 -16
- package/dist/dataParser/parsers/record/index.mjs +8 -6
- package/dist/dataParser/parsers/recover.cjs +7 -6
- package/dist/dataParser/parsers/recover.mjs +2 -1
- package/dist/dataParser/parsers/refine.cjs +3 -1
- package/dist/dataParser/parsers/refine.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/email.cjs +2 -2
- package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/string/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/string/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/regex.cjs +2 -2
- package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/url.cjs +4 -4
- package/dist/dataParser/parsers/string/checkers/url.mjs +5 -5
- package/dist/dataParser/parsers/string/index.cjs +2 -2
- package/dist/dataParser/parsers/string/index.mjs +3 -3
- package/dist/dataParser/parsers/templateLiteral/index.cjs +2 -2
- package/dist/dataParser/parsers/templateLiteral/index.mjs +3 -3
- package/dist/dataParser/parsers/time/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/time/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/time/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/time/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/time/index.cjs +4 -4
- package/dist/dataParser/parsers/time/index.mjs +5 -5
- package/dist/dataParser/parsers/transform.cjs +6 -6
- package/dist/dataParser/parsers/transform.d.ts +2 -2
- package/dist/dataParser/parsers/transform.mjs +4 -4
- package/dist/dataParser/parsers/tuple.cjs +14 -14
- package/dist/dataParser/parsers/tuple.mjs +4 -4
- package/dist/dataParser/parsers/union.cjs +26 -8
- package/dist/dataParser/parsers/union.mjs +26 -8
- package/dist/flow/calledByNext.cjs +13 -0
- package/dist/flow/calledByNext.d.ts +47 -0
- package/dist/flow/calledByNext.mjs +11 -0
- package/dist/flow/debounce.cjs +16 -0
- package/dist/flow/debounce.d.ts +63 -0
- package/dist/flow/debounce.mjs +14 -0
- package/dist/flow/exec.cjs +101 -0
- package/dist/flow/exec.d.ts +4 -3
- package/dist/flow/exec.mjs +101 -0
- package/dist/flow/index.cjs +28 -0
- package/dist/flow/index.d.ts +5 -0
- package/dist/flow/index.mjs +10 -1
- package/dist/flow/queue.cjs +19 -0
- package/dist/flow/queue.d.ts +47 -0
- package/dist/flow/queue.mjs +17 -0
- package/dist/flow/run.cjs +118 -0
- package/dist/flow/run.d.ts +6 -4
- package/dist/flow/run.mjs +113 -1
- package/dist/flow/theFlow/calledByNext.cjs +11 -0
- package/dist/flow/theFlow/calledByNext.d.ts +5 -0
- package/dist/flow/theFlow/calledByNext.mjs +8 -0
- package/dist/flow/theFlow/debounce.cjs +11 -0
- package/dist/flow/theFlow/debounce.d.ts +9 -0
- package/dist/flow/theFlow/debounce.mjs +8 -0
- package/dist/flow/theFlow/index.d.ts +11 -3
- package/dist/flow/theFlow/queue.cjs +11 -0
- package/dist/flow/theFlow/queue.d.ts +9 -0
- package/dist/flow/theFlow/queue.mjs +8 -0
- package/dist/flow/theFlow/throttling.cjs +11 -0
- package/dist/flow/theFlow/throttling.d.ts +10 -0
- package/dist/flow/theFlow/throttling.mjs +8 -0
- package/dist/flow/throttling.cjs +27 -0
- package/dist/flow/throttling.d.ts +60 -0
- package/dist/flow/throttling.mjs +25 -0
- package/dist/flow/toFunction.cjs +15 -0
- package/dist/flow/toFunction.d.ts +56 -0
- package/dist/flow/toFunction.mjs +13 -0
- package/dist/index.cjs +11 -0
- package/dist/index.mjs +4 -1
- package/dist/metadata.json +126 -0
- package/dist/number/types/isGreater.d.ts +26 -3
- package/dist/object/types/getPropsWithValue.d.ts +1 -1
- package/dist/object/types/getPropsWithValueExtends.d.ts +1 -1
- package/dist/string/length.d.ts +2 -2
- package/dist/string/types/split.d.ts +6 -5
- package/package.json +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { repeat } from '../string/repeat.mjs';
|
|
2
|
+
|
|
3
|
+
var Printer;
|
|
4
|
+
(function (Printer) {
|
|
5
|
+
const codeColors = {
|
|
6
|
+
red: "\x1b[31m",
|
|
7
|
+
green: "\x1b[32m",
|
|
8
|
+
yellow: "\x1b[33m",
|
|
9
|
+
blue: "\x1b[34m",
|
|
10
|
+
magenta: "\x1b[35m",
|
|
11
|
+
cyan: "\x1b[36m",
|
|
12
|
+
gray: "\x1b[90m",
|
|
13
|
+
};
|
|
14
|
+
const codeBold = "\x1b[1m";
|
|
15
|
+
const codeReset = "\x1b[0m";
|
|
16
|
+
Printer.tab = "\t";
|
|
17
|
+
Printer.back = "\n";
|
|
18
|
+
Printer.dash = "-";
|
|
19
|
+
function colorized(...args) {
|
|
20
|
+
if (args.length === 1) {
|
|
21
|
+
const [color] = args;
|
|
22
|
+
return (input) => colorized(input, color);
|
|
23
|
+
}
|
|
24
|
+
const [input, color] = args;
|
|
25
|
+
return `${codeColors[color]}${input}${codeReset}`;
|
|
26
|
+
}
|
|
27
|
+
Printer.colorized = colorized;
|
|
28
|
+
/**
|
|
29
|
+
* {@include common/printer/bold/index.md}
|
|
30
|
+
*/
|
|
31
|
+
function bold(input) {
|
|
32
|
+
return `${codeBold}${input}${codeReset}`;
|
|
33
|
+
}
|
|
34
|
+
Printer.bold = bold;
|
|
35
|
+
function colorizedBold(...args) {
|
|
36
|
+
if (args.length === 1) {
|
|
37
|
+
const [color] = args;
|
|
38
|
+
return (input) => colorizedBold(input, color);
|
|
39
|
+
}
|
|
40
|
+
const [input, color] = args;
|
|
41
|
+
return bold(colorized(input, color));
|
|
42
|
+
}
|
|
43
|
+
Printer.colorizedBold = colorizedBold;
|
|
44
|
+
function indent(level) {
|
|
45
|
+
return repeat(Printer.tab, level);
|
|
46
|
+
}
|
|
47
|
+
Printer.indent = indent;
|
|
48
|
+
function stringify(value) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.stringify(value);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return String(value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
Printer.stringify = stringify;
|
|
57
|
+
function render(...args) {
|
|
58
|
+
if (args.length === 1) {
|
|
59
|
+
const [joinCharacter] = args;
|
|
60
|
+
return (values) => render(values, joinCharacter);
|
|
61
|
+
}
|
|
62
|
+
const [values, joinCharacter] = args;
|
|
63
|
+
return values
|
|
64
|
+
.flat(Infinity)
|
|
65
|
+
.filter((value) => typeof value === "string" || value === true)
|
|
66
|
+
.join(joinCharacter);
|
|
67
|
+
}
|
|
68
|
+
Printer.render = render;
|
|
69
|
+
Printer.renderLine = render(" ");
|
|
70
|
+
Printer.renderParagraph = render(Printer.back);
|
|
71
|
+
})(Printer || (Printer = {}));
|
|
72
|
+
|
|
73
|
+
export { Printer };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var callThen = require('./callThen.cjs');
|
|
4
|
+
var externalPromise = require('./externalPromise.cjs');
|
|
5
|
+
var kind = require('./kind.cjs');
|
|
6
|
+
var create = require('../either/left/create.cjs');
|
|
7
|
+
|
|
8
|
+
const queueKind = kind.createKind("queue");
|
|
9
|
+
/**
|
|
10
|
+
* {@include common/queue/index.md}
|
|
11
|
+
*/
|
|
12
|
+
function createQueue(params) {
|
|
13
|
+
const concurrency = params?.concurrency === undefined || params.concurrency < 1
|
|
14
|
+
? 1
|
|
15
|
+
: params.concurrency;
|
|
16
|
+
let quantityRunning = 0;
|
|
17
|
+
let firstElement = undefined;
|
|
18
|
+
function add(theFunction) {
|
|
19
|
+
const externalPromise$1 = externalPromise.createExternalPromise();
|
|
20
|
+
const preparedFunction = () => {
|
|
21
|
+
quantityRunning++;
|
|
22
|
+
if (firstElement?.theFunction === preparedFunction) {
|
|
23
|
+
if (firstElement === firstElement.next) {
|
|
24
|
+
firstElement = undefined;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const newFirst = firstElement.next;
|
|
28
|
+
const last = firstElement.previous;
|
|
29
|
+
newFirst.previous = last;
|
|
30
|
+
last.next = newFirst;
|
|
31
|
+
firstElement = newFirst;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
let result = undefined;
|
|
35
|
+
try {
|
|
36
|
+
const MaybePromise = theFunction();
|
|
37
|
+
result = MaybePromise instanceof Promise
|
|
38
|
+
? MaybePromise.catch((error) => create.left("execution-error", error))
|
|
39
|
+
: MaybePromise;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
result = create.left("execution-error", error);
|
|
43
|
+
}
|
|
44
|
+
callThen.callThen(result, (output) => {
|
|
45
|
+
externalPromise$1.resolve(output);
|
|
46
|
+
quantityRunning--;
|
|
47
|
+
firstElement?.theFunction();
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
if (quantityRunning < concurrency) {
|
|
51
|
+
void preparedFunction();
|
|
52
|
+
}
|
|
53
|
+
else if (firstElement === undefined) {
|
|
54
|
+
firstElement = {
|
|
55
|
+
theFunction: preparedFunction,
|
|
56
|
+
next: undefined,
|
|
57
|
+
previous: undefined,
|
|
58
|
+
};
|
|
59
|
+
firstElement.next = firstElement;
|
|
60
|
+
firstElement.previous = firstElement;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const oldLast = firstElement.previous;
|
|
64
|
+
const newLastElement = {
|
|
65
|
+
theFunction: preparedFunction,
|
|
66
|
+
next: firstElement,
|
|
67
|
+
previous: firstElement.previous,
|
|
68
|
+
};
|
|
69
|
+
oldLast.next = newLastElement;
|
|
70
|
+
firstElement.previous = newLastElement;
|
|
71
|
+
}
|
|
72
|
+
return externalPromise$1.promise;
|
|
73
|
+
}
|
|
74
|
+
function addExternal() {
|
|
75
|
+
const externalPromiseToStart = externalPromise.createExternalPromise();
|
|
76
|
+
const externalPromiseToFinish = externalPromise.createExternalPromise();
|
|
77
|
+
void add(() => {
|
|
78
|
+
externalPromiseToStart.resolve(externalPromiseToFinish.resolve);
|
|
79
|
+
return externalPromiseToFinish.promise;
|
|
80
|
+
});
|
|
81
|
+
return externalPromiseToStart.promise;
|
|
82
|
+
}
|
|
83
|
+
return queueKind.setTo({
|
|
84
|
+
add,
|
|
85
|
+
addExternal,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
exports.createQueue = createQueue;
|
|
90
|
+
exports.queueKind = queueKind;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Kind } from "./kind";
|
|
2
|
+
import * as DEither from "../either";
|
|
3
|
+
export declare const queueKind: import("./kind").KindHandler<import("./kind").KindDefinition<"queue", unknown>>;
|
|
4
|
+
export interface Queue extends Kind<typeof queueKind.definition> {
|
|
5
|
+
add<GenericOutput extends unknown>(theFunction: () => GenericOutput): Promise<Awaited<GenericOutput> | DEither.Left<"execution-error", unknown>>;
|
|
6
|
+
addExternal(): Promise<() => void>;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateQueueParams {
|
|
9
|
+
concurrency?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The createQueue() function creates a FIFO queue object that limits how many tasks run at the same time and resolves each task result as a promise.
|
|
13
|
+
*
|
|
14
|
+
* Supported call styles:
|
|
15
|
+
* - Classic: `createQueue()` → returns a queue object
|
|
16
|
+
* - Classic with options: `createQueue({ concurrency })` → returns a queue object
|
|
17
|
+
*
|
|
18
|
+
* Behavior:
|
|
19
|
+
* - `queue.add(callback)` starts the callback immediately when a slot is available, otherwise it enqueues it
|
|
20
|
+
* - task results are always exposed through a promise
|
|
21
|
+
* - thrown errors and rejected promises are converted to `DEither.left("execution-error", error)`
|
|
22
|
+
* - `queue.addExternal()` reserves one slot and resolves with a release function
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const defaultQueue = createQueue();
|
|
26
|
+
* const numberResult = await defaultQueue.add(() => 42);
|
|
27
|
+
* // type: 42 | Left<"execution-error", unknown>
|
|
28
|
+
*
|
|
29
|
+
* const serialQueue = createQueue({
|
|
30
|
+
* concurrency: 1,
|
|
31
|
+
* });
|
|
32
|
+
* const textResult = await serialQueue.add(() => "hello" as const);
|
|
33
|
+
* // type: "hello" | Left<"execution-error", unknown>
|
|
34
|
+
*
|
|
35
|
+
* const asyncQueue = createQueue();
|
|
36
|
+
* const asyncResult = await asyncQueue.add(
|
|
37
|
+
* async() => Promise.resolve("done" as const),
|
|
38
|
+
* );
|
|
39
|
+
* // type: "done" | Left<"execution-error", unknown>
|
|
40
|
+
*
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/queue
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
export declare function createQueue(params?: CreateQueueParams): Queue;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { callThen } from './callThen.mjs';
|
|
2
|
+
import { createExternalPromise } from './externalPromise.mjs';
|
|
3
|
+
import { createKind } from './kind.mjs';
|
|
4
|
+
import { left } from '../either/left/create.mjs';
|
|
5
|
+
|
|
6
|
+
const queueKind = createKind("queue");
|
|
7
|
+
/**
|
|
8
|
+
* {@include common/queue/index.md}
|
|
9
|
+
*/
|
|
10
|
+
function createQueue(params) {
|
|
11
|
+
const concurrency = params?.concurrency === undefined || params.concurrency < 1
|
|
12
|
+
? 1
|
|
13
|
+
: params.concurrency;
|
|
14
|
+
let quantityRunning = 0;
|
|
15
|
+
let firstElement = undefined;
|
|
16
|
+
function add(theFunction) {
|
|
17
|
+
const externalPromise = createExternalPromise();
|
|
18
|
+
const preparedFunction = () => {
|
|
19
|
+
quantityRunning++;
|
|
20
|
+
if (firstElement?.theFunction === preparedFunction) {
|
|
21
|
+
if (firstElement === firstElement.next) {
|
|
22
|
+
firstElement = undefined;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const newFirst = firstElement.next;
|
|
26
|
+
const last = firstElement.previous;
|
|
27
|
+
newFirst.previous = last;
|
|
28
|
+
last.next = newFirst;
|
|
29
|
+
firstElement = newFirst;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let result = undefined;
|
|
33
|
+
try {
|
|
34
|
+
const MaybePromise = theFunction();
|
|
35
|
+
result = MaybePromise instanceof Promise
|
|
36
|
+
? MaybePromise.catch((error) => left("execution-error", error))
|
|
37
|
+
: MaybePromise;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
result = left("execution-error", error);
|
|
41
|
+
}
|
|
42
|
+
callThen(result, (output) => {
|
|
43
|
+
externalPromise.resolve(output);
|
|
44
|
+
quantityRunning--;
|
|
45
|
+
firstElement?.theFunction();
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
if (quantityRunning < concurrency) {
|
|
49
|
+
void preparedFunction();
|
|
50
|
+
}
|
|
51
|
+
else if (firstElement === undefined) {
|
|
52
|
+
firstElement = {
|
|
53
|
+
theFunction: preparedFunction,
|
|
54
|
+
next: undefined,
|
|
55
|
+
previous: undefined,
|
|
56
|
+
};
|
|
57
|
+
firstElement.next = firstElement;
|
|
58
|
+
firstElement.previous = firstElement;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const oldLast = firstElement.previous;
|
|
62
|
+
const newLastElement = {
|
|
63
|
+
theFunction: preparedFunction,
|
|
64
|
+
next: firstElement,
|
|
65
|
+
previous: firstElement.previous,
|
|
66
|
+
};
|
|
67
|
+
oldLast.next = newLastElement;
|
|
68
|
+
firstElement.previous = newLastElement;
|
|
69
|
+
}
|
|
70
|
+
return externalPromise.promise;
|
|
71
|
+
}
|
|
72
|
+
function addExternal() {
|
|
73
|
+
const externalPromiseToStart = createExternalPromise();
|
|
74
|
+
const externalPromiseToFinish = createExternalPromise();
|
|
75
|
+
void add(() => {
|
|
76
|
+
externalPromiseToStart.resolve(externalPromiseToFinish.resolve);
|
|
77
|
+
return externalPromiseToFinish.promise;
|
|
78
|
+
});
|
|
79
|
+
return externalPromiseToStart.promise;
|
|
80
|
+
}
|
|
81
|
+
return queueKind.setTo({
|
|
82
|
+
add,
|
|
83
|
+
addExternal,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { createQueue, queueKind };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type And<GenericBooleans extends [boolean, ...boolean[]]> = IsEqual<GenericBooleans[number], true>;
|
|
1
|
+
export type And<GenericBooleans extends [boolean, ...boolean[]]> = GenericBooleans[number] extends true ? true : false;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type Or<GenericBooleans extends [boolean, ...boolean[]]> = IsEqual<GenericBooleans[number] | false, boolean>;
|
|
1
|
+
export type Or<GenericBooleans extends [boolean, ...boolean[]]> = GenericBooleans[number] extends false ? false : true;
|
package/dist/dataParser/base.cjs
CHANGED
|
@@ -11,8 +11,6 @@ var errorKindNamespace = require('../common/errorKindNamespace.cjs');
|
|
|
11
11
|
var error$1 = require('../either/left/error.cjs');
|
|
12
12
|
var success = require('../either/right/success.cjs');
|
|
13
13
|
|
|
14
|
-
const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
15
|
-
const SymbolDataParserError = Symbol.for(SymbolDataParserErrorLabel);
|
|
16
14
|
const checkerKind = kind.createDataParserKind("checker");
|
|
17
15
|
function dataParserCheckerInit(kind, params, exec) {
|
|
18
16
|
return kind.setTo(checkerKind.setTo({
|
|
@@ -22,9 +20,7 @@ function dataParserCheckerInit(kind, params, exec) {
|
|
|
22
20
|
}
|
|
23
21
|
const dataParserKind = kind.createDataParserKind("base");
|
|
24
22
|
// This allows for better performance WTF ???
|
|
25
|
-
const
|
|
26
|
-
const SDPEPI = error.SymbolDataParserErrorPromiseIssue;
|
|
27
|
-
const SDPE = SymbolDataParserError;
|
|
23
|
+
const SDPE = error.SymbolDataParserError;
|
|
28
24
|
const DPE = error.createError();
|
|
29
25
|
const EE = error$1.error(null);
|
|
30
26
|
const ES = success.success(null);
|
|
@@ -44,22 +40,13 @@ function dataParserInit(kind, definition, exec, specificOverrideHandler) {
|
|
|
44
40
|
async: exec,
|
|
45
41
|
isAsynchronous: () => false,
|
|
46
42
|
};
|
|
47
|
-
function middleExec(data, error
|
|
48
|
-
let result = formattedExec.sync(data, error
|
|
49
|
-
if (result
|
|
50
|
-
error.addIssue(error$1, self, data);
|
|
51
|
-
return SDPE;
|
|
52
|
-
}
|
|
53
|
-
else if (result === SDPEPI) {
|
|
54
|
-
error.addPromiseIssue(error$1, self, data);
|
|
55
|
-
return SDPE;
|
|
56
|
-
}
|
|
57
|
-
else if (result !== SDPE
|
|
43
|
+
function middleExec(data, error) {
|
|
44
|
+
let result = formattedExec.sync(data, error, self);
|
|
45
|
+
if (result !== SDPE
|
|
58
46
|
&& self.definition.checkers.length) {
|
|
59
47
|
for (const checker of self.definition.checkers) {
|
|
60
|
-
const checkerResult = checker.exec(result, checker);
|
|
61
|
-
if (checkerResult ===
|
|
62
|
-
error.addIssue(error$1, checker, result);
|
|
48
|
+
const checkerResult = checker.exec(result, error, checker);
|
|
49
|
+
if (checkerResult === SDPE) {
|
|
63
50
|
return SDPE;
|
|
64
51
|
}
|
|
65
52
|
else {
|
|
@@ -69,22 +56,13 @@ function dataParserInit(kind, definition, exec, specificOverrideHandler) {
|
|
|
69
56
|
}
|
|
70
57
|
return result;
|
|
71
58
|
}
|
|
72
|
-
async function middleAsyncExec(data, error
|
|
73
|
-
let result = await formattedExec.async(data, error
|
|
74
|
-
if (result
|
|
75
|
-
error.addIssue(error$1, self, data);
|
|
76
|
-
return SDPE;
|
|
77
|
-
}
|
|
78
|
-
else if (result === SDPEPI) {
|
|
79
|
-
error.addPromiseIssue(error$1, self, data);
|
|
80
|
-
return SDPE;
|
|
81
|
-
}
|
|
82
|
-
else if (result !== SDPE
|
|
59
|
+
async function middleAsyncExec(data, error) {
|
|
60
|
+
let result = await formattedExec.async(data, error, self);
|
|
61
|
+
if (result !== SDPE
|
|
83
62
|
&& self.definition.checkers.length) {
|
|
84
63
|
for (const checker of self.definition.checkers) {
|
|
85
|
-
const checkerResult = checker.exec(result, checker);
|
|
86
|
-
if (checkerResult ===
|
|
87
|
-
error.addIssue(error$1, checker, result);
|
|
64
|
+
const checkerResult = checker.exec(result, error, checker);
|
|
65
|
+
if (checkerResult === SDPE) {
|
|
88
66
|
return SDPE;
|
|
89
67
|
}
|
|
90
68
|
else {
|
|
@@ -172,9 +150,8 @@ function dataParserInit(kind, definition, exec, specificOverrideHandler) {
|
|
|
172
150
|
}
|
|
173
151
|
dataParserInit.overrideHandler = override.createOverride("@duplojs/utils/data-parser/base");
|
|
174
152
|
|
|
153
|
+
exports.SymbolDataParserError = error.SymbolDataParserError;
|
|
175
154
|
exports.DataParserThrowError = DataParserThrowError;
|
|
176
|
-
exports.SymbolDataParserError = SymbolDataParserError;
|
|
177
|
-
exports.SymbolDataParserErrorLabel = SymbolDataParserErrorLabel;
|
|
178
155
|
exports.checkerKind = checkerKind;
|
|
179
156
|
exports.dataParserCheckerInit = dataParserCheckerInit;
|
|
180
157
|
exports.dataParserInit = dataParserInit;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { type GetKind, type GetKindHandler, type GetKindValue, type IsEqual, type Kind, type KindHandler, type OverrideHandler, type RemoveKind } from "../common";
|
|
2
|
-
import {
|
|
2
|
+
import { SymbolDataParserError, type DataParserError } from "./error";
|
|
3
3
|
import * as DEither from "../either";
|
|
4
|
-
export
|
|
5
|
-
export declare const SymbolDataParserError: unique symbol;
|
|
6
|
-
export type SymbolDataParserError = typeof SymbolDataParserError;
|
|
4
|
+
export { SymbolDataParserError } from "./error";
|
|
7
5
|
export declare const checkerKind: KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/checker", unknown>>;
|
|
8
6
|
export interface DataParserCheckerDefinition {
|
|
9
7
|
readonly errorMessage?: string;
|
|
10
8
|
}
|
|
11
9
|
export interface DataParserChecker<GenericDefinition extends DataParserCheckerDefinition = DataParserCheckerDefinition, GenericInput extends unknown = unknown> extends Kind<typeof checkerKind.definition, GenericInput> {
|
|
12
10
|
readonly definition: GenericDefinition;
|
|
13
|
-
exec(data: GenericInput, self: this): GenericInput |
|
|
11
|
+
exec(data: GenericInput, error: DataParserError, self: this): GenericInput | SymbolDataParserError;
|
|
14
12
|
}
|
|
15
13
|
export type InputChecker<GenericDataParser extends DataParserChecker> = Parameters<GenericDataParser["exec"]>[0];
|
|
16
|
-
export declare function dataParserCheckerInit<GenericDataParserChecker extends DataParserChecker>(kind: Exclude<GetKindHandler<GenericDataParserChecker>, typeof checkerKind>, params: NoInfer<Omit<RemoveKind<GenericDataParserChecker>, "exec">>, exec: (...args: Parameters<GenericDataParserChecker["exec"]>) => GetKindValue<typeof checkerKind, GenericDataParserChecker> |
|
|
14
|
+
export declare function dataParserCheckerInit<GenericDataParserChecker extends DataParserChecker>(kind: Exclude<GetKindHandler<GenericDataParserChecker>, typeof checkerKind>, params: NoInfer<Omit<RemoveKind<GenericDataParserChecker>, "exec">>, exec: (...args: Parameters<GenericDataParserChecker["exec"]>) => GetKindValue<typeof checkerKind, GenericDataParserChecker> | SymbolDataParserError): GenericDataParserChecker;
|
|
17
15
|
export declare const dataParserKind: KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/base", {
|
|
18
16
|
input: unknown;
|
|
19
17
|
output: unknown;
|
|
@@ -239,8 +237,8 @@ export interface DataParser<GenericDefinition extends DataParserDefinition = Dat
|
|
|
239
237
|
isAsynchronous(): boolean;
|
|
240
238
|
}
|
|
241
239
|
interface DataParserInitExecParams<GenericDataParser extends DataParser> {
|
|
242
|
-
sync(...args: [...Parameters<GenericDataParser["exec"]>, self: GenericDataParser]): (GetKindValue<typeof dataParserKind, GenericDataParser>["output"] | SymbolDataParserError
|
|
243
|
-
async(...args: [...Parameters<GenericDataParser["exec"]>, self: GenericDataParser]): Promise<GetKindValue<typeof dataParserKind, GenericDataParser>["output"] | SymbolDataParserError
|
|
240
|
+
sync(...args: [...Parameters<GenericDataParser["exec"]>, self: GenericDataParser]): (GetKindValue<typeof dataParserKind, GenericDataParser>["output"] | SymbolDataParserError);
|
|
241
|
+
async(...args: [...Parameters<GenericDataParser["exec"]>, self: GenericDataParser]): Promise<GetKindValue<typeof dataParserKind, GenericDataParser>["output"] | SymbolDataParserError>;
|
|
244
242
|
isAsynchronous(self: GenericDataParser): boolean;
|
|
245
243
|
}
|
|
246
244
|
declare const DataParserThrowError_base: new (params: {
|
|
@@ -261,4 +259,3 @@ export type AdvancedContract<GenericDataParser extends DataParser> = (GetKind<Ge
|
|
|
261
259
|
addChecker(...args: never): AdvancedContract<GenericDataParser>;
|
|
262
260
|
clone(): AdvancedContract<GenericDataParser>;
|
|
263
261
|
});
|
|
264
|
-
export {};
|
package/dist/dataParser/base.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createError,
|
|
1
|
+
import { createError, SymbolDataParserError } from './error.mjs';
|
|
2
2
|
import { createDataParserKind } from './kind.mjs';
|
|
3
3
|
import { simpleClone } from '../common/simpleClone.mjs';
|
|
4
4
|
import { keyWrappedValue } from '../common/wrapValue.mjs';
|
|
@@ -9,8 +9,6 @@ import { createErrorKind } from '../common/errorKindNamespace.mjs';
|
|
|
9
9
|
import { error } from '../either/left/error.mjs';
|
|
10
10
|
import { success } from '../either/right/success.mjs';
|
|
11
11
|
|
|
12
|
-
const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
13
|
-
const SymbolDataParserError = Symbol.for(SymbolDataParserErrorLabel);
|
|
14
12
|
const checkerKind = createDataParserKind("checker");
|
|
15
13
|
function dataParserCheckerInit(kind, params, exec) {
|
|
16
14
|
return kind.setTo(checkerKind.setTo({
|
|
@@ -20,8 +18,6 @@ function dataParserCheckerInit(kind, params, exec) {
|
|
|
20
18
|
}
|
|
21
19
|
const dataParserKind = createDataParserKind("base");
|
|
22
20
|
// This allows for better performance WTF ???
|
|
23
|
-
const SDPEI = SymbolDataParserErrorIssue;
|
|
24
|
-
const SDPEPI = SymbolDataParserErrorPromiseIssue;
|
|
25
21
|
const SDPE = SymbolDataParserError;
|
|
26
22
|
const DPE = createError();
|
|
27
23
|
const EE = error(null);
|
|
@@ -44,20 +40,11 @@ function dataParserInit(kind, definition, exec, specificOverrideHandler) {
|
|
|
44
40
|
};
|
|
45
41
|
function middleExec(data, error) {
|
|
46
42
|
let result = formattedExec.sync(data, error, self);
|
|
47
|
-
if (result
|
|
48
|
-
addIssue(error, self, data);
|
|
49
|
-
return SDPE;
|
|
50
|
-
}
|
|
51
|
-
else if (result === SDPEPI) {
|
|
52
|
-
addPromiseIssue(error, self, data);
|
|
53
|
-
return SDPE;
|
|
54
|
-
}
|
|
55
|
-
else if (result !== SDPE
|
|
43
|
+
if (result !== SDPE
|
|
56
44
|
&& self.definition.checkers.length) {
|
|
57
45
|
for (const checker of self.definition.checkers) {
|
|
58
|
-
const checkerResult = checker.exec(result, checker);
|
|
59
|
-
if (checkerResult ===
|
|
60
|
-
addIssue(error, checker, result);
|
|
46
|
+
const checkerResult = checker.exec(result, error, checker);
|
|
47
|
+
if (checkerResult === SDPE) {
|
|
61
48
|
return SDPE;
|
|
62
49
|
}
|
|
63
50
|
else {
|
|
@@ -69,20 +56,11 @@ function dataParserInit(kind, definition, exec, specificOverrideHandler) {
|
|
|
69
56
|
}
|
|
70
57
|
async function middleAsyncExec(data, error) {
|
|
71
58
|
let result = await formattedExec.async(data, error, self);
|
|
72
|
-
if (result
|
|
73
|
-
addIssue(error, self, data);
|
|
74
|
-
return SDPE;
|
|
75
|
-
}
|
|
76
|
-
else if (result === SDPEPI) {
|
|
77
|
-
addPromiseIssue(error, self, data);
|
|
78
|
-
return SDPE;
|
|
79
|
-
}
|
|
80
|
-
else if (result !== SDPE
|
|
59
|
+
if (result !== SDPE
|
|
81
60
|
&& self.definition.checkers.length) {
|
|
82
61
|
for (const checker of self.definition.checkers) {
|
|
83
|
-
const checkerResult = checker.exec(result, checker);
|
|
84
|
-
if (checkerResult ===
|
|
85
|
-
addIssue(error, checker, result);
|
|
62
|
+
const checkerResult = checker.exec(result, error, checker);
|
|
63
|
+
if (checkerResult === SDPE) {
|
|
86
64
|
return SDPE;
|
|
87
65
|
}
|
|
88
66
|
else {
|
|
@@ -170,4 +148,4 @@ function dataParserInit(kind, definition, exec, specificOverrideHandler) {
|
|
|
170
148
|
}
|
|
171
149
|
dataParserInit.overrideHandler = createOverride("@duplojs/utils/data-parser/base");
|
|
172
150
|
|
|
173
|
-
export { DataParserThrowError, SymbolDataParserError,
|
|
151
|
+
export { DataParserThrowError, SymbolDataParserError, checkerKind, dataParserCheckerInit, dataParserInit, dataParserKind };
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var kind = require('./kind.cjs');
|
|
4
|
+
var printer = require('../common/printer.cjs');
|
|
5
|
+
var unwrap = require('../common/unwrap.cjs');
|
|
4
6
|
|
|
5
|
-
const
|
|
7
|
+
const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
8
|
+
const SymbolDataParserError = Symbol.for(SymbolDataParserErrorLabel);
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
const SymbolDataParserErrorIssueLabel = "SymbolDataParserError";
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
6
16
|
const SymbolDataParserErrorIssue = Symbol.for(SymbolDataParserErrorIssueLabel);
|
|
7
17
|
const errorIssueKind = kind.createDataParserKind("error-issue");
|
|
8
|
-
const SymbolDataParserErrorPromiseIssueLabel = "SymbolDataParserErrorPromiseIssue";
|
|
9
|
-
const SymbolDataParserErrorPromiseIssue = Symbol.for(SymbolDataParserErrorPromiseIssueLabel);
|
|
10
|
-
const errorPromiseIssueKind = kind.createDataParserKind("error-issue-promise");
|
|
11
18
|
const errorKind = kind.createDataParserKind("error");
|
|
12
19
|
function createError() {
|
|
13
20
|
return errorKind.setTo({
|
|
@@ -15,23 +22,14 @@ function createError() {
|
|
|
15
22
|
currentPath: [],
|
|
16
23
|
});
|
|
17
24
|
}
|
|
18
|
-
function addIssue(error,
|
|
25
|
+
function addIssue(error, expected, data, message) {
|
|
19
26
|
error.issues.push(errorIssueKind.setTo({
|
|
20
|
-
|
|
27
|
+
expected,
|
|
21
28
|
path: error.currentPath.join("."),
|
|
22
29
|
data,
|
|
23
|
-
|
|
30
|
+
message,
|
|
24
31
|
}));
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
function addPromiseIssue(error, source, data, moreInformation) {
|
|
28
|
-
error.issues.push(errorPromiseIssueKind.setTo({
|
|
29
|
-
source,
|
|
30
|
-
path: error.currentPath.join("."),
|
|
31
|
-
data,
|
|
32
|
-
moreInformation,
|
|
33
|
-
}));
|
|
34
|
-
return error;
|
|
32
|
+
return SymbolDataParserError;
|
|
35
33
|
}
|
|
36
34
|
function setErrorPath(error, value, index) {
|
|
37
35
|
error.currentPath[index] = value;
|
|
@@ -41,16 +39,36 @@ function popErrorPath(error) {
|
|
|
41
39
|
error.currentPath.pop();
|
|
42
40
|
return error;
|
|
43
41
|
}
|
|
42
|
+
function interpretError(error) {
|
|
43
|
+
const dataParserError = errorKind.has(error)
|
|
44
|
+
? error
|
|
45
|
+
: unwrap.unwrap(error);
|
|
46
|
+
return printer.Printer.renderParagraph([
|
|
47
|
+
printer.Printer.colorizedBold("Validation failed", "red"),
|
|
48
|
+
dataParserError.issues.map((issue) => printer.Printer.renderParagraph([
|
|
49
|
+
"",
|
|
50
|
+
printer.Printer.renderLine([
|
|
51
|
+
printer.Printer.colorizedBold("✖", "red"),
|
|
52
|
+
printer.Printer.colorizedBold(issue.path || "<root>", "cyan"),
|
|
53
|
+
"expected",
|
|
54
|
+
printer.Printer.colorized(issue.expected, "green"),
|
|
55
|
+
"but received",
|
|
56
|
+
printer.Printer.colorized(printer.Printer.stringify(issue.data), "red"),
|
|
57
|
+
]),
|
|
58
|
+
issue.message !== undefined && `${printer.Printer.indent(1)}↳ ${issue.message}`,
|
|
59
|
+
])),
|
|
60
|
+
dataParserError.issues.length === 0 && "No issue found",
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
44
63
|
|
|
64
|
+
exports.SymbolDataParserError = SymbolDataParserError;
|
|
45
65
|
exports.SymbolDataParserErrorIssue = SymbolDataParserErrorIssue;
|
|
46
66
|
exports.SymbolDataParserErrorIssueLabel = SymbolDataParserErrorIssueLabel;
|
|
47
|
-
exports.
|
|
48
|
-
exports.SymbolDataParserErrorPromiseIssueLabel = SymbolDataParserErrorPromiseIssueLabel;
|
|
67
|
+
exports.SymbolDataParserErrorLabel = SymbolDataParserErrorLabel;
|
|
49
68
|
exports.addIssue = addIssue;
|
|
50
|
-
exports.addPromiseIssue = addPromiseIssue;
|
|
51
69
|
exports.createError = createError;
|
|
52
70
|
exports.errorIssueKind = errorIssueKind;
|
|
53
71
|
exports.errorKind = errorKind;
|
|
54
|
-
exports.
|
|
72
|
+
exports.interpretError = interpretError;
|
|
55
73
|
exports.popErrorPath = popErrorPath;
|
|
56
74
|
exports.setErrorPath = setErrorPath;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { type Kind } from "../common";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
2
|
+
import type * as DEither from "../either";
|
|
3
|
+
export declare const SymbolDataParserErrorLabel = "SymbolDataParserError";
|
|
4
|
+
export declare const SymbolDataParserError: unique symbol;
|
|
5
|
+
export type SymbolDataParserError = typeof SymbolDataParserError;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
export declare const SymbolDataParserErrorIssueLabel = "SymbolDataParserError";
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
6
13
|
export declare const SymbolDataParserErrorIssue: unique symbol;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated
|
|
16
|
+
*/
|
|
7
17
|
export type SymbolDataParserErrorIssue = typeof SymbolDataParserErrorIssue;
|
|
8
18
|
export declare const errorIssueKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/error-issue", unknown>>;
|
|
9
19
|
export interface DataParserErrorIssue extends Kind<typeof errorIssueKind.definition> {
|
|
10
|
-
readonly
|
|
20
|
+
readonly expected: string;
|
|
11
21
|
readonly path: string;
|
|
12
22
|
readonly data: unknown;
|
|
13
|
-
readonly
|
|
14
|
-
}
|
|
15
|
-
export declare const SymbolDataParserErrorPromiseIssueLabel = "SymbolDataParserErrorPromiseIssue";
|
|
16
|
-
export declare const SymbolDataParserErrorPromiseIssue: unique symbol;
|
|
17
|
-
export type SymbolDataParserErrorPromiseIssue = typeof SymbolDataParserErrorPromiseIssue;
|
|
18
|
-
export declare const errorPromiseIssueKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/error-issue-promise", unknown>>;
|
|
19
|
-
export interface DataParserErrorPromiseIssue extends Kind<typeof errorPromiseIssueKind.definition> {
|
|
20
|
-
readonly source: DataParserTransform;
|
|
21
|
-
readonly path: string;
|
|
22
|
-
readonly data: unknown;
|
|
23
|
-
readonly moreInformation?: string;
|
|
23
|
+
readonly message: string | undefined;
|
|
24
24
|
}
|
|
25
25
|
export declare const errorKind: import("../common").KindHandler<import("../common").KindDefinition<"@DuplojsUtilsDataParser/error", unknown>>;
|
|
26
26
|
export interface DataParserError extends Kind<typeof errorKind.definition> {
|
|
27
|
-
readonly issues:
|
|
27
|
+
readonly issues: DataParserErrorIssue[];
|
|
28
28
|
readonly currentPath: string[];
|
|
29
29
|
}
|
|
30
30
|
export declare function createError(): DataParserError;
|
|
31
|
-
export declare function addIssue(error: DataParserError,
|
|
32
|
-
export declare function addPromiseIssue(error: DataParserError, source: DataParserTransform, data: unknown, moreInformation?: string): DataParserError;
|
|
31
|
+
export declare function addIssue(error: DataParserError, expected: string, data: unknown, message: string | undefined): SymbolDataParserError;
|
|
33
32
|
export declare function setErrorPath(error: DataParserError, value: string, index: number): DataParserError;
|
|
34
33
|
export declare function popErrorPath(error: DataParserError): DataParserError;
|
|
34
|
+
export declare function interpretError(error: DataParserError | DEither.Left<string, DataParserError>): string;
|