@duplojs/utils 1.3.23 → 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/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/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 +13 -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
package/dist/array/join.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { type IsEqual } from "../common";
|
|
2
|
-
import { type Adaptor } from "../common/types/adaptor";
|
|
3
1
|
import { type AnyTuple } from "../common/types/anyTuple";
|
|
4
|
-
import { type
|
|
5
|
-
|
|
6
|
-
export declare function join<GenericArray extends readonly string[], GenericSeparator extends string>(separator: GenericSeparator):
|
|
7
|
-
export declare function join<GenericArray extends readonly string[], GenericSeparator extends string>(array: GenericArray, separator: GenericSeparator): GenericArray extends AnyTuple ? ComputeResult<GenericArray, GenericSeparator> : string;
|
|
8
|
-
export {};
|
|
2
|
+
import { type JoinTuple } from "./types";
|
|
3
|
+
export declare function join<GenericArray extends readonly string[], GenericSeparator extends string>(separator: GenericSeparator): (array: GenericArray) => GenericArray extends AnyTuple ? JoinTuple<GenericArray, GenericSeparator> : string;
|
|
4
|
+
export declare function join<GenericArray extends readonly string[], GenericSeparator extends string>(array: GenericArray, separator: GenericSeparator): GenericArray extends AnyTuple ? JoinTuple<GenericArray, GenericSeparator> : string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AnyTuple, type IsEqual } from "../../common";
|
|
2
|
+
import { type ShiftTuple } from "./shiftTuple";
|
|
3
|
+
export type JoinTuple<GenericArray extends AnyTuple<string> | readonly [], GenericSeparator extends string, GenericDepth extends readonly unknown[] = []> = GenericArray extends AnyTuple<string> ? IsEqual<GenericDepth["length"], 100> extends true ? string : ShiftTuple<GenericArray> extends infer InferredRest extends readonly string[] ? InferredRest extends AnyTuple<string> ? JoinTuple<InferredRest, GenericSeparator, [
|
|
4
|
+
...GenericDepth,
|
|
5
|
+
0
|
|
6
|
+
]> extends infer InferredRestResult extends string ? `${GenericArray[0]}${GenericSeparator}${InferredRestResult}` : never : InferredRest extends readonly [] ? GenericArray[0] : `${GenericArray[0]}${GenericSeparator}${string}` : never : "";
|
package/dist/date/create.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type { Hour, IsLeapYear, Millisecond, Minute, Second, TheDate } from "./types";
|
|
1
|
+
import type { Hour, IsLeapYear, IsSafeYear, Millisecond, Minute, Second, TheDate } from "./types";
|
|
2
2
|
import { type EitherLeft, type EitherRight } from "../either";
|
|
3
3
|
import { type MonthWithDay } from "./types/month";
|
|
4
|
+
import type * as DString from "../string";
|
|
4
5
|
export type MayBe = EitherRight<"date-created", TheDate> | EitherLeft<"date-created-error", null>;
|
|
5
|
-
|
|
6
|
+
type SafeDate = `${number}-${MonthWithDay}`;
|
|
7
|
+
declare const SymbolForbiddenDate: unique symbol;
|
|
8
|
+
type ForbiddenDate<GenericDate extends SafeDate> = ((DString.Includes<GenericDate, "."> extends true ? {
|
|
9
|
+
[SymbolForbiddenDate]: "Year can't be includes a float number.";
|
|
10
|
+
} : GenericDate) & (GenericDate extends `${infer InferredYear extends number}-02-29` ? IsLeapYear<InferredYear> extends true ? GenericDate : {
|
|
11
|
+
[SymbolForbiddenDate]: "Is not a leap year.";
|
|
12
|
+
} : GenericDate) & (GenericDate extends `${infer InferredYear extends number}-${MonthWithDay}` ? IsSafeYear<InferredYear> extends true ? GenericDate : {
|
|
13
|
+
[SymbolForbiddenDate]: "Support that the years between -271820 and 275759.";
|
|
14
|
+
} : GenericDate));
|
|
6
15
|
interface SafeDateParams {
|
|
7
16
|
hour?: Hour;
|
|
8
17
|
minute?: Minute;
|
|
@@ -10,7 +19,5 @@ interface SafeDateParams {
|
|
|
10
19
|
millisecond?: Millisecond;
|
|
11
20
|
}
|
|
12
21
|
export declare function create<GenericInput extends TheDate | Date | number>(input: GenericInput): MayBe;
|
|
13
|
-
export declare function create<GenericInput extends
|
|
14
|
-
[SymbolErrorIsNotLeapYear]: "Is not a leap year.";
|
|
15
|
-
} : GenericInput), params?: SafeDateParams): TheDate;
|
|
22
|
+
export declare function create<GenericInput extends SafeDate>(input: GenericInput & ForbiddenDate<GenericInput>, params?: SafeDateParams): TheDate;
|
|
16
23
|
export {};
|
|
@@ -9,9 +9,8 @@ function addDays(...args) {
|
|
|
9
9
|
return (input) => addDays(input, day);
|
|
10
10
|
}
|
|
11
11
|
const [input, day] = args;
|
|
12
|
-
const absoluteDay = Math.abs(day);
|
|
13
12
|
const date = toNative.toNative(input);
|
|
14
|
-
date.setTime(date.getTime() + (
|
|
13
|
+
date.setTime(date.getTime() + (day * constants.millisecondsInOneDay));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addDays<GenericInput extends TheDate, GenericDay extends number>(day:
|
|
4
|
-
export declare function addDays<GenericInput extends TheDate, GenericDay extends number>(input: GenericInput, day: PositiveNumber<GenericDay>): TheDate;
|
|
2
|
+
export declare function addDays<GenericInput extends TheDate, GenericDay extends number>(day: GenericDay): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addDays<GenericInput extends TheDate, GenericDay extends number>(input: GenericInput, day: GenericDay): TheDate;
|
|
@@ -7,9 +7,8 @@ function addDays(...args) {
|
|
|
7
7
|
return (input) => addDays(input, day);
|
|
8
8
|
}
|
|
9
9
|
const [input, day] = args;
|
|
10
|
-
const absoluteDay = Math.abs(day);
|
|
11
10
|
const date = toNative(input);
|
|
12
|
-
date.setTime(date.getTime() + (
|
|
11
|
+
date.setTime(date.getTime() + (day * millisecondsInOneDay));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,9 +9,8 @@ function addHours(...args) {
|
|
|
9
9
|
return (input) => addHours(input, hour);
|
|
10
10
|
}
|
|
11
11
|
const [input, hour] = args;
|
|
12
|
-
const absoluteHour = Math.abs(hour);
|
|
13
12
|
const date = toNative.toNative(input);
|
|
14
|
-
date.setTime(date.getTime() + (
|
|
13
|
+
date.setTime(date.getTime() + (hour * constants.millisecondInOneHour));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addHours<GenericInput extends TheDate, GenericHour extends number>(hour:
|
|
4
|
-
export declare function addHours<GenericInput extends TheDate, GenericHour extends number>(input: GenericInput, hour: PositiveNumber<GenericHour>): TheDate;
|
|
2
|
+
export declare function addHours<GenericInput extends TheDate, GenericHour extends number>(hour: GenericHour): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addHours<GenericInput extends TheDate, GenericHour extends number>(input: GenericInput, hour: GenericHour): TheDate;
|
|
@@ -7,9 +7,8 @@ function addHours(...args) {
|
|
|
7
7
|
return (input) => addHours(input, hour);
|
|
8
8
|
}
|
|
9
9
|
const [input, hour] = args;
|
|
10
|
-
const absoluteHour = Math.abs(hour);
|
|
11
10
|
const date = toNative(input);
|
|
12
|
-
date.setTime(date.getTime() + (
|
|
11
|
+
date.setTime(date.getTime() + (hour * millisecondInOneHour));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -8,9 +8,8 @@ function addMilliseconds(...args) {
|
|
|
8
8
|
return (input) => addMilliseconds(input, millisecond);
|
|
9
9
|
}
|
|
10
10
|
const [input, millisecond] = args;
|
|
11
|
-
const absoluteMilliseconds = Math.abs(millisecond);
|
|
12
11
|
const date = toNative.toNative(input);
|
|
13
|
-
date.setTime(date.getTime() +
|
|
12
|
+
date.setTime(date.getTime() + millisecond);
|
|
14
13
|
const timestamp = date.getTime();
|
|
15
14
|
const isNegative = timestamp < 0;
|
|
16
15
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(millisecond:
|
|
4
|
-
export declare function addMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(input: GenericInput, millisecond: PositiveNumber<GenericMillisecond>): TheDate;
|
|
2
|
+
export declare function addMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(millisecond: GenericMillisecond): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(input: GenericInput, millisecond: GenericMillisecond): TheDate;
|
|
@@ -6,9 +6,8 @@ function addMilliseconds(...args) {
|
|
|
6
6
|
return (input) => addMilliseconds(input, millisecond);
|
|
7
7
|
}
|
|
8
8
|
const [input, millisecond] = args;
|
|
9
|
-
const absoluteMilliseconds = Math.abs(millisecond);
|
|
10
9
|
const date = toNative(input);
|
|
11
|
-
date.setTime(date.getTime() +
|
|
10
|
+
date.setTime(date.getTime() + millisecond);
|
|
12
11
|
const timestamp = date.getTime();
|
|
13
12
|
const isNegative = timestamp < 0;
|
|
14
13
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,9 +9,8 @@ function addMinutes(...args) {
|
|
|
9
9
|
return (input) => addMinutes(input, minute);
|
|
10
10
|
}
|
|
11
11
|
const [input, minute] = args;
|
|
12
|
-
const absoluteMinute = Math.abs(minute);
|
|
13
12
|
const date = toNative.toNative(input);
|
|
14
|
-
date.setTime(date.getTime() + (
|
|
13
|
+
date.setTime(date.getTime() + (minute * constants.millisecondInOneMinute));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addMinutes<GenericInput extends TheDate, GenericMinute extends number>(minute:
|
|
4
|
-
export declare function addMinutes<GenericInput extends TheDate, GenericMinute extends number>(input: GenericInput, minute: PositiveNumber<GenericMinute>): TheDate;
|
|
2
|
+
export declare function addMinutes<GenericInput extends TheDate, GenericMinute extends number>(minute: GenericMinute): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addMinutes<GenericInput extends TheDate, GenericMinute extends number>(input: GenericInput, minute: GenericMinute): TheDate;
|
|
@@ -7,9 +7,8 @@ function addMinutes(...args) {
|
|
|
7
7
|
return (input) => addMinutes(input, minute);
|
|
8
8
|
}
|
|
9
9
|
const [input, minute] = args;
|
|
10
|
-
const absoluteMinute = Math.abs(minute);
|
|
11
10
|
const date = toNative(input);
|
|
12
|
-
date.setTime(date.getTime() + (
|
|
11
|
+
date.setTime(date.getTime() + (minute * millisecondInOneMinute));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -8,9 +8,8 @@ function addMonths(...args) {
|
|
|
8
8
|
return (input) => addMonths(input, month);
|
|
9
9
|
}
|
|
10
10
|
const [input, month] = args;
|
|
11
|
-
const absoluteMonth = Math.abs(month);
|
|
12
11
|
const date = toNative.toNative(input);
|
|
13
|
-
date.setUTCMonth(date.getUTCMonth() +
|
|
12
|
+
date.setUTCMonth(date.getUTCMonth() + month);
|
|
14
13
|
const timestamp = date.getTime();
|
|
15
14
|
const isNegative = timestamp < 0;
|
|
16
15
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addMonths<GenericInput extends TheDate, GenericMonth extends number>(month:
|
|
4
|
-
export declare function addMonths<GenericInput extends TheDate, GenericMonth extends number>(input: GenericInput, month: PositiveNumber<GenericMonth>): TheDate;
|
|
2
|
+
export declare function addMonths<GenericInput extends TheDate, GenericMonth extends number>(month: GenericMonth): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addMonths<GenericInput extends TheDate, GenericMonth extends number>(input: GenericInput, month: GenericMonth): TheDate;
|
|
@@ -6,9 +6,8 @@ function addMonths(...args) {
|
|
|
6
6
|
return (input) => addMonths(input, month);
|
|
7
7
|
}
|
|
8
8
|
const [input, month] = args;
|
|
9
|
-
const absoluteMonth = Math.abs(month);
|
|
10
9
|
const date = toNative(input);
|
|
11
|
-
date.setUTCMonth(date.getUTCMonth() +
|
|
10
|
+
date.setUTCMonth(date.getUTCMonth() + month);
|
|
12
11
|
const timestamp = date.getTime();
|
|
13
12
|
const isNegative = timestamp < 0;
|
|
14
13
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,9 +9,8 @@ function addSeconds(...args) {
|
|
|
9
9
|
return (input) => addSeconds(input, second);
|
|
10
10
|
}
|
|
11
11
|
const [input, second] = args;
|
|
12
|
-
const absoluteSecond = Math.abs(second);
|
|
13
12
|
const date = toNative.toNative(input);
|
|
14
|
-
date.setTime(date.getTime() + (
|
|
13
|
+
date.setTime(date.getTime() + (second * constants.millisecondsInOneSecond));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addSeconds<GenericInput extends TheDate, GenericSecond extends number>(second:
|
|
4
|
-
export declare function addSeconds<GenericInput extends TheDate, GenericSecond extends number>(input: GenericInput, second: PositiveNumber<GenericSecond>): TheDate;
|
|
2
|
+
export declare function addSeconds<GenericInput extends TheDate, GenericSecond extends number>(second: GenericSecond): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addSeconds<GenericInput extends TheDate, GenericSecond extends number>(input: GenericInput, second: GenericSecond): TheDate;
|
|
@@ -7,9 +7,8 @@ function addSeconds(...args) {
|
|
|
7
7
|
return (input) => addSeconds(input, second);
|
|
8
8
|
}
|
|
9
9
|
const [input, second] = args;
|
|
10
|
-
const absoluteSecond = Math.abs(second);
|
|
11
10
|
const date = toNative(input);
|
|
12
|
-
date.setTime(date.getTime() + (
|
|
11
|
+
date.setTime(date.getTime() + (second * millisecondsInOneSecond));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,9 +9,8 @@ function addWeeks(...args) {
|
|
|
9
9
|
return (input) => addWeeks(input, week);
|
|
10
10
|
}
|
|
11
11
|
const [input, week] = args;
|
|
12
|
-
const absoluteWeek = Math.abs(week);
|
|
13
12
|
const date = toNative.toNative(input);
|
|
14
|
-
date.setTime(date.getTime() + (
|
|
13
|
+
date.setTime(date.getTime() + (week * constants.millisecondInOneWeek));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addWeeks<GenericInput extends TheDate, GenericWeek extends number>(week:
|
|
4
|
-
export declare function addWeeks<GenericInput extends TheDate, GenericWeek extends number>(input: GenericInput, week: PositiveNumber<GenericWeek>): TheDate;
|
|
2
|
+
export declare function addWeeks<GenericInput extends TheDate, GenericWeek extends number>(week: GenericWeek): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addWeeks<GenericInput extends TheDate, GenericWeek extends number>(input: GenericInput, week: GenericWeek): TheDate;
|
|
@@ -7,9 +7,8 @@ function addWeeks(...args) {
|
|
|
7
7
|
return (input) => addWeeks(input, week);
|
|
8
8
|
}
|
|
9
9
|
const [input, week] = args;
|
|
10
|
-
const absoluteWeek = Math.abs(week);
|
|
11
10
|
const date = toNative(input);
|
|
12
|
-
date.setTime(date.getTime() + (
|
|
11
|
+
date.setTime(date.getTime() + (week * millisecondInOneWeek));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -8,9 +8,8 @@ function addYears(...args) {
|
|
|
8
8
|
return (input) => addYears(input, year);
|
|
9
9
|
}
|
|
10
10
|
const [input, year] = args;
|
|
11
|
-
const absoluteYear = Math.abs(year);
|
|
12
11
|
const date = toNative.toNative(input);
|
|
13
|
-
date.setUTCFullYear(date.getUTCFullYear() +
|
|
12
|
+
date.setUTCFullYear(date.getUTCFullYear() + year);
|
|
14
13
|
const timestamp = date.getTime();
|
|
15
14
|
const isNegative = timestamp < 0;
|
|
16
15
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function addYears<GenericInput extends TheDate, GenericYear extends number>(year:
|
|
4
|
-
export declare function addYears<GenericInput extends TheDate, GenericYear extends number>(input: GenericInput, year: PositiveNumber<GenericYear>): TheDate;
|
|
2
|
+
export declare function addYears<GenericInput extends TheDate, GenericYear extends number>(year: GenericYear): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function addYears<GenericInput extends TheDate, GenericYear extends number>(input: GenericInput, year: GenericYear): TheDate;
|
|
@@ -6,9 +6,8 @@ function addYears(...args) {
|
|
|
6
6
|
return (input) => addYears(input, year);
|
|
7
7
|
}
|
|
8
8
|
const [input, year] = args;
|
|
9
|
-
const absoluteYear = Math.abs(year);
|
|
10
9
|
const date = toNative(input);
|
|
11
|
-
date.setUTCFullYear(date.getUTCFullYear() +
|
|
10
|
+
date.setUTCFullYear(date.getUTCFullYear() + year);
|
|
12
11
|
const timestamp = date.getTime();
|
|
13
12
|
const isNegative = timestamp < 0;
|
|
14
13
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -10,8 +10,7 @@ function subtractDays(...args) {
|
|
|
10
10
|
}
|
|
11
11
|
const [input, day] = args;
|
|
12
12
|
const date = toNative.toNative(input);
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() - (absoluteDay * constants.millisecondsInOneDay));
|
|
13
|
+
date.setTime(date.getTime() - (day * constants.millisecondsInOneDay));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractDays<GenericInput extends TheDate, GenericDay extends number>(day:
|
|
4
|
-
export declare function subtractDays<GenericInput extends TheDate, GenericDay extends number>(input: GenericInput, day: PositiveNumber<GenericDay>): TheDate;
|
|
2
|
+
export declare function subtractDays<GenericInput extends TheDate, GenericDay extends number>(day: GenericDay): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractDays<GenericInput extends TheDate, GenericDay extends number>(input: GenericInput, day: GenericDay): TheDate;
|
|
@@ -8,8 +8,7 @@ function subtractDays(...args) {
|
|
|
8
8
|
}
|
|
9
9
|
const [input, day] = args;
|
|
10
10
|
const date = toNative(input);
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() - (absoluteDay * millisecondsInOneDay));
|
|
11
|
+
date.setTime(date.getTime() - (day * millisecondsInOneDay));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -10,8 +10,7 @@ function subtractHours(...args) {
|
|
|
10
10
|
}
|
|
11
11
|
const [input, hour] = args;
|
|
12
12
|
const date = toNative.toNative(input);
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() - (absoluteHour * constants.millisecondInOneHour));
|
|
13
|
+
date.setTime(date.getTime() - (hour * constants.millisecondInOneHour));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractHours<GenericInput extends TheDate, GenericHour extends number>(hour:
|
|
4
|
-
export declare function subtractHours<GenericInput extends TheDate, GenericHour extends number>(input: GenericInput, hour: PositiveNumber<GenericHour>): TheDate;
|
|
2
|
+
export declare function subtractHours<GenericInput extends TheDate, GenericHour extends number>(hour: GenericHour): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractHours<GenericInput extends TheDate, GenericHour extends number>(input: GenericInput, hour: GenericHour): TheDate;
|
|
@@ -8,8 +8,7 @@ function subtractHours(...args) {
|
|
|
8
8
|
}
|
|
9
9
|
const [input, hour] = args;
|
|
10
10
|
const date = toNative(input);
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() - (absoluteHour * millisecondInOneHour));
|
|
11
|
+
date.setTime(date.getTime() - (hour * millisecondInOneHour));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,8 +9,7 @@ function subtractMilliseconds(...args) {
|
|
|
9
9
|
}
|
|
10
10
|
const [input, millisecond] = args;
|
|
11
11
|
const date = toNative.toNative(input);
|
|
12
|
-
|
|
13
|
-
date.setTime(date.getTime() - absoluteMillisecond);
|
|
12
|
+
date.setTime(date.getTime() - millisecond);
|
|
14
13
|
const timestamp = date.getTime();
|
|
15
14
|
const isNegative = timestamp < 0;
|
|
16
15
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(millisecond:
|
|
4
|
-
export declare function subtractMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(input: GenericInput, millisecond: PositiveNumber<GenericMillisecond>): TheDate;
|
|
2
|
+
export declare function subtractMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(millisecond: GenericMillisecond): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractMilliseconds<GenericInput extends TheDate, GenericMillisecond extends number>(input: GenericInput, millisecond: GenericMillisecond): TheDate;
|
|
@@ -7,8 +7,7 @@ function subtractMilliseconds(...args) {
|
|
|
7
7
|
}
|
|
8
8
|
const [input, millisecond] = args;
|
|
9
9
|
const date = toNative(input);
|
|
10
|
-
|
|
11
|
-
date.setTime(date.getTime() - absoluteMillisecond);
|
|
10
|
+
date.setTime(date.getTime() - millisecond);
|
|
12
11
|
const timestamp = date.getTime();
|
|
13
12
|
const isNegative = timestamp < 0;
|
|
14
13
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -10,8 +10,7 @@ function subtractMinutes(...args) {
|
|
|
10
10
|
}
|
|
11
11
|
const [input, minute] = args;
|
|
12
12
|
const date = toNative.toNative(input);
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() - (absoluteMinute * constants.millisecondInOneMinute));
|
|
13
|
+
date.setTime(date.getTime() - (minute * constants.millisecondInOneMinute));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractMinutes<GenericInput extends TheDate, GenericMinute extends number>(minute:
|
|
4
|
-
export declare function subtractMinutes<GenericInput extends TheDate, GenericMinute extends number>(input: GenericInput, minute: PositiveNumber<GenericMinute>): TheDate;
|
|
2
|
+
export declare function subtractMinutes<GenericInput extends TheDate, GenericMinute extends number>(minute: GenericMinute): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractMinutes<GenericInput extends TheDate, GenericMinute extends number>(input: GenericInput, minute: GenericMinute): TheDate;
|
|
@@ -8,8 +8,7 @@ function subtractMinutes(...args) {
|
|
|
8
8
|
}
|
|
9
9
|
const [input, minute] = args;
|
|
10
10
|
const date = toNative(input);
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() - (absoluteMinute * millisecondInOneMinute));
|
|
11
|
+
date.setTime(date.getTime() - (minute * millisecondInOneMinute));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,8 +9,7 @@ function subtractMonths(...args) {
|
|
|
9
9
|
}
|
|
10
10
|
const [input, month] = args;
|
|
11
11
|
const date = toNative.toNative(input);
|
|
12
|
-
|
|
13
|
-
date.setUTCMonth(date.getUTCMonth() - absoluteMonth);
|
|
12
|
+
date.setUTCMonth(date.getUTCMonth() - month);
|
|
14
13
|
const timestamp = date.getTime();
|
|
15
14
|
const isNegative = timestamp < 0;
|
|
16
15
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractMonths<GenericInput extends TheDate, GenericMonth extends number>(month:
|
|
4
|
-
export declare function subtractMonths<GenericInput extends TheDate, GenericMonth extends number>(input: GenericInput, month: PositiveNumber<GenericMonth>): TheDate;
|
|
2
|
+
export declare function subtractMonths<GenericInput extends TheDate, GenericMonth extends number>(month: GenericMonth): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractMonths<GenericInput extends TheDate, GenericMonth extends number>(input: GenericInput, month: GenericMonth): TheDate;
|
|
@@ -7,8 +7,7 @@ function subtractMonths(...args) {
|
|
|
7
7
|
}
|
|
8
8
|
const [input, month] = args;
|
|
9
9
|
const date = toNative(input);
|
|
10
|
-
|
|
11
|
-
date.setUTCMonth(date.getUTCMonth() - absoluteMonth);
|
|
10
|
+
date.setUTCMonth(date.getUTCMonth() - month);
|
|
12
11
|
const timestamp = date.getTime();
|
|
13
12
|
const isNegative = timestamp < 0;
|
|
14
13
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -10,8 +10,7 @@ function subtractSeconds(...args) {
|
|
|
10
10
|
}
|
|
11
11
|
const [input, second] = args;
|
|
12
12
|
const date = toNative.toNative(input);
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() - (absoluteSecond * constants.millisecondsInOneSecond));
|
|
13
|
+
date.setTime(date.getTime() - (second * constants.millisecondsInOneSecond));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractSeconds<GenericInput extends TheDate, GenericSecond extends number>(second:
|
|
4
|
-
export declare function subtractSeconds<GenericInput extends TheDate, GenericSecond extends number>(input: GenericInput, second: PositiveNumber<GenericSecond>): TheDate;
|
|
2
|
+
export declare function subtractSeconds<GenericInput extends TheDate, GenericSecond extends number>(second: GenericSecond): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractSeconds<GenericInput extends TheDate, GenericSecond extends number>(input: GenericInput, second: GenericSecond): TheDate;
|
|
@@ -8,8 +8,7 @@ function subtractSeconds(...args) {
|
|
|
8
8
|
}
|
|
9
9
|
const [input, second] = args;
|
|
10
10
|
const date = toNative(input);
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() - (absoluteSecond * millisecondsInOneSecond));
|
|
11
|
+
date.setTime(date.getTime() - (second * millisecondsInOneSecond));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -10,8 +10,7 @@ function subtractWeeks(...args) {
|
|
|
10
10
|
}
|
|
11
11
|
const [input, week] = args;
|
|
12
12
|
const date = toNative.toNative(input);
|
|
13
|
-
|
|
14
|
-
date.setTime(date.getTime() - (absoluteWeek * constants.millisecondInOneWeek));
|
|
13
|
+
date.setTime(date.getTime() - (week * constants.millisecondInOneWeek));
|
|
15
14
|
const timestamp = date.getTime();
|
|
16
15
|
const isNegative = timestamp < 0;
|
|
17
16
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractWeeks<GenericInput extends TheDate, GenericWeek extends number>(week:
|
|
4
|
-
export declare function subtractWeeks<GenericInput extends TheDate, GenericWeek extends number>(input: GenericInput, week: PositiveNumber<GenericWeek>): TheDate;
|
|
2
|
+
export declare function subtractWeeks<GenericInput extends TheDate, GenericWeek extends number>(week: GenericWeek): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractWeeks<GenericInput extends TheDate, GenericWeek extends number>(input: GenericInput, week: GenericWeek): TheDate;
|
|
@@ -8,8 +8,7 @@ function subtractWeeks(...args) {
|
|
|
8
8
|
}
|
|
9
9
|
const [input, week] = args;
|
|
10
10
|
const date = toNative(input);
|
|
11
|
-
|
|
12
|
-
date.setTime(date.getTime() - (absoluteWeek * millisecondInOneWeek));
|
|
11
|
+
date.setTime(date.getTime() - (week * millisecondInOneWeek));
|
|
13
12
|
const timestamp = date.getTime();
|
|
14
13
|
const isNegative = timestamp < 0;
|
|
15
14
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -9,8 +9,7 @@ function subtractYears(...args) {
|
|
|
9
9
|
}
|
|
10
10
|
const [input, year] = args;
|
|
11
11
|
const date = toNative.toNative(input);
|
|
12
|
-
|
|
13
|
-
date.setUTCFullYear(date.getUTCFullYear() - absoluteYear);
|
|
12
|
+
date.setUTCFullYear(date.getUTCFullYear() - year);
|
|
14
13
|
const timestamp = date.getTime();
|
|
15
14
|
const isNegative = timestamp < 0;
|
|
16
15
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { TheDate } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare function subtractYears<GenericInput extends TheDate, GenericYear extends number>(year:
|
|
4
|
-
export declare function subtractYears<GenericInput extends TheDate, GenericYear extends number>(input: GenericInput, year: PositiveNumber<GenericYear>): TheDate;
|
|
2
|
+
export declare function subtractYears<GenericInput extends TheDate, GenericYear extends number>(year: GenericYear): (input: GenericInput) => TheDate;
|
|
3
|
+
export declare function subtractYears<GenericInput extends TheDate, GenericYear extends number>(input: GenericInput, year: GenericYear): TheDate;
|
|
@@ -7,8 +7,7 @@ function subtractYears(...args) {
|
|
|
7
7
|
}
|
|
8
8
|
const [input, year] = args;
|
|
9
9
|
const date = toNative(input);
|
|
10
|
-
|
|
11
|
-
date.setUTCFullYear(date.getUTCFullYear() - absoluteYear);
|
|
10
|
+
date.setUTCFullYear(date.getUTCFullYear() - year);
|
|
12
11
|
const timestamp = date.getTime();
|
|
13
12
|
const isNegative = timestamp < 0;
|
|
14
13
|
return `date${Math.abs(timestamp)}${isNegative ? "-" : "+"}`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type * as DString from "../../string";
|
|
2
2
|
type TenEven = "" | "2" | "4" | "6" | "8";
|
|
3
3
|
type OddTen = "1" | "3" | "5" | "7" | "9";
|
|
4
4
|
type MultipleOf4 = `${TenEven}${"0" | "4" | "8"}` | `${OddTen}${"2" | "6"}`;
|
|
5
|
-
type MultipleOf100 = `${Exclude<Digit, "0">}00`;
|
|
5
|
+
type MultipleOf100 = `${Exclude<DString.Digit, "0">}00`;
|
|
6
6
|
type MultipleOf400 = `${Exclude<MultipleOf4, "0">}00`;
|
|
7
|
-
export type IsLeapYear<GenericYear extends
|
|
7
|
+
export type IsLeapYear<GenericYear extends number> = `${GenericYear}` extends infer InferredYear ? InferredYear extends `${number | ""}${MultipleOf4}` ? InferredYear extends `${number | ""}${MultipleOf100}` ? InferredYear extends `${number | ""}${MultipleOf400}` ? true : false : true : false : never;
|
|
8
8
|
export {};
|
|
@@ -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
|
@@ -1671,6 +1671,9 @@
|
|
|
1671
1671
|
{
|
|
1672
1672
|
"name": "types",
|
|
1673
1673
|
"files": [
|
|
1674
|
+
{
|
|
1675
|
+
"name": "joinTuple.d.ts"
|
|
1676
|
+
},
|
|
1674
1677
|
{
|
|
1675
1678
|
"name": "tupleHasSpread.d.ts"
|
|
1676
1679
|
},
|
|
@@ -2627,10 +2630,16 @@
|
|
|
2627
2630
|
"name": "types",
|
|
2628
2631
|
"files": [
|
|
2629
2632
|
{
|
|
2630
|
-
"name": "
|
|
2633
|
+
"name": "forbiddenNegative.d.ts"
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
"name": "absolute.d.ts"
|
|
2631
2637
|
},
|
|
2632
2638
|
{
|
|
2633
2639
|
"name": "index.d.ts"
|
|
2640
|
+
},
|
|
2641
|
+
{
|
|
2642
|
+
"name": "isPositive.d.ts"
|
|
2634
2643
|
}
|
|
2635
2644
|
]
|
|
2636
2645
|
},
|
|
@@ -3148,6 +3157,9 @@
|
|
|
3148
3157
|
{
|
|
3149
3158
|
"name": "index.d.ts"
|
|
3150
3159
|
},
|
|
3160
|
+
{
|
|
3161
|
+
"name": "isSafeYear.d.ts"
|
|
3162
|
+
},
|
|
3151
3163
|
{
|
|
3152
3164
|
"name": "timezone.d.ts"
|
|
3153
3165
|
},
|
|
@@ -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;
|