@duplojs/utils 1.2.17 → 1.2.19
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/chunk.cjs +16 -0
- package/dist/array/chunk.d.ts +2 -0
- package/dist/array/chunk.mjs +14 -0
- package/dist/array/every.cjs +6 -3
- package/dist/array/every.d.ts +4 -3
- package/dist/array/every.mjs +6 -3
- package/dist/array/fill/all.d.ts +2 -2
- package/dist/array/filter.cjs +6 -3
- package/dist/array/filter.d.ts +6 -5
- package/dist/array/filter.mjs +6 -3
- package/dist/array/flatMap.cjs +6 -3
- package/dist/array/flatMap.d.ts +4 -3
- package/dist/array/flatMap.mjs +6 -3
- package/dist/array/index.cjs +13 -10
- package/dist/array/index.d.ts +3 -0
- package/dist/array/index.mjs +5 -4
- package/dist/array/insert.cjs +12 -0
- package/dist/array/insert.d.ts +2 -0
- package/dist/array/insert.mjs +10 -0
- package/dist/array/isLastIndex.cjs +12 -0
- package/dist/array/isLastIndex.d.ts +2 -0
- package/dist/array/isLastIndex.mjs +10 -0
- package/dist/array/map.cjs +6 -3
- package/dist/array/map.d.ts +4 -3
- package/dist/array/map.mjs +6 -3
- package/dist/array/push.cjs +3 -3
- package/dist/array/push.d.ts +2 -2
- package/dist/array/push.mjs +3 -3
- package/dist/array/reduce.cjs +22 -9
- package/dist/array/reduce.d.ts +7 -4
- package/dist/array/reduce.mjs +22 -10
- package/dist/array/reduceRight.cjs +7 -10
- package/dist/array/reduceRight.d.ts +2 -2
- package/dist/array/reduceRight.mjs +7 -10
- package/dist/array/some.cjs +6 -3
- package/dist/array/some.d.ts +4 -3
- package/dist/array/some.mjs +6 -3
- package/dist/array/types/ArrayCoalescing.d.ts +1 -1
- package/dist/clean/constraint/base.cjs +77 -0
- package/dist/clean/constraint/base.d.ts +36 -0
- package/dist/clean/constraint/base.mjs +72 -0
- package/dist/{array/sort → clean/constraint/defaultConstraint}/index.d.ts +0 -1
- package/dist/clean/constraint/defaultConstraint/number.cjs +15 -0
- package/dist/clean/constraint/defaultConstraint/number.d.ts +8 -0
- package/dist/clean/constraint/defaultConstraint/number.mjs +11 -0
- package/dist/clean/constraint/defaultConstraint/string.cjs +12 -0
- package/dist/clean/constraint/defaultConstraint/string.d.ts +6 -0
- package/dist/clean/constraint/defaultConstraint/string.mjs +9 -0
- package/dist/clean/constraint/index.d.ts +2 -0
- package/dist/clean/entity.cjs +125 -0
- package/dist/clean/entity.d.ts +74 -0
- package/dist/clean/entity.mjs +121 -0
- package/dist/clean/flag.cjs +26 -0
- package/dist/clean/flag.d.ts +16 -0
- package/dist/clean/flag.mjs +23 -0
- package/dist/clean/index.cjs +84 -0
- package/dist/clean/index.d.ts +8 -0
- package/dist/clean/index.mjs +29 -0
- package/dist/clean/kind.cjs +9 -0
- package/dist/clean/kind.d.ts +1 -0
- package/dist/clean/kind.mjs +7 -0
- package/dist/clean/newType.cjs +91 -0
- package/dist/clean/newType.d.ts +38 -0
- package/dist/clean/newType.mjs +86 -0
- package/dist/clean/primitive/base.cjs +72 -0
- package/dist/clean/primitive/base.d.ts +36 -0
- package/dist/clean/primitive/base.mjs +64 -0
- package/dist/clean/primitive/index.d.ts +2 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateGreaterThan.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateLessThan.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateLessThan.d.ts +4 -0
- package/dist/clean/primitive/operations/date/dateLessThan.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateMax.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateMax.d.ts +5 -0
- package/dist/clean/primitive/operations/date/dateMax.mjs +13 -0
- package/dist/clean/primitive/operations/date/dateMin.cjs +15 -0
- package/dist/clean/primitive/operations/date/dateMin.d.ts +5 -0
- package/dist/clean/primitive/operations/date/dateMin.mjs +13 -0
- package/dist/clean/primitive/operations/date/index.d.ts +8 -0
- package/dist/clean/primitive/operations/equal.cjs +14 -0
- package/dist/clean/primitive/operations/equal.d.ts +4 -0
- package/dist/clean/primitive/operations/equal.mjs +12 -0
- package/dist/clean/primitive/operations/index.d.ts +5 -0
- package/dist/clean/primitive/operations/number/add.cjs +15 -0
- package/dist/clean/primitive/operations/number/add.d.ts +3 -0
- package/dist/clean/primitive/operations/number/add.mjs +13 -0
- package/dist/clean/primitive/operations/number/divide.cjs +15 -0
- package/dist/clean/primitive/operations/number/divide.d.ts +3 -0
- package/dist/clean/primitive/operations/number/divide.mjs +13 -0
- package/dist/clean/primitive/operations/number/greaterThan.cjs +14 -0
- package/dist/clean/primitive/operations/number/greaterThan.d.ts +3 -0
- package/dist/clean/primitive/operations/number/greaterThan.mjs +12 -0
- package/dist/clean/primitive/operations/number/index.d.ts +8 -0
- package/dist/clean/primitive/operations/number/lessThan.cjs +14 -0
- package/dist/clean/primitive/operations/number/lessThan.d.ts +3 -0
- package/dist/clean/primitive/operations/number/lessThan.mjs +12 -0
- package/dist/clean/primitive/operations/number/max.cjs +10 -0
- package/dist/clean/primitive/operations/number/max.d.ts +3 -0
- package/dist/clean/primitive/operations/number/max.mjs +8 -0
- package/dist/clean/primitive/operations/number/min.cjs +10 -0
- package/dist/clean/primitive/operations/number/min.d.ts +3 -0
- package/dist/clean/primitive/operations/number/min.mjs +8 -0
- package/dist/clean/primitive/operations/number/multiply.cjs +15 -0
- package/dist/clean/primitive/operations/number/multiply.d.ts +3 -0
- package/dist/clean/primitive/operations/number/multiply.mjs +13 -0
- package/dist/clean/primitive/operations/number/subtract.cjs +15 -0
- package/dist/clean/primitive/operations/number/subtract.d.ts +3 -0
- package/dist/clean/primitive/operations/number/subtract.mjs +13 -0
- package/dist/clean/primitive/operations/sort.cjs +35 -0
- package/dist/clean/primitive/operations/sort.d.ts +9 -0
- package/dist/clean/primitive/operations/sort.mjs +33 -0
- package/dist/clean/primitive/operations/string/concat.cjs +16 -0
- package/dist/clean/primitive/operations/string/concat.d.ts +3 -0
- package/dist/clean/primitive/operations/string/concat.mjs +14 -0
- package/dist/clean/primitive/operations/string/index.d.ts +5 -0
- package/dist/clean/primitive/operations/string/length.cjs +10 -0
- package/dist/clean/primitive/operations/string/length.d.ts +2 -0
- package/dist/clean/primitive/operations/string/length.mjs +8 -0
- package/dist/clean/primitive/operations/string/lengthEqual.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthEqual.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthEqual.mjs +12 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthGreaterThan.mjs +12 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.cjs +14 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.d.ts +3 -0
- package/dist/clean/primitive/operations/string/lengthLessThan.mjs +12 -0
- package/dist/clean/repository.cjs +15 -0
- package/dist/clean/repository.d.ts +8 -0
- package/dist/clean/repository.mjs +12 -0
- package/dist/clean/useCase.cjs +25 -0
- package/dist/clean/useCase.d.ts +23 -0
- package/dist/clean/useCase.mjs +21 -0
- package/dist/common/index.d.ts +0 -1
- package/dist/common/kind.d.ts +1 -0
- package/dist/common/types/index.d.ts +1 -0
- package/dist/common/types/sortType.d.ts +1 -0
- package/dist/common/unwrap.d.ts +1 -2
- package/dist/dataParser/base.d.ts +5 -4
- package/dist/dataParser/baseExtended.d.ts +4 -4
- package/dist/dataParser/extended/array.d.ts +3 -3
- package/dist/dataParser/extended/bigint.d.ts +2 -2
- package/dist/dataParser/extended/boolean.d.ts +2 -2
- package/dist/dataParser/extended/date.d.ts +3 -2
- package/dist/dataParser/extended/empty.d.ts +2 -2
- package/dist/dataParser/extended/lazy.d.ts +3 -3
- package/dist/dataParser/extended/literal.d.ts +2 -2
- package/dist/dataParser/extended/nil.d.ts +2 -2
- package/dist/dataParser/extended/nullable.d.ts +3 -3
- package/dist/dataParser/extended/number.cjs +3 -0
- package/dist/dataParser/extended/number.d.ts +5 -2
- package/dist/dataParser/extended/number.mjs +3 -0
- package/dist/dataParser/extended/object.cjs +8 -13
- package/dist/dataParser/extended/object.d.ts +4 -2
- package/dist/dataParser/extended/object.mjs +8 -13
- package/dist/dataParser/extended/optional.d.ts +3 -3
- package/dist/dataParser/extended/pipe.d.ts +3 -3
- package/dist/dataParser/extended/record.d.ts +3 -3
- package/dist/dataParser/extended/recover.d.ts +3 -3
- package/dist/dataParser/extended/string.d.ts +2 -2
- package/dist/dataParser/extended/templateLiteral.d.ts +2 -2
- package/dist/dataParser/extended/transform.d.ts +3 -3
- package/dist/dataParser/extended/tuple.d.ts +3 -3
- package/dist/dataParser/extended/union.d.ts +3 -3
- package/dist/dataParser/extended/unknown.d.ts +2 -2
- package/dist/dataParser/identifier.d.ts +10 -160
- package/dist/dataParser/index.cjs +4 -0
- package/dist/dataParser/index.mjs +2 -0
- package/dist/dataParser/parsers/array/index.cjs +2 -2
- package/dist/dataParser/parsers/array/index.mjs +2 -2
- package/dist/dataParser/parsers/literal.d.ts +1 -1
- package/dist/dataParser/parsers/object/index.cjs +3 -3
- package/dist/dataParser/parsers/object/index.d.ts +2 -0
- package/dist/dataParser/parsers/object/index.mjs +3 -3
- package/dist/dataParser/parsers/object/partial.cjs +20 -0
- package/dist/dataParser/parsers/object/partial.d.ts +14 -0
- package/dist/dataParser/parsers/object/partial.mjs +18 -0
- package/dist/dataParser/parsers/object/required.cjs +20 -0
- package/dist/dataParser/parsers/object/required.d.ts +10 -0
- package/dist/dataParser/parsers/object/required.mjs +18 -0
- package/dist/dataParser/parsers/record/index.cjs +2 -2
- package/dist/dataParser/parsers/record/index.mjs +2 -2
- package/dist/dataParser/parsers/refine.d.ts +1 -1
- package/dist/dataParser/parsers/tuple.cjs +2 -2
- package/dist/dataParser/parsers/tuple.mjs +2 -2
- package/dist/date/index.cjs +8 -0
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.mjs +4 -0
- package/dist/date/is.cjs +9 -0
- package/dist/date/is.d.ts +2 -0
- package/dist/date/is.mjs +7 -0
- package/dist/date/max.cjs +10 -0
- package/dist/date/max.d.ts +3 -0
- package/dist/date/max.mjs +8 -0
- package/dist/date/min.cjs +10 -0
- package/dist/date/min.d.ts +3 -0
- package/dist/date/min.mjs +8 -0
- package/dist/date/sort.cjs +20 -0
- package/dist/date/sort.d.ts +4 -0
- package/dist/date/sort.mjs +18 -0
- package/dist/generator/chunk.cjs +24 -0
- package/dist/generator/chunk.d.ts +2 -0
- package/dist/generator/chunk.mjs +22 -0
- package/dist/generator/index.cjs +2 -0
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.mjs +1 -0
- package/dist/generator/reduce.cjs +2 -6
- package/dist/generator/reduce.d.ts +1 -0
- package/dist/generator/reduce.mjs +2 -6
- package/dist/index.cjs +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +3 -1
- package/dist/number/index.cjs +2 -0
- package/dist/number/index.d.ts +1 -0
- package/dist/number/index.mjs +1 -0
- package/dist/number/max.cjs +2 -7
- package/dist/number/max.d.ts +2 -2
- package/dist/number/max.mjs +2 -7
- package/dist/number/min.cjs +2 -7
- package/dist/number/min.d.ts +2 -2
- package/dist/number/min.mjs +2 -7
- package/dist/number/sort.cjs +14 -0
- package/dist/number/sort.d.ts +3 -0
- package/dist/number/sort.mjs +12 -0
- package/dist/pattern/match/index.d.ts +3 -3
- package/dist/pattern/when.d.ts +5 -5
- package/dist/string/index.cjs +2 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.mjs +1 -0
- package/dist/{array/sort/string.cjs → string/sort.cjs} +6 -6
- package/dist/string/sort.d.ts +3 -0
- package/dist/{array/sort/string.mjs → string/sort.mjs} +6 -6
- package/package.json +7 -2
- package/dist/array/sort/number.cjs +0 -14
- package/dist/array/sort/number.d.ts +0 -4
- package/dist/array/sort/number.mjs +0 -12
- package/dist/array/sort/string.d.ts +0 -4
- package/dist/common/not.cjs +0 -12
- package/dist/common/not.d.ts +0 -2
- package/dist/common/not.mjs +0 -10
- /package/dist/array/{sort/default.cjs → sort.cjs} +0 -0
- /package/dist/array/{sort/default.d.ts → sort.d.ts} +0 -0
- /package/dist/array/{sort/default.mjs → sort.mjs} +0 -0
|
@@ -2,11 +2,11 @@ import { dataParserInit, SymbolDataParserError, dataParserKind } from '../../bas
|
|
|
2
2
|
import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../kind.mjs';
|
|
4
4
|
import { memo } from '../../../common/memo.mjs';
|
|
5
|
-
import { forward } from '../../../common/forward.mjs';
|
|
6
5
|
import { pipe } from '../../../common/pipe.mjs';
|
|
7
6
|
import { map } from '../../../array/map.mjs';
|
|
8
7
|
import { filter } from '../../../array/filter.mjs';
|
|
9
8
|
import { entries } from '../../../object/entries.mjs';
|
|
9
|
+
import { forward } from '../../../common/forward.mjs';
|
|
10
10
|
import { createOverride } from '../../../common/override.mjs';
|
|
11
11
|
|
|
12
12
|
const objectKind = createDataParserKind("object");
|
|
@@ -41,7 +41,7 @@ function object(shape, definition) {
|
|
|
41
41
|
output[entry.key] = result;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
popErrorPath(error);
|
|
44
|
+
void (self.definition.optimizedShape.value.length && popErrorPath(error));
|
|
45
45
|
return output;
|
|
46
46
|
},
|
|
47
47
|
async: async (data, error, self) => {
|
|
@@ -63,7 +63,7 @@ function object(shape, definition) {
|
|
|
63
63
|
output[entry.key] = result;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
popErrorPath(error);
|
|
66
|
+
void (self.definition.optimizedShape.value.length && popErrorPath(error));
|
|
67
67
|
return output;
|
|
68
68
|
},
|
|
69
69
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index.cjs');
|
|
4
|
+
var optional = require('../optional.cjs');
|
|
5
|
+
var identifier = require('../../identifier.cjs');
|
|
6
|
+
var forward = require('../../../common/forward.cjs');
|
|
7
|
+
var pipe = require('../../../common/pipe.cjs');
|
|
8
|
+
var map = require('../../../array/map.cjs');
|
|
9
|
+
var when = require('../../../either/right/when.cjs');
|
|
10
|
+
var when$1 = require('../../../either/left/when.cjs');
|
|
11
|
+
var entry = require('../../../object/entry.cjs');
|
|
12
|
+
var entries = require('../../../object/entries.cjs');
|
|
13
|
+
var fromEntries = require('../../../object/fromEntries.cjs');
|
|
14
|
+
|
|
15
|
+
function partial(dataParser, definition) {
|
|
16
|
+
const newShape = pipe.pipe(dataParser.definition.shape, entries.entries, map.map(([key, dataParser]) => pipe.pipe(identifier.identifier(dataParser, optional.optionalKind), when.whenIsRight(forward.forward), when$1.whenIsLeft(optional.optional), (dataParser) => entry.entry(key, dataParser))), fromEntries.fromEntries);
|
|
17
|
+
return index.object(newShape, definition);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.partial = partial;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MergeDefinition } from "../../../dataParser/types";
|
|
2
|
+
import { type DataParserObjectShape, type DataParserDefinitionObject, type DataParserObject } from ".";
|
|
3
|
+
import { type NeverCoalescing, type SimplifyTopLevel } from "../../../common";
|
|
4
|
+
import { type DataParserOptionalCheckers, type DataParserOptional } from "../optional";
|
|
5
|
+
export type PartialDataParserObject<GenericShape extends DataParserObjectShape> = SimplifyTopLevel<{
|
|
6
|
+
[Prop in keyof GenericShape]: GenericShape[Prop] extends DataParserOptional<any> ? GenericShape[Prop] : DataParserOptional<{
|
|
7
|
+
inner: GenericShape[Prop];
|
|
8
|
+
checkers: DataParserOptionalCheckers[];
|
|
9
|
+
coalescingValue: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function partial<GenericDataParserObject extends DataParserObject, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
|
|
13
|
+
readonly shape: PartialDataParserObject<GenericDataParserObject["definition"]["shape"]>;
|
|
14
|
+
}>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { object } from './index.mjs';
|
|
2
|
+
import { optionalKind, optional } from '../optional.mjs';
|
|
3
|
+
import { identifier } from '../../identifier.mjs';
|
|
4
|
+
import { forward } from '../../../common/forward.mjs';
|
|
5
|
+
import { pipe } from '../../../common/pipe.mjs';
|
|
6
|
+
import { map } from '../../../array/map.mjs';
|
|
7
|
+
import { whenIsRight } from '../../../either/right/when.mjs';
|
|
8
|
+
import { whenIsLeft } from '../../../either/left/when.mjs';
|
|
9
|
+
import { entry } from '../../../object/entry.mjs';
|
|
10
|
+
import { entries } from '../../../object/entries.mjs';
|
|
11
|
+
import { fromEntries } from '../../../object/fromEntries.mjs';
|
|
12
|
+
|
|
13
|
+
function partial(dataParser, definition) {
|
|
14
|
+
const newShape = pipe(dataParser.definition.shape, entries, map(([key, dataParser]) => pipe(identifier(dataParser, optionalKind), whenIsRight(forward), whenIsLeft(optional), (dataParser) => entry(key, dataParser))), fromEntries);
|
|
15
|
+
return object(newShape, definition);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { partial };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index.cjs');
|
|
4
|
+
var optional = require('../optional.cjs');
|
|
5
|
+
var identifier = require('../../identifier.cjs');
|
|
6
|
+
var pipe = require('../../../common/pipe.cjs');
|
|
7
|
+
var map = require('../../../array/map.cjs');
|
|
8
|
+
var when = require('../../../either/right/when.cjs');
|
|
9
|
+
var when$1 = require('../../../either/left/when.cjs');
|
|
10
|
+
var forward = require('../../../common/forward.cjs');
|
|
11
|
+
var entry = require('../../../object/entry.cjs');
|
|
12
|
+
var entries = require('../../../object/entries.cjs');
|
|
13
|
+
var fromEntries = require('../../../object/fromEntries.cjs');
|
|
14
|
+
|
|
15
|
+
function required(dataParser, definition) {
|
|
16
|
+
const newShape = pipe.pipe(dataParser.definition.shape, entries.entries, map.map(([key, dataParser]) => pipe.pipe(identifier.identifier(dataParser, optional.optionalKind), when.whenIsRight((dataParser) => dataParser.definition.inner), when$1.whenIsLeft(forward.forward), (dataParser) => entry.entry(key, dataParser))), fromEntries.fromEntries);
|
|
17
|
+
return index.object(newShape, definition);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.required = required;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MergeDefinition } from "../../../dataParser/types";
|
|
2
|
+
import { type DataParserObjectShape, type DataParserDefinitionObject, type DataParserObject } from ".";
|
|
3
|
+
import { type NeverCoalescing, type SimplifyTopLevel } from "../../../common";
|
|
4
|
+
import { type DataParserOptional } from "../optional";
|
|
5
|
+
export type RequireDataParserObject<GenericShape extends DataParserObjectShape> = SimplifyTopLevel<{
|
|
6
|
+
[Prop in keyof GenericShape]: GenericShape[Prop] extends DataParserOptional<any> ? GenericShape[Prop]["definition"]["inner"] : GenericShape[Prop];
|
|
7
|
+
}>;
|
|
8
|
+
export declare function required<GenericDataParserObject extends DataParserObject, const GenericDefinition extends Partial<Omit<DataParserDefinitionObject, "shape" | "optimizedShape">> = never>(dataParser: GenericDataParserObject, definition?: GenericDefinition): DataParserObject<MergeDefinition<DataParserDefinitionObject, NeverCoalescing<GenericDefinition, {}> & {
|
|
9
|
+
readonly shape: RequireDataParserObject<GenericDataParserObject["definition"]["shape"]>;
|
|
10
|
+
}>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { object } from './index.mjs';
|
|
2
|
+
import { optionalKind } from '../optional.mjs';
|
|
3
|
+
import { identifier } from '../../identifier.mjs';
|
|
4
|
+
import { pipe } from '../../../common/pipe.mjs';
|
|
5
|
+
import { map } from '../../../array/map.mjs';
|
|
6
|
+
import { whenIsRight } from '../../../either/right/when.mjs';
|
|
7
|
+
import { whenIsLeft } from '../../../either/left/when.mjs';
|
|
8
|
+
import { forward } from '../../../common/forward.mjs';
|
|
9
|
+
import { entry } from '../../../object/entry.mjs';
|
|
10
|
+
import { entries } from '../../../object/entries.mjs';
|
|
11
|
+
import { fromEntries } from '../../../object/fromEntries.mjs';
|
|
12
|
+
|
|
13
|
+
function required(dataParser, definition) {
|
|
14
|
+
const newShape = pipe(dataParser.definition.shape, entries, map(([key, dataParser]) => pipe(identifier(dataParser, optionalKind), whenIsRight((dataParser) => dataParser.definition.inner), whenIsLeft(forward), (dataParser) => entry(key, dataParser))), fromEntries);
|
|
15
|
+
return object(newShape, definition);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { required };
|
|
@@ -45,7 +45,7 @@ function record(key, value, definition) {
|
|
|
45
45
|
output[resultKey] = resultValue;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
error.popErrorPath(error$1);
|
|
48
|
+
void (currentIndexPath !== error$1.currentPath.length && error.popErrorPath(error$1));
|
|
49
49
|
if (output === base.SymbolDataParserError) {
|
|
50
50
|
return output;
|
|
51
51
|
}
|
|
@@ -83,7 +83,7 @@ function record(key, value, definition) {
|
|
|
83
83
|
output[resultKey] = resultValue;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
error.popErrorPath(error$1);
|
|
86
|
+
void (currentIndexPath !== error$1.currentPath.length && error.popErrorPath(error$1));
|
|
87
87
|
if (output === base.SymbolDataParserError) {
|
|
88
88
|
return output;
|
|
89
89
|
}
|
|
@@ -44,7 +44,7 @@ function record(key, value, definition) {
|
|
|
44
44
|
output[resultKey] = resultValue;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
popErrorPath(error);
|
|
47
|
+
void (currentIndexPath !== error.currentPath.length && popErrorPath(error));
|
|
48
48
|
if (output === SymbolDataParserError) {
|
|
49
49
|
return output;
|
|
50
50
|
}
|
|
@@ -82,7 +82,7 @@ function record(key, value, definition) {
|
|
|
82
82
|
output[resultKey] = resultValue;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
popErrorPath(error);
|
|
85
|
+
void (currentIndexPath !== error.currentPath.length && popErrorPath(error));
|
|
86
86
|
if (output === SymbolDataParserError) {
|
|
87
87
|
return output;
|
|
88
88
|
}
|
|
@@ -8,7 +8,7 @@ export declare const dataParserCheckerRefineKind: import("../../common").KindHan
|
|
|
8
8
|
type _DataParserCheckerRefine<GenericDefinition extends DataParserCheckerDefinitionRefine> = (Kind<typeof dataParserCheckerRefineKind.definition> & DataParserChecker<GenericDefinition, string>);
|
|
9
9
|
export interface DataParserCheckerRefine<GenericDefinition extends DataParserCheckerDefinitionRefine = DataParserCheckerDefinitionRefine> extends _DataParserCheckerRefine<GenericDefinition> {
|
|
10
10
|
}
|
|
11
|
-
export declare function checkerRefine<GenericInput extends unknown, const GenericDefinition extends Partial<Omit<DataParserCheckerDefinitionRefine, "theFunction">> = never>(theFunction: (input: GenericInput) => boolean, definition?: GenericDefinition): DataParserCheckerRefine<AssignObjects<NeverCoalescing<GenericDefinition,
|
|
11
|
+
export declare function checkerRefine<GenericInput extends unknown, const GenericDefinition extends Partial<Omit<DataParserCheckerDefinitionRefine, "theFunction">> = never>(theFunction: (input: GenericInput) => boolean, definition?: GenericDefinition): DataParserCheckerRefine<AssignObjects<NeverCoalescing<GenericDefinition, DataParserCheckerDefinitionRefine>, {
|
|
12
12
|
theFunction(input: GenericInput): boolean;
|
|
13
13
|
}>>;
|
|
14
14
|
export type CheckerRefineImplementation<GenericInput extends unknown> = DataParserCheckerRefine<AssignObjects<DataParserCheckerDefinitionRefine, {
|
|
@@ -43,7 +43,7 @@ function tuple(shape, definition) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
error.popErrorPath(error$1);
|
|
46
|
+
void (self.definition.shape.length && error.popErrorPath(error$1));
|
|
47
47
|
return output;
|
|
48
48
|
},
|
|
49
49
|
async: async (data, error$1, self) => {
|
|
@@ -74,7 +74,7 @@ function tuple(shape, definition) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
error.popErrorPath(error$1);
|
|
77
|
+
void (self.definition.shape.length && error.popErrorPath(error$1));
|
|
78
78
|
return output;
|
|
79
79
|
},
|
|
80
80
|
});
|
|
@@ -41,7 +41,7 @@ function tuple(shape, definition) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
popErrorPath(error);
|
|
44
|
+
void (self.definition.shape.length && popErrorPath(error));
|
|
45
45
|
return output;
|
|
46
46
|
},
|
|
47
47
|
async: async (data, error, self) => {
|
|
@@ -72,7 +72,7 @@ function tuple(shape, definition) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
popErrorPath(error);
|
|
75
|
+
void (self.definition.shape.length && popErrorPath(error));
|
|
76
76
|
return output;
|
|
77
77
|
},
|
|
78
78
|
});
|
package/dist/date/index.cjs
CHANGED
|
@@ -14,6 +14,10 @@ var each = require('./each.cjs');
|
|
|
14
14
|
var createOrThrow = require('./createOrThrow.cjs');
|
|
15
15
|
var round = require('./round.cjs');
|
|
16
16
|
var isSafeTimestamp = require('./isSafeTimestamp.cjs');
|
|
17
|
+
var min = require('./min.cjs');
|
|
18
|
+
var max = require('./max.cjs');
|
|
19
|
+
var sort = require('./sort.cjs');
|
|
20
|
+
var is = require('./is.cjs');
|
|
17
21
|
var timezone = require('./types/timezone.cjs');
|
|
18
22
|
var getDayOfMonth = require('./getters/getDayOfMonth.cjs');
|
|
19
23
|
var getDayOfWeek = require('./getters/getDayOfWeek.cjs');
|
|
@@ -82,6 +86,10 @@ exports.CreateTheDateError = createOrThrow.CreateTheDateError;
|
|
|
82
86
|
exports.createOrThrow = createOrThrow.createOrThrow;
|
|
83
87
|
exports.round = round.round;
|
|
84
88
|
exports.isSafeTimestamp = isSafeTimestamp.isSafeTimestamp;
|
|
89
|
+
exports.min = min.min;
|
|
90
|
+
exports.max = max.max;
|
|
91
|
+
exports.sort = sort.sort;
|
|
92
|
+
exports.is = is.is;
|
|
85
93
|
exports.timezone = timezone.timezone;
|
|
86
94
|
exports.getDayOfMonth = getDayOfMonth.getDayOfMonth;
|
|
87
95
|
exports.getDayOfWeek = getDayOfWeek.getDayOfWeek;
|
package/dist/date/index.d.ts
CHANGED
package/dist/date/index.mjs
CHANGED
|
@@ -12,6 +12,10 @@ export { each } from './each.mjs';
|
|
|
12
12
|
export { CreateTheDateError, createOrThrow } from './createOrThrow.mjs';
|
|
13
13
|
export { round } from './round.mjs';
|
|
14
14
|
export { isSafeTimestamp } from './isSafeTimestamp.mjs';
|
|
15
|
+
export { min } from './min.mjs';
|
|
16
|
+
export { max } from './max.mjs';
|
|
17
|
+
export { sort } from './sort.mjs';
|
|
18
|
+
export { is } from './is.mjs';
|
|
15
19
|
export { timezone } from './types/timezone.mjs';
|
|
16
20
|
export { getDayOfMonth } from './getters/getDayOfMonth.mjs';
|
|
17
21
|
export { getDayOfWeek } from './getters/getDayOfWeek.mjs';
|
package/dist/date/is.cjs
ADDED
package/dist/date/is.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var createOrThrow = require('./createOrThrow.cjs');
|
|
4
|
+
var toTimestamp = require('./toTimestamp.cjs');
|
|
5
|
+
|
|
6
|
+
function sort(...args) {
|
|
7
|
+
if (args.length === 1) {
|
|
8
|
+
const [type] = args;
|
|
9
|
+
return (array) => sort(array, type);
|
|
10
|
+
}
|
|
11
|
+
const [array, type] = args;
|
|
12
|
+
return array
|
|
13
|
+
.map(toTimestamp.toTimestamp)
|
|
14
|
+
.sort(type === "DSC"
|
|
15
|
+
? (first, second) => second - first
|
|
16
|
+
: (first, second) => first - second)
|
|
17
|
+
.map(createOrThrow.createOrThrow);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.sort = sort;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SortType } from "../common";
|
|
2
|
+
import { type TheDate } from "./types";
|
|
3
|
+
export declare function sort<GenericArray extends readonly TheDate[]>(type: SortType): (array: GenericArray) => TheDate[];
|
|
4
|
+
export declare function sort<GenericArray extends readonly TheDate[]>(array: GenericArray, type: SortType): TheDate[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createOrThrow } from './createOrThrow.mjs';
|
|
2
|
+
import { toTimestamp } from './toTimestamp.mjs';
|
|
3
|
+
|
|
4
|
+
function sort(...args) {
|
|
5
|
+
if (args.length === 1) {
|
|
6
|
+
const [type] = args;
|
|
7
|
+
return (array) => sort(array, type);
|
|
8
|
+
}
|
|
9
|
+
const [array, type] = args;
|
|
10
|
+
return array
|
|
11
|
+
.map(toTimestamp)
|
|
12
|
+
.sort(type === "DSC"
|
|
13
|
+
? (first, second) => second - first
|
|
14
|
+
: (first, second) => first - second)
|
|
15
|
+
.map(createOrThrow);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { sort };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function chunk(...args) {
|
|
4
|
+
if (args.length === 1) {
|
|
5
|
+
const [size] = args;
|
|
6
|
+
return (input) => chunk(input, size);
|
|
7
|
+
}
|
|
8
|
+
const [input, size] = args;
|
|
9
|
+
return (function* () {
|
|
10
|
+
let buffer = [];
|
|
11
|
+
for (const element of input) {
|
|
12
|
+
buffer.push(element);
|
|
13
|
+
if (buffer.length === size) {
|
|
14
|
+
yield buffer;
|
|
15
|
+
buffer = [];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (buffer.length > 0) {
|
|
19
|
+
yield buffer;
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.chunk = chunk;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function chunk<const GenericElement extends unknown>(size: number): (input: Iterable<GenericElement>) => Generator<GenericElement[], unknown, unknown>;
|
|
2
|
+
export declare function chunk<const GenericElement extends unknown>(input: Iterable<GenericElement>, size: number): Generator<GenericElement[], unknown, unknown>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function chunk(...args) {
|
|
2
|
+
if (args.length === 1) {
|
|
3
|
+
const [size] = args;
|
|
4
|
+
return (input) => chunk(input, size);
|
|
5
|
+
}
|
|
6
|
+
const [input, size] = args;
|
|
7
|
+
return (function* () {
|
|
8
|
+
let buffer = [];
|
|
9
|
+
for (const element of input) {
|
|
10
|
+
buffer.push(element);
|
|
11
|
+
if (buffer.length === size) {
|
|
12
|
+
yield buffer;
|
|
13
|
+
buffer = [];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (buffer.length > 0) {
|
|
17
|
+
yield buffer;
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { chunk };
|
package/dist/generator/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var reduce = require('./reduce.cjs');
|
|
|
9
9
|
var asyncReduce = require('./asyncReduce.cjs');
|
|
10
10
|
var loop = require('./loop.cjs');
|
|
11
11
|
var asyncLoop = require('./asyncLoop.cjs');
|
|
12
|
+
var chunk = require('./chunk.cjs');
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
@@ -22,3 +23,4 @@ exports.reduceFrom = reduce.reduceFrom;
|
|
|
22
23
|
exports.asyncReduce = asyncReduce.asyncReduce;
|
|
23
24
|
exports.loop = loop.loop;
|
|
24
25
|
exports.asyncLoop = asyncLoop.asyncLoop;
|
|
26
|
+
exports.chunk = chunk.chunk;
|
package/dist/generator/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var kind = require('../common/kind.cjs');
|
|
4
4
|
var wrapValue = require('../common/wrapValue.cjs');
|
|
5
5
|
var unwrap = require('../common/unwrap.cjs');
|
|
6
|
-
var
|
|
6
|
+
var reduce$1 = require('../array/reduce.cjs');
|
|
7
7
|
|
|
8
8
|
const generatorReduceFromKind = kind.createKind("generator-reduce-from");
|
|
9
9
|
function reduceFrom(value) {
|
|
@@ -22,11 +22,7 @@ function reduce(...args) {
|
|
|
22
22
|
element,
|
|
23
23
|
index,
|
|
24
24
|
lastValue,
|
|
25
|
-
|
|
26
|
-
"-next": override.override(object1, object2),
|
|
27
|
-
})),
|
|
28
|
-
exit: (output) => ({ "-exit": output }),
|
|
29
|
-
next: (output) => ({ "-next": output }),
|
|
25
|
+
...reduce$1.reduceTools,
|
|
30
26
|
});
|
|
31
27
|
if ("-exit" in result) {
|
|
32
28
|
return result["-exit"];
|
|
@@ -15,6 +15,7 @@ export interface GeneratorReduceFunctionParams<GenericElement extends unknown =
|
|
|
15
15
|
nextWithObject: GenericOutput extends object ? (object1: GenericOutput, object2: Partial<GenericOutput>) => GeneratorReduceNext<GenericOutput> : undefined;
|
|
16
16
|
next(output: GenericOutput): GeneratorReduceNext<GenericOutput>;
|
|
17
17
|
exit<GenericExitValue extends unknown>(output: GenericExitValue): GeneratorReduceExit<GenericExitValue>;
|
|
18
|
+
nextPush: GenericOutput extends readonly any[] ? (array: GenericOutput, ...values: GenericOutput) => GeneratorReduceExit<GenericOutput> : undefined;
|
|
18
19
|
}
|
|
19
20
|
declare const generatorReduceFromKind: import("../common").KindHandler<import("../common").KindDefinition<"generator-reduce-from", unknown>>;
|
|
20
21
|
export interface GeneratorReduceFromResult<GenericValue extends unknown = unknown> extends Kind<typeof generatorReduceFromKind.definition>, WrappedValue<GenericValue> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createKind } from '../common/kind.mjs';
|
|
2
2
|
import { wrapValue } from '../common/wrapValue.mjs';
|
|
3
3
|
import { unwrap } from '../common/unwrap.mjs';
|
|
4
|
-
import {
|
|
4
|
+
import { reduceTools } from '../array/reduce.mjs';
|
|
5
5
|
|
|
6
6
|
const generatorReduceFromKind = createKind("generator-reduce-from");
|
|
7
7
|
function reduceFrom(value) {
|
|
@@ -20,11 +20,7 @@ function reduce(...args) {
|
|
|
20
20
|
element,
|
|
21
21
|
index,
|
|
22
22
|
lastValue,
|
|
23
|
-
|
|
24
|
-
"-next": override(object1, object2),
|
|
25
|
-
})),
|
|
26
|
-
exit: (output) => ({ "-exit": output }),
|
|
27
|
-
next: (output) => ({ "-next": output }),
|
|
23
|
+
...reduceTools,
|
|
28
24
|
});
|
|
29
25
|
if ("-exit" in result) {
|
|
30
26
|
return result["-exit"];
|
package/dist/index.cjs
CHANGED
|
@@ -11,6 +11,7 @@ var index$7 = require('./dataParser/index.cjs');
|
|
|
11
11
|
var index$8 = require('./dataParser/parsers/coerce/index.cjs');
|
|
12
12
|
var index$9 = require('./dataParser/extended/index.cjs');
|
|
13
13
|
var index$a = require('./date/index.cjs');
|
|
14
|
+
var index$b = require('./clean/index.cjs');
|
|
14
15
|
var addWrappedProperties = require('./common/addWrappedProperties.cjs');
|
|
15
16
|
var asyncPipe = require('./common/asyncPipe.cjs');
|
|
16
17
|
var clone = require('./common/clone.cjs');
|
|
@@ -40,7 +41,6 @@ var forward = require('./common/forward.cjs');
|
|
|
40
41
|
var when = require('./common/when.cjs');
|
|
41
42
|
var whenNot = require('./common/whenNot.cjs');
|
|
42
43
|
var equal = require('./common/equal.cjs');
|
|
43
|
-
var not = require('./common/not.cjs');
|
|
44
44
|
var isType = require('./common/isType.cjs');
|
|
45
45
|
var and = require('./common/and.cjs');
|
|
46
46
|
var or = require('./common/or.cjs');
|
|
@@ -79,6 +79,8 @@ exports.DDataParserExtended = index$9;
|
|
|
79
79
|
exports.DPE = index$9;
|
|
80
80
|
exports.D = index$a;
|
|
81
81
|
exports.DDate = index$a;
|
|
82
|
+
exports.C = index$b;
|
|
83
|
+
exports.DClean = index$b;
|
|
82
84
|
exports.addWrappedProperties = addWrappedProperties.addWrappedProperties;
|
|
83
85
|
exports.asyncPipe = asyncPipe.asyncPipe;
|
|
84
86
|
exports.clone = clone.clone;
|
|
@@ -118,7 +120,6 @@ exports.forward = forward.forward;
|
|
|
118
120
|
exports.when = when.when;
|
|
119
121
|
exports.whenNot = whenNot.whenNot;
|
|
120
122
|
exports.equal = equal.equal;
|
|
121
|
-
exports.not = not.not;
|
|
122
123
|
exports.isType = isType.isType;
|
|
123
124
|
exports.and = and.and;
|
|
124
125
|
exports.or = or.or;
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -31,6 +31,9 @@ export { index$9 as DPE };
|
|
|
31
31
|
import * as index$a from './date/index.mjs';
|
|
32
32
|
export { index$a as D };
|
|
33
33
|
export { index$a as DDate };
|
|
34
|
+
import * as index$b from './clean/index.mjs';
|
|
35
|
+
export { index$b as C };
|
|
36
|
+
export { index$b as DClean };
|
|
34
37
|
export { addWrappedProperties } from './common/addWrappedProperties.mjs';
|
|
35
38
|
export { asyncPipe } from './common/asyncPipe.mjs';
|
|
36
39
|
export { clone } from './common/clone.mjs';
|
|
@@ -60,7 +63,6 @@ export { forward } from './common/forward.mjs';
|
|
|
60
63
|
export { when } from './common/when.mjs';
|
|
61
64
|
export { whenNot } from './common/whenNot.mjs';
|
|
62
65
|
export { equal } from './common/equal.mjs';
|
|
63
|
-
export { not } from './common/not.mjs';
|
|
64
66
|
export { isType } from './common/isType.mjs';
|
|
65
67
|
export { and } from './common/and.mjs';
|
|
66
68
|
export { or } from './common/or.mjs';
|
package/dist/number/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var toFixed = require('./toFixed.cjs');
|
|
|
30
30
|
var sqrt = require('./sqrt.cjs');
|
|
31
31
|
var between = require('./between.cjs');
|
|
32
32
|
var betweenThan = require('./betweenThan.cjs');
|
|
33
|
+
var sort = require('./sort.cjs');
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
|
|
@@ -63,3 +64,4 @@ exports.toFixed = toFixed.toFixed;
|
|
|
63
64
|
exports.sqrt = sqrt.sqrt;
|
|
64
65
|
exports.between = between.between;
|
|
65
66
|
exports.betweenThan = betweenThan.betweenThan;
|
|
67
|
+
exports.sort = sort.sort;
|
package/dist/number/index.d.ts
CHANGED
package/dist/number/index.mjs
CHANGED
package/dist/number/max.cjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function max(
|
|
4
|
-
|
|
5
|
-
const [comparison] = args;
|
|
6
|
-
return (value) => max(value, comparison);
|
|
7
|
-
}
|
|
8
|
-
const [value, comparison] = args;
|
|
9
|
-
return Math.max(value, comparison);
|
|
3
|
+
function max(input) {
|
|
4
|
+
return Math.max(...input);
|
|
10
5
|
}
|
|
11
6
|
|
|
12
7
|
exports.max = max;
|
package/dist/number/max.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function max<
|
|
1
|
+
import { type AnyTuple } from "../common";
|
|
2
|
+
export declare function max<GenericInput extends AnyTuple<number>>(input: GenericInput): number;
|