@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
package/dist/clean/index.d.ts
CHANGED
package/dist/clean/index.mjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { createCleanKind } from './kind.mjs';
|
|
2
2
|
export { CreateNewTypeError, createNewType, newTypeHandlerKind, newTypeKind } from './newType.mjs';
|
|
3
|
-
export { CreateEntityError, createEntity, entityKind } from './entity/index.mjs';
|
|
3
|
+
export { CreateEntityError, createEntity, entityHandlerKind, entityKind } from './entity/index.mjs';
|
|
4
4
|
export { createRepository, repositoryHandlerKind } from './repository.mjs';
|
|
5
5
|
export { createUseCase, useCaseHandlerKind, useCaseInstances } from './useCase.mjs';
|
|
6
6
|
export { createFlag, flagKind } from './flag.mjs';
|
|
7
7
|
export { none, some } from './maybe.mjs';
|
|
8
|
+
export { toMapDataParser } from './toMapDataParser.mjs';
|
|
8
9
|
export { entityPropertyArrayKind, entityPropertyDefinitionToDataParser, entityPropertyDefinitionTools, entityPropertyIdentifierKind, entityPropertyNullableKind, entityPropertyStructureKind, entityPropertyUnionKind } from './entity/property.mjs';
|
|
9
10
|
export { unwrapEntity, unwrapEntityProperty } from './entity/unwrap.mjs';
|
|
10
11
|
export { CreateConstrainedTypeError, constrainedTypeKind, constraintHandlerKind, createConstraint } from './constraint/base.mjs';
|
|
11
|
-
export {
|
|
12
|
+
export { castConstraint } from './constraint/cast.mjs';
|
|
13
|
+
export { Int, Negative, NumberMax, NumberMin, Positive } from './constraint/defaultConstraint/number.mjs';
|
|
12
14
|
export { Email, StringMax, StringMin, Url } from './constraint/defaultConstraint/string.mjs';
|
|
13
15
|
export { NegativeTime, PositiveTime } from './constraint/defaultConstraint/time.mjs';
|
|
14
16
|
export { CreateConstraintsSetError, constraintsSetHandlerKind, createConstraintsSet } from './constraint/set.mjs';
|
package/dist/clean/newType.cjs
CHANGED
|
@@ -35,7 +35,7 @@ class CreateNewTypeError extends kind$1.kindHeritage("create-new-type-error", er
|
|
|
35
35
|
*/
|
|
36
36
|
function createNewType(name, dataParser, constraint) {
|
|
37
37
|
const constraints = coalescing.coalescing(constraint ?? []);
|
|
38
|
-
const checkers = flatMap.flatMap(constraints, ({
|
|
38
|
+
const checkers = flatMap.flatMap(constraints, ({ internal }) => internal.checkers);
|
|
39
39
|
const dataParserWithCheckers = constraint
|
|
40
40
|
? dataParser.addChecker(...checkers)
|
|
41
41
|
: dataParser;
|
|
@@ -85,6 +85,11 @@ function createNewType(name, dataParser, constraint) {
|
|
|
85
85
|
name,
|
|
86
86
|
dataParser: dataParserWithCheckers,
|
|
87
87
|
constraints,
|
|
88
|
+
internal: {
|
|
89
|
+
dataParser: dataParserWithCheckers,
|
|
90
|
+
constraints,
|
|
91
|
+
constraintKindValue,
|
|
92
|
+
},
|
|
88
93
|
getConstraint,
|
|
89
94
|
create: create$2,
|
|
90
95
|
createOrThrow,
|
package/dist/clean/newType.d.ts
CHANGED
|
@@ -17,15 +17,30 @@ export interface NewTypeHandler<GenericName extends string = string, GenericValu
|
|
|
17
17
|
*/
|
|
18
18
|
readonly name: GenericName;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* @deprecated
|
|
22
21
|
*/
|
|
23
22
|
readonly dataParser: DDataParser.Contract<GenericValue, unknown>;
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* @deprecated
|
|
27
25
|
*/
|
|
28
26
|
readonly constraints: GenericConstraintsHandler;
|
|
27
|
+
readonly internal: {
|
|
28
|
+
/**
|
|
29
|
+
* The DataParser used to validate and transform raw inputs.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
readonly dataParser: DDataParser.Contract<GenericValue, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* The list of constraints applied to this NewType.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
readonly constraints: GenericConstraintsHandler;
|
|
38
|
+
/**
|
|
39
|
+
* The constraint kind metadata applied to this NewType.
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
readonly constraintKindValue: Record<string, null>;
|
|
43
|
+
};
|
|
29
44
|
/**
|
|
30
45
|
* Creates a NewType value and returns an Either.
|
|
31
46
|
*
|
|
@@ -156,5 +171,5 @@ export declare function createNewType<GenericName extends string, GenericDataPar
|
|
|
156
171
|
export declare namespace createNewType {
|
|
157
172
|
var overrideHandler: import("..").OverrideHandler<NewTypeHandler<string, unknown, readonly ConstraintHandler<string, EligiblePrimitive, readonly DDataParser.DataParserChecker<DDataParser.DataParserCheckerDefinition, unknown>[], unknown>[], unknown>>;
|
|
158
173
|
}
|
|
159
|
-
export type GetNewType<GenericHandler extends NewTypeHandler<string, unknown, readonly any[]>, GenericValue extends DDataParser.Output<GenericHandler["dataParser"]> = DDataParser.Output<GenericHandler["dataParser"]>> = Extract<GenericHandler extends any ? NewType<GenericHandler["name"], GenericValue, GenericHandler["constraints"][number]["name"]> : never, any>;
|
|
174
|
+
export type GetNewType<GenericHandler extends NewTypeHandler<string, unknown, readonly any[]>, GenericValue extends DDataParser.Output<GenericHandler["internal"]["dataParser"]> = DDataParser.Output<GenericHandler["internal"]["dataParser"]>> = Extract<GenericHandler extends any ? NewType<GenericHandler["name"], GenericValue, GenericHandler["internal"]["constraints"][number]["name"]> : never, any>;
|
|
160
175
|
export {};
|
package/dist/clean/newType.mjs
CHANGED
|
@@ -33,7 +33,7 @@ class CreateNewTypeError extends kindHeritage("create-new-type-error", createErr
|
|
|
33
33
|
*/
|
|
34
34
|
function createNewType(name, dataParser, constraint) {
|
|
35
35
|
const constraints = coalescing(constraint ?? []);
|
|
36
|
-
const checkers = flatMap(constraints, ({
|
|
36
|
+
const checkers = flatMap(constraints, ({ internal }) => internal.checkers);
|
|
37
37
|
const dataParserWithCheckers = constraint
|
|
38
38
|
? dataParser.addChecker(...checkers)
|
|
39
39
|
: dataParser;
|
|
@@ -83,6 +83,11 @@ function createNewType(name, dataParser, constraint) {
|
|
|
83
83
|
name,
|
|
84
84
|
dataParser: dataParserWithCheckers,
|
|
85
85
|
constraints,
|
|
86
|
+
internal: {
|
|
87
|
+
dataParser: dataParserWithCheckers,
|
|
88
|
+
constraints,
|
|
89
|
+
constraintKindValue,
|
|
90
|
+
},
|
|
86
91
|
getConstraint,
|
|
87
92
|
create,
|
|
88
93
|
createOrThrow,
|
|
@@ -8,6 +8,9 @@ function equal(...args) {
|
|
|
8
8
|
return (input) => equal(input, value);
|
|
9
9
|
}
|
|
10
10
|
const [input, value] = args;
|
|
11
|
+
if (input === null || value === null) {
|
|
12
|
+
return input === value;
|
|
13
|
+
}
|
|
11
14
|
return unwrap.unwrap(input).toString() === unwrap.unwrap(value).toString();
|
|
12
15
|
}
|
|
13
16
|
|
|
@@ -34,5 +34,5 @@ import { type Primitive, type Primitives } from "../base";
|
|
|
34
34
|
* @namespace C
|
|
35
35
|
*
|
|
36
36
|
*/
|
|
37
|
-
export declare function equal<GenericInput extends Primitives, GenericValue extends (Primitive<Unwrap<GenericInput
|
|
38
|
-
export declare function equal<GenericInput extends Primitives, GenericValue extends (Primitive<Unwrap<GenericInput
|
|
37
|
+
export declare function equal<GenericInput extends Primitives | null, const GenericValue extends (Primitive<Unwrap<Exclude<GenericInput, null>>> | Unwrap<GenericInput>)>(value: GenericValue): (input: GenericInput) => input is (GenericInput & (GenericValue extends null ? GenericValue : Primitive<Unwrap<Exclude<GenericValue, null>>>));
|
|
38
|
+
export declare function equal<GenericInput extends Primitives | null, const GenericValue extends (Primitive<Unwrap<Exclude<GenericInput, null>>> | Unwrap<GenericInput>)>(input: GenericInput, value: GenericValue): input is (GenericInput & (GenericValue extends null ? GenericValue : Primitive<Unwrap<Exclude<GenericValue, null>>>));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var newType = require('./newType.cjs');
|
|
4
|
+
var base = require('./primitive/base.cjs');
|
|
5
|
+
var base$1 = require('./constraint/base.cjs');
|
|
6
|
+
var set = require('./constraint/set.cjs');
|
|
7
|
+
var hasSomeKinds = require('../common/hasSomeKinds.cjs');
|
|
8
|
+
var index = require('../pattern/match/index.cjs');
|
|
9
|
+
var transform = require('../dataParser/parsers/transform.cjs');
|
|
10
|
+
var index$1 = require('../dataParser/parsers/string/index.cjs');
|
|
11
|
+
var index$2 = require('../dataParser/parsers/number/index.cjs');
|
|
12
|
+
var index$3 = require('../dataParser/parsers/bigint/index.cjs');
|
|
13
|
+
var boolean = require('../dataParser/parsers/boolean.cjs');
|
|
14
|
+
var date = require('../dataParser/parsers/date.cjs');
|
|
15
|
+
var index$4 = require('../dataParser/parsers/time/index.cjs');
|
|
16
|
+
var empty = require('../dataParser/parsers/empty.cjs');
|
|
17
|
+
var nil = require('../dataParser/parsers/nil.cjs');
|
|
18
|
+
var wrapValue = require('../common/wrapValue.cjs');
|
|
19
|
+
|
|
20
|
+
function toMapDataParser(input, params) {
|
|
21
|
+
const dataParser = (base.primitiveHandlerKind.has(input)
|
|
22
|
+
? input.dataParser.clone()
|
|
23
|
+
: input.internal.dataParser.clone());
|
|
24
|
+
if (params?.coerce
|
|
25
|
+
&& hasSomeKinds.hasSomeKinds(dataParser, [
|
|
26
|
+
index$1.stringKind,
|
|
27
|
+
index$2.numberKind,
|
|
28
|
+
index$3.bigIntKind,
|
|
29
|
+
index$3.bigIntKind,
|
|
30
|
+
boolean.booleanKind,
|
|
31
|
+
date.dateKind,
|
|
32
|
+
index$4.timeKind,
|
|
33
|
+
empty.emptyKind,
|
|
34
|
+
nil.nilKind,
|
|
35
|
+
])) {
|
|
36
|
+
dataParser.definition.coerce = true;
|
|
37
|
+
}
|
|
38
|
+
const valueContainer = index.match(input)
|
|
39
|
+
.when(newType.newTypeHandlerKind.has, (newType$1) => ({
|
|
40
|
+
...newType.newTypeKind.setTo({}, newType$1.name),
|
|
41
|
+
...base$1.constrainedTypeKind.setTo({}, newType$1.internal.constraintKindValue),
|
|
42
|
+
}))
|
|
43
|
+
.when(hasSomeKinds.hasSomeKinds([base$1.constraintHandlerKind, set.constraintsSetHandlerKind]), (constraintOrSet) => base$1.constrainedTypeKind.setTo({}, constraintOrSet.internal.constraintKindValue))
|
|
44
|
+
.when(base.primitiveHandlerKind.has, () => ({}))
|
|
45
|
+
.exhaustive();
|
|
46
|
+
return transform.transform(dataParser, (value) => ({
|
|
47
|
+
...valueContainer,
|
|
48
|
+
[wrapValue.keyWrappedValue]: value,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.toMapDataParser = toMapDataParser;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as DDataParser from "../dataParser";
|
|
2
|
+
import { type ConstraintHandler, type ConstraintsSetHandler, type GetConstraint, type GetConstraints } from "./constraint";
|
|
3
|
+
import { type GetNewType, type NewTypeHandler } from "./newType";
|
|
4
|
+
import { type PrimitiveHandler } from "./primitive";
|
|
5
|
+
type ToMapDataParserInput = NewTypeHandler<any, any, readonly any[], any> | ConstraintHandler<any, any, readonly any[], any> | ConstraintsSetHandler<any, readonly any[], any> | PrimitiveHandler;
|
|
6
|
+
type OutputDataParser<GenericInput extends ToMapDataParserInput> = GenericInput extends NewTypeHandler<any, any, readonly any[], any> ? GetNewType<GenericInput> : GenericInput extends ConstraintHandler<any, any, readonly any[], any> ? GetConstraint<GenericInput> : GenericInput extends ConstraintsSetHandler<any, readonly any[], any> ? GetConstraints<GenericInput> : GenericInput extends PrimitiveHandler ? ReturnType<GenericInput["createWithUnknownOrThrow"]> : never;
|
|
7
|
+
interface ToMapDataParserParams {
|
|
8
|
+
coerce?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a DataParser that maps Clean handlers or primitives into a wrapped value object.
|
|
12
|
+
*
|
|
13
|
+
* **Supported call styles:**
|
|
14
|
+
* - Classic: `toMapDataParser(handler, params?)` -> returns a DataParser
|
|
15
|
+
* - Pipe: `pipe(handler, toMapDataParser)` -> returns a DataParser
|
|
16
|
+
*
|
|
17
|
+
* The resulting parser preserves kind tags (`newTypeKind`, `constrainedTypeKind`) and stores the parsed value under the wrapped value key. When `coerce` is enabled, compatible primitive parsers will coerce inputs before validation.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const ShortLabel = C.createNewType(
|
|
21
|
+
* "ShortLabel",
|
|
22
|
+
* DP.string(),
|
|
23
|
+
* [C.StringMax(5)],
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* const labelParser = C.toMapDataParser(ShortLabel);
|
|
27
|
+
* labelParser.parseOrThrow("hello");
|
|
28
|
+
*
|
|
29
|
+
* const userIdParser = pipe(
|
|
30
|
+
* C.Number,
|
|
31
|
+
* C.toMapDataParser,
|
|
32
|
+
* );
|
|
33
|
+
* userIdParser.parseOrThrow(42);
|
|
34
|
+
*
|
|
35
|
+
* const coerceParser = C.toMapDataParser(
|
|
36
|
+
* C.String,
|
|
37
|
+
* { coerce: true },
|
|
38
|
+
* );
|
|
39
|
+
* coerceParser.parseOrThrow(123);
|
|
40
|
+
*
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* - Supported inputs: `NewTypeHandler`, `ConstraintHandler`, `ConstraintsSetHandler`, and `PrimitiveHandler`.
|
|
45
|
+
* - Use `coerce: true` to allow conversions (e.g. number to string) on compatible parsers.
|
|
46
|
+
*
|
|
47
|
+
* @see https://utils.duplojs.dev/en/v1/api/clean/toMapDataParser
|
|
48
|
+
*
|
|
49
|
+
* @namespace C
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
export declare function toMapDataParser<GenericInput extends ToMapDataParserInput, GenericInputDataParser extends unknown = unknown>(input: GenericInput, params?: ToMapDataParserParams): DDataParser.Contract<OutputDataParser<GenericInput>, GenericInputDataParser>;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { newTypeHandlerKind, newTypeKind } from './newType.mjs';
|
|
2
|
+
import { primitiveHandlerKind } from './primitive/base.mjs';
|
|
3
|
+
import { constrainedTypeKind, constraintHandlerKind } from './constraint/base.mjs';
|
|
4
|
+
import { constraintsSetHandlerKind } from './constraint/set.mjs';
|
|
5
|
+
import { hasSomeKinds } from '../common/hasSomeKinds.mjs';
|
|
6
|
+
import { match } from '../pattern/match/index.mjs';
|
|
7
|
+
import { transform } from '../dataParser/parsers/transform.mjs';
|
|
8
|
+
import { stringKind } from '../dataParser/parsers/string/index.mjs';
|
|
9
|
+
import { numberKind } from '../dataParser/parsers/number/index.mjs';
|
|
10
|
+
import { bigIntKind } from '../dataParser/parsers/bigint/index.mjs';
|
|
11
|
+
import { booleanKind } from '../dataParser/parsers/boolean.mjs';
|
|
12
|
+
import { dateKind } from '../dataParser/parsers/date.mjs';
|
|
13
|
+
import { timeKind } from '../dataParser/parsers/time/index.mjs';
|
|
14
|
+
import { emptyKind } from '../dataParser/parsers/empty.mjs';
|
|
15
|
+
import { nilKind } from '../dataParser/parsers/nil.mjs';
|
|
16
|
+
import { keyWrappedValue } from '../common/wrapValue.mjs';
|
|
17
|
+
|
|
18
|
+
function toMapDataParser(input, params) {
|
|
19
|
+
const dataParser = (primitiveHandlerKind.has(input)
|
|
20
|
+
? input.dataParser.clone()
|
|
21
|
+
: input.internal.dataParser.clone());
|
|
22
|
+
if (params?.coerce
|
|
23
|
+
&& hasSomeKinds(dataParser, [
|
|
24
|
+
stringKind,
|
|
25
|
+
numberKind,
|
|
26
|
+
bigIntKind,
|
|
27
|
+
bigIntKind,
|
|
28
|
+
booleanKind,
|
|
29
|
+
dateKind,
|
|
30
|
+
timeKind,
|
|
31
|
+
emptyKind,
|
|
32
|
+
nilKind,
|
|
33
|
+
])) {
|
|
34
|
+
dataParser.definition.coerce = true;
|
|
35
|
+
}
|
|
36
|
+
const valueContainer = match(input)
|
|
37
|
+
.when(newTypeHandlerKind.has, (newType) => ({
|
|
38
|
+
...newTypeKind.setTo({}, newType.name),
|
|
39
|
+
...constrainedTypeKind.setTo({}, newType.internal.constraintKindValue),
|
|
40
|
+
}))
|
|
41
|
+
.when(hasSomeKinds([constraintHandlerKind, constraintsSetHandlerKind]), (constraintOrSet) => constrainedTypeKind.setTo({}, constraintOrSet.internal.constraintKindValue))
|
|
42
|
+
.when(primitiveHandlerKind.has, () => ({}))
|
|
43
|
+
.exhaustive();
|
|
44
|
+
return transform(dataParser, (value) => ({
|
|
45
|
+
...valueContainer,
|
|
46
|
+
[keyWrappedValue]: value,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { toMapDataParser };
|
package/dist/common/asserts.cjs
CHANGED
|
@@ -18,6 +18,18 @@ function asserts(input, predicate) {
|
|
|
18
18
|
throw new AssertsError(input);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
function forwardAsserts(...args) {
|
|
22
|
+
if (args.length === 1) {
|
|
23
|
+
const [theFunction] = args;
|
|
24
|
+
return (input) => forwardAsserts(input, theFunction);
|
|
25
|
+
}
|
|
26
|
+
const [input, theFunction] = args;
|
|
27
|
+
if (!theFunction(input)) {
|
|
28
|
+
throw new AssertsError(input);
|
|
29
|
+
}
|
|
30
|
+
return input;
|
|
31
|
+
}
|
|
21
32
|
|
|
22
33
|
exports.AssertsError = AssertsError;
|
|
23
34
|
exports.asserts = asserts;
|
|
35
|
+
exports.forwardAsserts = forwardAsserts;
|
package/dist/common/asserts.d.ts
CHANGED
|
@@ -33,4 +33,30 @@ export declare class AssertsError extends AssertsError_base {
|
|
|
33
33
|
*
|
|
34
34
|
*/
|
|
35
35
|
export declare function asserts<GenericInput extends unknown, GenericPredicate extends GenericInput>(input: GenericInput, predicate: (input: GenericInput) => input is GenericPredicate): asserts input is GenericPredicate;
|
|
36
|
+
/**
|
|
37
|
+
* The forwardAsserts() function throws when a predicate fails and returns the validated input. It supports classic and curried forms, with type-guard and boolean predicates.
|
|
38
|
+
*
|
|
39
|
+
* **Supported call styles:**
|
|
40
|
+
* - Classic: `forwardAsserts(input, predicate)` → returns the narrowed input or throws
|
|
41
|
+
* - Curried: `forwardAsserts(predicate)(input)` → returns the validated input or throws
|
|
42
|
+
*
|
|
43
|
+
* It is useful when you want both runtime validation and a returned value you can keep using directly, especially inside `pipe()`. With a type guard predicate, the return type is narrowed. With a boolean predicate, the original input type is preserved. It throws an `AssertsError` with the failing input value.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const input = "demo" as string | number;
|
|
47
|
+
* const result = forwardAsserts(input, isType("string"));
|
|
48
|
+
*
|
|
49
|
+
* const pipedResult = pipe(
|
|
50
|
+
* "admin" as string | number,
|
|
51
|
+
* forwardAsserts(isType("string")),
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/forwardAsserts
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export declare function forwardAsserts<GenericInput extends unknown, GenericPredicate extends GenericInput>(predicate: (input: GenericInput) => input is GenericPredicate): (input: GenericInput) => GenericPredicate;
|
|
59
|
+
export declare function forwardAsserts<GenericInput extends unknown>(predicate: (input: GenericInput) => boolean): (input: GenericInput) => GenericInput;
|
|
60
|
+
export declare function forwardAsserts<GenericInput extends unknown, GenericPredicate extends GenericInput>(input: GenericInput, predicate: (input: GenericInput) => input is GenericPredicate): GenericPredicate;
|
|
61
|
+
export declare function forwardAsserts<GenericInput extends unknown>(input: GenericInput, predicate: (input: GenericInput) => boolean): GenericInput;
|
|
36
62
|
export {};
|
package/dist/common/asserts.mjs
CHANGED
|
@@ -16,5 +16,16 @@ function asserts(input, predicate) {
|
|
|
16
16
|
throw new AssertsError(input);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
function forwardAsserts(...args) {
|
|
20
|
+
if (args.length === 1) {
|
|
21
|
+
const [theFunction] = args;
|
|
22
|
+
return (input) => forwardAsserts(input, theFunction);
|
|
23
|
+
}
|
|
24
|
+
const [input, theFunction] = args;
|
|
25
|
+
if (!theFunction(input)) {
|
|
26
|
+
throw new AssertsError(input);
|
|
27
|
+
}
|
|
28
|
+
return input;
|
|
29
|
+
}
|
|
19
30
|
|
|
20
|
-
export { AssertsError, asserts };
|
|
31
|
+
export { AssertsError, asserts, forwardAsserts };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* {@include common/callThen/index.md}
|
|
5
|
+
*/
|
|
6
|
+
function callThen(input, TheFunction) {
|
|
7
|
+
if (input instanceof Promise) {
|
|
8
|
+
return input
|
|
9
|
+
.then(TheFunction);
|
|
10
|
+
}
|
|
11
|
+
return TheFunction(input);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.callThen = callThen;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The callThen() function applies a callback to a value immediately, or waits for a promise input before running the same callback.
|
|
3
|
+
*
|
|
4
|
+
* Supported call styles:
|
|
5
|
+
* - Classic: `callThen(input, callback)` → returns a value or a promise depending on the input and callback
|
|
6
|
+
*
|
|
7
|
+
* Behavior:
|
|
8
|
+
* - direct values call the callback synchronously
|
|
9
|
+
* - `Promise` inputs call the callback through `.then(...)`
|
|
10
|
+
* - callback promises are preserved for direct values and flattened for `Promise` inputs
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const syncResult = callThen(
|
|
14
|
+
* 2,
|
|
15
|
+
* (value) => value * 3,
|
|
16
|
+
* );
|
|
17
|
+
* // type: number
|
|
18
|
+
*
|
|
19
|
+
* const asyncFromSync = callThen(
|
|
20
|
+
* "duplo",
|
|
21
|
+
* async(value) => Promise.resolve(value.toUpperCase()),
|
|
22
|
+
* );
|
|
23
|
+
* // type: Promise<string>
|
|
24
|
+
*
|
|
25
|
+
* const asyncFromPromise = callThen(
|
|
26
|
+
* Promise.resolve({
|
|
27
|
+
* count: 2,
|
|
28
|
+
* }),
|
|
29
|
+
* ({ count }) => count + 1,
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/callThen
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
export declare function callThen<GenericInput extends unknown, GenericOutput extends unknown>(input: GenericInput, TheFunction: (input: Awaited<GenericInput>) => GenericOutput): GenericInput extends Promise<unknown> ? Promise<Awaited<GenericOutput>> : GenericOutput;
|
package/dist/common/index.d.ts
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var repeat = require('../string/repeat.cjs');
|
|
4
|
+
|
|
5
|
+
exports.Printer = void 0;
|
|
6
|
+
(function (Printer) {
|
|
7
|
+
const codeColors = {
|
|
8
|
+
red: "\x1b[31m",
|
|
9
|
+
green: "\x1b[32m",
|
|
10
|
+
yellow: "\x1b[33m",
|
|
11
|
+
blue: "\x1b[34m",
|
|
12
|
+
magenta: "\x1b[35m",
|
|
13
|
+
cyan: "\x1b[36m",
|
|
14
|
+
gray: "\x1b[90m",
|
|
15
|
+
};
|
|
16
|
+
const codeBold = "\x1b[1m";
|
|
17
|
+
const codeReset = "\x1b[0m";
|
|
18
|
+
Printer.tab = "\t";
|
|
19
|
+
Printer.back = "\n";
|
|
20
|
+
Printer.dash = "-";
|
|
21
|
+
function colorized(...args) {
|
|
22
|
+
if (args.length === 1) {
|
|
23
|
+
const [color] = args;
|
|
24
|
+
return (input) => colorized(input, color);
|
|
25
|
+
}
|
|
26
|
+
const [input, color] = args;
|
|
27
|
+
return `${codeColors[color]}${input}${codeReset}`;
|
|
28
|
+
}
|
|
29
|
+
Printer.colorized = colorized;
|
|
30
|
+
/**
|
|
31
|
+
* {@include common/printer/bold/index.md}
|
|
32
|
+
*/
|
|
33
|
+
function bold(input) {
|
|
34
|
+
return `${codeBold}${input}${codeReset}`;
|
|
35
|
+
}
|
|
36
|
+
Printer.bold = bold;
|
|
37
|
+
function colorizedBold(...args) {
|
|
38
|
+
if (args.length === 1) {
|
|
39
|
+
const [color] = args;
|
|
40
|
+
return (input) => colorizedBold(input, color);
|
|
41
|
+
}
|
|
42
|
+
const [input, color] = args;
|
|
43
|
+
return bold(colorized(input, color));
|
|
44
|
+
}
|
|
45
|
+
Printer.colorizedBold = colorizedBold;
|
|
46
|
+
function indent(level) {
|
|
47
|
+
return repeat.repeat(Printer.tab, level);
|
|
48
|
+
}
|
|
49
|
+
Printer.indent = indent;
|
|
50
|
+
function stringify(value) {
|
|
51
|
+
try {
|
|
52
|
+
return JSON.stringify(value);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return String(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
Printer.stringify = stringify;
|
|
59
|
+
function render(...args) {
|
|
60
|
+
if (args.length === 1) {
|
|
61
|
+
const [joinCharacter] = args;
|
|
62
|
+
return (values) => render(values, joinCharacter);
|
|
63
|
+
}
|
|
64
|
+
const [values, joinCharacter] = args;
|
|
65
|
+
return values
|
|
66
|
+
.flat(Infinity)
|
|
67
|
+
.filter((value) => typeof value === "string" || value === true)
|
|
68
|
+
.join(joinCharacter);
|
|
69
|
+
}
|
|
70
|
+
Printer.render = render;
|
|
71
|
+
Printer.renderLine = render(" ");
|
|
72
|
+
Printer.renderParagraph = render(Printer.back);
|
|
73
|
+
})(exports.Printer || (exports.Printer = {}));
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export declare namespace Printer {
|
|
2
|
+
const codeColors: {
|
|
3
|
+
readonly red: "\u001B[31m";
|
|
4
|
+
readonly green: "\u001B[32m";
|
|
5
|
+
readonly yellow: "\u001B[33m";
|
|
6
|
+
readonly blue: "\u001B[34m";
|
|
7
|
+
readonly magenta: "\u001B[35m";
|
|
8
|
+
readonly cyan: "\u001B[36m";
|
|
9
|
+
readonly gray: "\u001B[90m";
|
|
10
|
+
};
|
|
11
|
+
export const tab = "\t";
|
|
12
|
+
export const back = "\n";
|
|
13
|
+
export const dash = "-";
|
|
14
|
+
export type Colors = keyof typeof codeColors;
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a string with the ANSI escape sequence of the selected color. Exists in immediate or curried form.
|
|
17
|
+
*
|
|
18
|
+
* **Supported call styles:**
|
|
19
|
+
* - Classic: `Printer.colorized(input, color)` -> returns the colored string
|
|
20
|
+
* - Curried: `Printer.colorized(color)` -> returns a function waiting for the string
|
|
21
|
+
*
|
|
22
|
+
* The function only adds the opening color code and the reset code around the input string.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const directResult = Printer.colorized("Hello", "green");
|
|
26
|
+
* // directResult: "\x1b[32mHello\x1b[0m"
|
|
27
|
+
*
|
|
28
|
+
* const pipedResult = pipe(
|
|
29
|
+
* "Warning",
|
|
30
|
+
* Printer.colorized("yellow"),
|
|
31
|
+
* );
|
|
32
|
+
* // pipedResult: "\x1b[33mWarning\x1b[0m"
|
|
33
|
+
*
|
|
34
|
+
* const errorResult = Printer.colorized("Error", "red");
|
|
35
|
+
* // errorResult: "\x1b[31mError\x1b[0m"
|
|
36
|
+
*
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/printer/colorized
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export function colorized<GenericInput extends string>(color: Colors): (input: GenericInput) => string;
|
|
43
|
+
export function colorized<GenericInput extends string>(input: GenericInput, color: Colors): string;
|
|
44
|
+
/**
|
|
45
|
+
* Wraps a string with the ANSI escape sequence for bold text.
|
|
46
|
+
*
|
|
47
|
+
* Signature: `Printer.bold(input)` -> returns the bold string
|
|
48
|
+
*
|
|
49
|
+
* The function prepends the bold code and appends the reset code without altering the input content.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const title = Printer.bold("Build report");
|
|
53
|
+
* // title: "\x1b[1mBuild report\x1b[0m"
|
|
54
|
+
*
|
|
55
|
+
* const symbol = Printer.bold("!");
|
|
56
|
+
* // symbol: "\x1b[1m!\x1b[0m"
|
|
57
|
+
*
|
|
58
|
+
* const empty = Printer.bold("");
|
|
59
|
+
* // empty: "\x1b[1m\x1b[0m"
|
|
60
|
+
*
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/printer/bold
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
export function bold(input: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Applies a color and bold formatting to a string by combining `Printer.colorized()` and `Printer.bold()`. Exists in immediate or curried form.
|
|
69
|
+
*
|
|
70
|
+
* **Supported call styles:**
|
|
71
|
+
* - Classic: `Printer.colorizedBold(input, color)` -> returns the formatted string
|
|
72
|
+
* - Curried: `Printer.colorizedBold(color)` -> returns a function waiting for the string
|
|
73
|
+
*
|
|
74
|
+
* The produced string contains the bold ANSI code, then the colorized content, and finally the reset codes.
|
|
75
|
+
*
|
|
76
|
+
* ```ts
|
|
77
|
+
* const directResult = Printer.colorizedBold("Fatal", "red");
|
|
78
|
+
* // directResult: "\x1b[1m\x1b[31mFatal\x1b[0m\x1b[0m"
|
|
79
|
+
*
|
|
80
|
+
* const pipedResult = pipe(
|
|
81
|
+
* "Info",
|
|
82
|
+
* Printer.colorizedBold("cyan"),
|
|
83
|
+
* );
|
|
84
|
+
* // pipedResult: "\x1b[1m\x1b[36mInfo\x1b[0m\x1b[0m"
|
|
85
|
+
*
|
|
86
|
+
* const successResult = Printer.colorizedBold("Done", "green");
|
|
87
|
+
* // successResult: "\x1b[1m\x1b[32mDone\x1b[0m\x1b[0m"
|
|
88
|
+
*
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/printer/colorizedBold
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
export function colorizedBold<GenericInput extends string>(color: Colors): (input: GenericInput) => string;
|
|
95
|
+
export function colorizedBold<GenericInput extends string>(input: GenericInput, color: Colors): string;
|
|
96
|
+
export function indent(level: number): string;
|
|
97
|
+
export function stringify(value: unknown): string;
|
|
98
|
+
export type RenderInput = string | boolean | null | undefined | RenderInput[];
|
|
99
|
+
/**
|
|
100
|
+
* Flattens printable values, keeps strings and `true`, then joins the result with a custom separator. Exists in immediate or curried form.
|
|
101
|
+
*
|
|
102
|
+
* **Supported call styles:**
|
|
103
|
+
* - Classic: `Printer.render(values, joinCharacter)` -> returns the rendered string
|
|
104
|
+
* - Curried: `Printer.render(joinCharacter)` -> returns a function waiting for the values array
|
|
105
|
+
*
|
|
106
|
+
* Nested arrays are flattened recursively. `false`, `null`, and `undefined` are ignored, while `true` is kept as the string `"true"`.
|
|
107
|
+
* The namespace also exposes two ready-to-use defaults: `Printer.renderLine`, which joins with a space, and `Printer.renderParagraph`, which joins with `Printer.back`.
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* const customResult = Printer.render(
|
|
111
|
+
* ["alpha", ["beta", false], true, undefined],
|
|
112
|
+
* " | ",
|
|
113
|
+
* );
|
|
114
|
+
* // customResult: "alpha | beta | true"
|
|
115
|
+
*
|
|
116
|
+
* const lineResult = Printer.renderLine([
|
|
117
|
+
* "hello",
|
|
118
|
+
* ["world", null],
|
|
119
|
+
* true,
|
|
120
|
+
* ]);
|
|
121
|
+
* // lineResult: "hello world true"
|
|
122
|
+
*
|
|
123
|
+
* const paragraphResult = pipe(
|
|
124
|
+
* ["title", ["", "body"], false, true] as const,
|
|
125
|
+
* Printer.renderParagraph,
|
|
126
|
+
* );
|
|
127
|
+
* // paragraphResult: "title\n\nbody\ntrue"
|
|
128
|
+
*
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @see https://utils.duplojs.dev/en/v1/api/common/printer/render
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
export function render<GenericValues extends readonly RenderInput[]>(joinCharacter: string): (values: GenericValues) => string;
|
|
135
|
+
export function render<GenericValues extends readonly RenderInput[]>(values: GenericValues, joinCharacter: string): string;
|
|
136
|
+
export const renderLine: (values: readonly RenderInput[]) => string;
|
|
137
|
+
export const renderParagraph: (values: readonly RenderInput[]) => string;
|
|
138
|
+
export {};
|
|
139
|
+
}
|