@duplojs/utils 1.3.22 → 1.3.24
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/README.md +1 -1
- package/dist/array/join.d.ts +3 -7
- package/dist/array/types/index.d.ts +1 -0
- package/dist/array/types/joinTuple.d.ts +6 -0
- package/dist/clean/index.d.ts +1 -0
- package/dist/clean/newType.d.ts +2 -1
- package/dist/clean/types/dataParserContainTransform.d.ts +6 -0
- package/dist/clean/types/index.d.ts +1 -0
- package/dist/dataParser/base.d.ts +3 -0
- package/dist/dataParser/baseExtended.d.ts +3 -0
- package/dist/dataParser/extended/array.d.ts +3 -0
- package/dist/dataParser/extended/bigint.d.ts +3 -0
- package/dist/dataParser/extended/boolean.d.ts +3 -0
- package/dist/dataParser/extended/date.d.ts +3 -0
- package/dist/dataParser/extended/empty.d.ts +3 -0
- package/dist/dataParser/extended/lazy.d.ts +3 -0
- package/dist/dataParser/extended/literal.d.ts +3 -0
- package/dist/dataParser/extended/nil.d.ts +3 -0
- package/dist/dataParser/extended/nullable.d.ts +3 -0
- package/dist/dataParser/extended/number.d.ts +3 -0
- package/dist/dataParser/extended/object.d.ts +3 -0
- package/dist/dataParser/extended/optional.d.ts +3 -0
- package/dist/dataParser/extended/pipe.d.ts +3 -0
- package/dist/dataParser/extended/record.d.ts +3 -0
- package/dist/dataParser/extended/recover.d.ts +3 -0
- package/dist/dataParser/extended/string.d.ts +3 -0
- package/dist/dataParser/extended/templateLiteral.d.ts +3 -0
- package/dist/dataParser/extended/transform.d.ts +3 -0
- package/dist/dataParser/extended/tuple.d.ts +3 -0
- package/dist/dataParser/extended/union.d.ts +3 -0
- package/dist/dataParser/extended/unknown.d.ts +3 -0
- package/dist/dataParser/parsers/array/index.d.ts +3 -0
- package/dist/dataParser/parsers/bigint/index.d.ts +3 -0
- package/dist/dataParser/parsers/boolean.d.ts +3 -0
- package/dist/dataParser/parsers/date.d.ts +3 -0
- package/dist/dataParser/parsers/empty.d.ts +3 -0
- package/dist/dataParser/parsers/lazy.d.ts +3 -0
- package/dist/dataParser/parsers/literal.d.ts +3 -0
- package/dist/dataParser/parsers/nil.d.ts +3 -0
- package/dist/dataParser/parsers/nullable.d.ts +3 -0
- package/dist/dataParser/parsers/number/index.d.ts +3 -0
- package/dist/dataParser/parsers/object/index.d.ts +3 -0
- package/dist/dataParser/parsers/optional.d.ts +3 -0
- package/dist/dataParser/parsers/pipe.d.ts +3 -0
- package/dist/dataParser/parsers/record/index.d.ts +3 -0
- package/dist/dataParser/parsers/recover.d.ts +3 -0
- package/dist/dataParser/parsers/string/index.d.ts +3 -0
- package/dist/dataParser/parsers/templateLiteral/index.d.ts +3 -0
- package/dist/dataParser/parsers/transform.d.ts +3 -0
- package/dist/dataParser/parsers/tuple.d.ts +3 -0
- package/dist/dataParser/parsers/union.d.ts +3 -0
- package/dist/dataParser/parsers/unknown.d.ts +3 -0
- package/dist/dataParser/types/contain.d.ts +4 -0
- package/dist/dataParser/types/index.d.ts +1 -0
- package/dist/date/create.d.ts +12 -5
- package/dist/date/operators/addDays.cjs +1 -2
- package/dist/date/operators/addDays.d.ts +2 -3
- package/dist/date/operators/addDays.mjs +1 -2
- package/dist/date/operators/addHours.cjs +1 -2
- package/dist/date/operators/addHours.d.ts +2 -3
- package/dist/date/operators/addHours.mjs +1 -2
- package/dist/date/operators/addMilliseconds.cjs +1 -2
- package/dist/date/operators/addMilliseconds.d.ts +2 -3
- package/dist/date/operators/addMilliseconds.mjs +1 -2
- package/dist/date/operators/addMinutes.cjs +1 -2
- package/dist/date/operators/addMinutes.d.ts +2 -3
- package/dist/date/operators/addMinutes.mjs +1 -2
- package/dist/date/operators/addMonths.cjs +1 -2
- package/dist/date/operators/addMonths.d.ts +2 -3
- package/dist/date/operators/addMonths.mjs +1 -2
- package/dist/date/operators/addSeconds.cjs +1 -2
- package/dist/date/operators/addSeconds.d.ts +2 -3
- package/dist/date/operators/addSeconds.mjs +1 -2
- package/dist/date/operators/addWeeks.cjs +1 -2
- package/dist/date/operators/addWeeks.d.ts +2 -3
- package/dist/date/operators/addWeeks.mjs +1 -2
- package/dist/date/operators/addYears.cjs +1 -2
- package/dist/date/operators/addYears.d.ts +2 -3
- package/dist/date/operators/addYears.mjs +1 -2
- package/dist/date/operators/subtractDays.cjs +1 -2
- package/dist/date/operators/subtractDays.d.ts +2 -3
- package/dist/date/operators/subtractDays.mjs +1 -2
- package/dist/date/operators/subtractHours.cjs +1 -2
- package/dist/date/operators/subtractHours.d.ts +2 -3
- package/dist/date/operators/subtractHours.mjs +1 -2
- package/dist/date/operators/subtractMilliseconds.cjs +1 -2
- package/dist/date/operators/subtractMilliseconds.d.ts +2 -3
- package/dist/date/operators/subtractMilliseconds.mjs +1 -2
- package/dist/date/operators/subtractMinutes.cjs +1 -2
- package/dist/date/operators/subtractMinutes.d.ts +2 -3
- package/dist/date/operators/subtractMinutes.mjs +1 -2
- package/dist/date/operators/subtractMonths.cjs +1 -2
- package/dist/date/operators/subtractMonths.d.ts +2 -3
- package/dist/date/operators/subtractMonths.mjs +1 -2
- package/dist/date/operators/subtractSeconds.cjs +1 -2
- package/dist/date/operators/subtractSeconds.d.ts +2 -3
- package/dist/date/operators/subtractSeconds.mjs +1 -2
- package/dist/date/operators/subtractWeeks.cjs +1 -2
- package/dist/date/operators/subtractWeeks.d.ts +2 -3
- package/dist/date/operators/subtractWeeks.mjs +1 -2
- package/dist/date/operators/subtractYears.cjs +1 -2
- package/dist/date/operators/subtractYears.d.ts +2 -3
- package/dist/date/operators/subtractYears.mjs +1 -2
- package/dist/date/types/index.d.ts +1 -0
- package/dist/date/types/isLeapYear.d.ts +3 -3
- package/dist/date/types/isSafeYear.d.ts +53 -0
- package/dist/metadata.json +27 -1
- package/dist/number/types/absolute.d.ts +5 -0
- package/dist/number/types/forbiddenNegative.d.ts +6 -0
- package/dist/number/types/index.d.ts +3 -1
- package/dist/number/types/isPositive.d.ts +3 -0
- package/package.json +1 -1
- package/dist/number/types/positiveNumber.d.ts +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Adaptor, type AnyTuple } from "../../common";
|
|
2
|
+
import type * as DString from "../../string";
|
|
3
|
+
import type * as DArray from "../../array";
|
|
4
|
+
import type * as DNumber from "../../number";
|
|
5
|
+
interface GreaterTable {
|
|
6
|
+
positive: {
|
|
7
|
+
greater: [
|
|
8
|
+
"3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
9
|
+
"8" | "9",
|
|
10
|
+
"6" | "7" | "8" | "9",
|
|
11
|
+
"8" | "9",
|
|
12
|
+
"6" | "7" | "8" | "9",
|
|
13
|
+
""
|
|
14
|
+
];
|
|
15
|
+
equal: [
|
|
16
|
+
"2",
|
|
17
|
+
"7",
|
|
18
|
+
"5",
|
|
19
|
+
"7",
|
|
20
|
+
"5",
|
|
21
|
+
"9"
|
|
22
|
+
];
|
|
23
|
+
};
|
|
24
|
+
negative: {
|
|
25
|
+
greater: [
|
|
26
|
+
"3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
27
|
+
"8" | "9",
|
|
28
|
+
"2" | "3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
29
|
+
"9",
|
|
30
|
+
"3" | "4" | "5" | "6" | "7" | "8" | "9",
|
|
31
|
+
"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
|
32
|
+
];
|
|
33
|
+
equal: [
|
|
34
|
+
"2",
|
|
35
|
+
"7",
|
|
36
|
+
"1",
|
|
37
|
+
"8",
|
|
38
|
+
"2",
|
|
39
|
+
"0"
|
|
40
|
+
];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
type CheckSplitYear<GenericSplitYear extends AnyTuple<DString.Number>, GenericGreaterTable extends AnyTuple<string>, GenericEqualTable extends AnyTuple<string>> = GenericSplitYear[0] extends GenericGreaterTable[0] ? false : GenericSplitYear[0] extends GenericEqualTable[0] ? [
|
|
44
|
+
DArray.ShiftTuple<GenericSplitYear>,
|
|
45
|
+
DArray.ShiftTuple<GenericGreaterTable>,
|
|
46
|
+
DArray.ShiftTuple<GenericEqualTable>
|
|
47
|
+
] extends [
|
|
48
|
+
infer InferredSplitYear extends readonly DString.Number[],
|
|
49
|
+
infer InferredGreaterTable extends readonly string[],
|
|
50
|
+
infer InferredEqualTable extends readonly string[]
|
|
51
|
+
] ? InferredSplitYear extends AnyTuple<DString.Number> ? CheckSplitYear<InferredSplitYear, Adaptor<InferredGreaterTable, AnyTuple<string>>, Adaptor<InferredEqualTable, AnyTuple<string>>> : true : never : true;
|
|
52
|
+
export type IsSafeYear<GenericYears extends number> = DNumber.Absolute<GenericYears> extends infer InferredYear extends number ? DString.StringLength<`${InferredYear}`> extends infer InferredLength extends number ? InferredLength extends 1 | 2 | 3 | 4 | 5 | 6 ? InferredLength extends 6 ? DString.Split<`${InferredYear}`, ""> extends infer InferredSplitYear extends AnyTuple<DString.Number> ? CheckSplitYear<InferredSplitYear, DNumber.IsPositive<GenericYears> extends true ? GreaterTable["positive"]["greater"] : GreaterTable["negative"]["greater"], DNumber.IsPositive<GenericYears> extends true ? GreaterTable["positive"]["equal"] : GreaterTable["negative"]["equal"]> : false : true : false : never : never;
|
|
53
|
+
export {};
|
package/dist/metadata.json
CHANGED
|
@@ -387,6 +387,17 @@
|
|
|
387
387
|
{
|
|
388
388
|
"name": "flag.d.ts"
|
|
389
389
|
},
|
|
390
|
+
{
|
|
391
|
+
"name": "types",
|
|
392
|
+
"files": [
|
|
393
|
+
{
|
|
394
|
+
"name": "index.d.ts"
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
"name": "dataParserContainTransform.d.ts"
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
},
|
|
390
401
|
{
|
|
391
402
|
"name": "flag.mjs"
|
|
392
403
|
},
|
|
@@ -1660,6 +1671,9 @@
|
|
|
1660
1671
|
{
|
|
1661
1672
|
"name": "types",
|
|
1662
1673
|
"files": [
|
|
1674
|
+
{
|
|
1675
|
+
"name": "joinTuple.d.ts"
|
|
1676
|
+
},
|
|
1663
1677
|
{
|
|
1664
1678
|
"name": "tupleHasSpread.d.ts"
|
|
1665
1679
|
},
|
|
@@ -2616,10 +2630,16 @@
|
|
|
2616
2630
|
"name": "types",
|
|
2617
2631
|
"files": [
|
|
2618
2632
|
{
|
|
2619
|
-
"name": "
|
|
2633
|
+
"name": "forbiddenNegative.d.ts"
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
"name": "absolute.d.ts"
|
|
2620
2637
|
},
|
|
2621
2638
|
{
|
|
2622
2639
|
"name": "index.d.ts"
|
|
2640
|
+
},
|
|
2641
|
+
{
|
|
2642
|
+
"name": "isPositive.d.ts"
|
|
2623
2643
|
}
|
|
2624
2644
|
]
|
|
2625
2645
|
},
|
|
@@ -3137,6 +3157,9 @@
|
|
|
3137
3157
|
{
|
|
3138
3158
|
"name": "index.d.ts"
|
|
3139
3159
|
},
|
|
3160
|
+
{
|
|
3161
|
+
"name": "isSafeYear.d.ts"
|
|
3162
|
+
},
|
|
3140
3163
|
{
|
|
3141
3164
|
"name": "timezone.d.ts"
|
|
3142
3165
|
},
|
|
@@ -3443,6 +3466,9 @@
|
|
|
3443
3466
|
{
|
|
3444
3467
|
"name": "mergeDefinition.d.ts"
|
|
3445
3468
|
},
|
|
3469
|
+
{
|
|
3470
|
+
"name": "contain.d.ts"
|
|
3471
|
+
},
|
|
3446
3472
|
{
|
|
3447
3473
|
"name": "dataParsers.d.ts"
|
|
3448
3474
|
},
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as DString from "../../string";
|
|
2
|
+
import type * as DArray from "../../array";
|
|
3
|
+
import { type AnyTuple, type Adaptor } from "../../common";
|
|
4
|
+
import { type IsPositive } from "./isPositive";
|
|
5
|
+
export type Absolute<GenericValue extends number> = IsPositive<GenericValue> extends true ? GenericValue : DArray.JoinTuple<DArray.ShiftTuple<Adaptor<DString.Split<`${GenericValue}`, "">, AnyTuple<string>>>, ""> extends `${infer InferredResult extends number}` ? InferredResult : never;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IsPositive } from "./isPositive";
|
|
2
|
+
declare const SymbolForbiddenNumber: unique symbol;
|
|
3
|
+
export type ForbiddenNegative<GenericNumber extends number> = IsPositive<GenericNumber> extends true ? GenericNumber : {
|
|
4
|
+
[SymbolForbiddenNumber]: "Only positive number is allowed.";
|
|
5
|
+
};
|
|
6
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type PositiveNumber<GenericNumber extends number> = `${GenericNumber}` extends `-${string}` | "0" ? never : GenericNumber;
|