@duplojs/lang 0.0.1-beta.7 → 0.0.1-beta.8
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/chrono/createDate.cjs +8 -8
- package/dist/chrono/createDate.d.ts +3 -3
- package/dist/chrono/createDate.mjs +8 -8
- package/dist/chrono/createTime.cjs +24 -13
- package/dist/chrono/createTime.mjs +24 -13
- package/dist/chrono/theDate.cjs +15 -16
- package/dist/chrono/theDate.d.ts +15 -15
- package/dist/chrono/theDate.mjs +15 -16
- package/dist/chrono/theTime.cjs +0 -1
- package/dist/chrono/theTime.mjs +0 -1
- package/dist/chrono/types/spoolingTime.d.ts +2 -1
- package/dist/common/constraint/cast/string.d.ts +4 -0
- package/dist/common/constraint/infer/string.d.ts +1 -0
- package/dist/common/isType.d.ts +3 -2
- package/dist/dataStructure/common/{codec.cjs → codec/base.cjs} +5 -5
- package/dist/dataStructure/common/{codec.d.ts → codec/base.d.ts} +6 -6
- package/dist/dataStructure/common/{codec.mjs → codec/base.mjs} +5 -5
- package/dist/dataStructure/common/codec/defaults/index.d.ts +2 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +26 -0
- package/dist/dataStructure/common/codec/defaults/json.d.ts +6 -0
- package/dist/dataStructure/common/codec/defaults/json.mjs +26 -0
- package/dist/dataStructure/common/codec/defaults/string.cjs +44 -0
- package/dist/dataStructure/common/codec/defaults/string.d.ts +11 -0
- package/dist/dataStructure/common/codec/defaults/string.mjs +44 -0
- package/dist/dataStructure/common/codec/index.d.ts +2 -0
- package/dist/dataStructure/constraint/defaults/index.d.ts +1 -0
- package/dist/dataStructure/constraint/defaults/numberInString.cjs +13 -0
- package/dist/dataStructure/constraint/defaults/numberInString.d.ts +10 -0
- package/dist/dataStructure/constraint/defaults/numberInString.mjs +12 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +1 -0
- package/dist/dataStructure/helpers/index.d.ts +1 -0
- package/dist/dataStructure/helpers/numberInString.cjs +7 -0
- package/dist/dataStructure/helpers/numberInString.d.ts +2 -0
- package/dist/dataStructure/helpers/numberInString.mjs +7 -0
- package/dist/dataStructure/index.cjs +65 -51
- package/dist/dataStructure/index.mjs +21 -12
- package/dist/number/types/isGreater.d.ts +5 -5
- package/dist/string/constraints/index.d.ts +2 -1
- package/dist/string/constraints/number.d.ts +4 -0
- package/dist/string/index.cjs +3 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.mjs +3 -1
- package/dist/string/isNumber.cjs +7 -0
- package/dist/string/isNumber.d.ts +5 -0
- package/dist/string/isNumber.mjs +7 -0
- package/dist/string/to.d.ts +9 -2
- package/dist/string/types/index.d.ts +4 -5
- package/dist/string/types/numberInString.d.ts +1 -0
- package/package.json +1 -1
- package/dist/string/types/number.d.ts +0 -1
|
@@ -28,23 +28,23 @@ function createDate(input, params) {
|
|
|
28
28
|
return require_theDate.TheDate.new(date.getTime());
|
|
29
29
|
}
|
|
30
30
|
if (typeof input === "object") {
|
|
31
|
-
let
|
|
31
|
+
let resolvedDate = void 0;
|
|
32
32
|
const serializeTheDateMatch = typeof input.value === "string" && input.value.match(require_constants.serializeTheDateRegex);
|
|
33
33
|
if (serializeTheDateMatch) {
|
|
34
34
|
const { value, sign } = serializeTheDateMatch.groups;
|
|
35
|
-
|
|
36
|
-
} else if (require_isDate.isDate(input.value))
|
|
37
|
-
else if (input.value instanceof Date)
|
|
38
|
-
else if (typeof input.value === "number")
|
|
35
|
+
resolvedDate = createFromTimestamp(Number(sign === "-" ? `-${value}` : value));
|
|
36
|
+
} else if (require_isDate.isDate(input.value)) resolvedDate = require_create$1.right("date-created", input.value);
|
|
37
|
+
else if (input.value instanceof Date) resolvedDate = createFromTimestamp(input.value.getTime());
|
|
38
|
+
else if (typeof input.value === "number") resolvedDate = createFromTimestamp(input.value);
|
|
39
39
|
else {
|
|
40
40
|
const isoDateMatch = input.value.match(require_constants.isoDateRegex);
|
|
41
41
|
if (isoDateMatch) {
|
|
42
42
|
const { year, month, date, hour, minute, second, millisecond } = isoDateMatch.groups;
|
|
43
|
-
|
|
43
|
+
resolvedDate = createFromTimestamp(Date.UTC(Number(year), Number(month) - 1, Number(date), typeof hour === "string" ? Number(hour) : 0, typeof minute === "string" ? Number(minute) : 0, typeof second === "string" ? Number(second) : 0, typeof millisecond === "string" ? Number(millisecond) : 0));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (!
|
|
47
|
-
const date = require_toNative.toNative(require_unwrap.unwrapRight(
|
|
46
|
+
if (!resolvedDate || require_is.isLeft(resolvedDate)) return resolvedDate || require_create.left("date-created-error", null);
|
|
47
|
+
const date = require_toNative.toNative(require_unwrap.unwrapRight(resolvedDate));
|
|
48
48
|
input.year && date.setUTCFullYear(input.year);
|
|
49
49
|
input.month && date.setMonth(input.month);
|
|
50
50
|
input.day && date.setDate(input.day);
|
|
@@ -3,7 +3,7 @@ import { Hour, IsLeapYear, IsSafeYear, Millisecond, Minute, Second, MonthWithDay
|
|
|
3
3
|
import * as DEither from '../either';
|
|
4
4
|
import type * as DCommon from '../common';
|
|
5
5
|
import type * as DString from '../string';
|
|
6
|
-
export type
|
|
6
|
+
export type MayBeDate = DEither.Right<"date-created", TheDate> | DEither.Left<"date-created-error", null>;
|
|
7
7
|
type SafeDate = `${number}-${MonthWithDay}`;
|
|
8
8
|
type ForbiddenDate<GenericDate extends string> = DCommon.And<[
|
|
9
9
|
DCommon.IsExtends<GenericDate, SafeDate>,
|
|
@@ -15,7 +15,7 @@ export interface CreateSafeDateParams {
|
|
|
15
15
|
second?: Second;
|
|
16
16
|
millisecond?: Millisecond;
|
|
17
17
|
}
|
|
18
|
-
export declare function createDate<GenericInput extends TheDate | Date | number | SerializedTheDate>(input: GenericInput):
|
|
19
|
-
export declare function createDate<GenericInput extends SpoolingDate>(input: GenericInput):
|
|
18
|
+
export declare function createDate<GenericInput extends TheDate | Date | number | SerializedTheDate>(input: GenericInput): MayBeDate;
|
|
19
|
+
export declare function createDate<GenericInput extends SpoolingDate>(input: GenericInput): MayBeDate;
|
|
20
20
|
export declare function createDate<GenericInput extends SafeDate>(input: GenericInput & ForbiddenDate<GenericInput>, params?: CreateSafeDateParams): TheDate;
|
|
21
21
|
export {};
|
|
@@ -28,23 +28,23 @@ function createDate(input, params) {
|
|
|
28
28
|
return TheDate.new(date.getTime());
|
|
29
29
|
}
|
|
30
30
|
if (typeof input === "object") {
|
|
31
|
-
let
|
|
31
|
+
let resolvedDate = void 0;
|
|
32
32
|
const serializeTheDateMatch = typeof input.value === "string" && input.value.match(serializeTheDateRegex);
|
|
33
33
|
if (serializeTheDateMatch) {
|
|
34
34
|
const { value, sign } = serializeTheDateMatch.groups;
|
|
35
|
-
|
|
36
|
-
} else if (isDate(input.value))
|
|
37
|
-
else if (input.value instanceof Date)
|
|
38
|
-
else if (typeof input.value === "number")
|
|
35
|
+
resolvedDate = createFromTimestamp(Number(sign === "-" ? `-${value}` : value));
|
|
36
|
+
} else if (isDate(input.value)) resolvedDate = right("date-created", input.value);
|
|
37
|
+
else if (input.value instanceof Date) resolvedDate = createFromTimestamp(input.value.getTime());
|
|
38
|
+
else if (typeof input.value === "number") resolvedDate = createFromTimestamp(input.value);
|
|
39
39
|
else {
|
|
40
40
|
const isoDateMatch = input.value.match(isoDateRegex);
|
|
41
41
|
if (isoDateMatch) {
|
|
42
42
|
const { year, month, date, hour, minute, second, millisecond } = isoDateMatch.groups;
|
|
43
|
-
|
|
43
|
+
resolvedDate = createFromTimestamp(Date.UTC(Number(year), Number(month) - 1, Number(date), typeof hour === "string" ? Number(hour) : 0, typeof minute === "string" ? Number(minute) : 0, typeof second === "string" ? Number(second) : 0, typeof millisecond === "string" ? Number(millisecond) : 0));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
if (!
|
|
47
|
-
const date = toNative(unwrapRight(
|
|
46
|
+
if (!resolvedDate || isLeft(resolvedDate)) return resolvedDate || left("date-created-error", null);
|
|
47
|
+
const date = toNative(unwrapRight(resolvedDate));
|
|
48
48
|
input.year && date.setUTCFullYear(input.year);
|
|
49
49
|
input.month && date.setMonth(input.month);
|
|
50
50
|
input.day && date.setDate(input.day);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
const require_constants = require("./constants.cjs");
|
|
2
2
|
const require_theTime = require("./theTime.cjs");
|
|
3
|
+
const require_isTime = require("./isTime.cjs");
|
|
3
4
|
const require_create = require("../either/left/create.cjs");
|
|
5
|
+
const require_is = require("../either/left/is.cjs");
|
|
4
6
|
const require_create$1 = require("../either/right/create.cjs");
|
|
7
|
+
const require_unwrap = require("../either/right/unwrap.cjs");
|
|
8
|
+
const require_toNative = require("./toNative.cjs");
|
|
5
9
|
const require_isSafeTimeValue = require("./isSafeTimeValue.cjs");
|
|
6
10
|
//#region scripts/chrono/createTime.ts
|
|
7
11
|
const unitMapper = {
|
|
@@ -18,24 +22,31 @@ function createTime(input, unit) {
|
|
|
18
22
|
if (unit) return require_theTime.TheTime.new(input * unitMapper[unit]);
|
|
19
23
|
return createFromTimeValue(input * unitMapper[unit ?? "millisecond"]);
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!serializeTheTimeMatch) return require_create.left("time-created-error", null);
|
|
25
|
+
const serializeTheTimeMatch = typeof input === "string" && input.match(require_constants.serializeTheTimeRegex);
|
|
26
|
+
if (serializeTheTimeMatch) {
|
|
24
27
|
const { value, sign } = serializeTheTimeMatch.groups;
|
|
25
28
|
return createFromTimeValue(Number(sign === "-" ? `-${value}` : value));
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
if (typeof input === "object") {
|
|
31
|
+
let resolvedTime = void 0;
|
|
32
|
+
const serializeTheTimeMatch = typeof input.value === "string" && input.value.match(require_constants.serializeTheTimeRegex);
|
|
33
|
+
if (serializeTheTimeMatch) {
|
|
34
|
+
const { value, sign } = serializeTheTimeMatch.groups;
|
|
35
|
+
resolvedTime = createFromTimeValue(Number(sign === "-" ? `-${value}` : value));
|
|
36
|
+
} else if (typeof input.value === "number") resolvedTime = createFromTimeValue(input.value);
|
|
37
|
+
else if (require_isTime.isTime(input.value)) resolvedTime = require_create$1.right("time-created", input.value);
|
|
38
|
+
else {
|
|
39
|
+
const theTimeMatch = input.value?.match(require_constants.isoTimeRegex);
|
|
40
|
+
if (theTimeMatch) {
|
|
41
|
+
const { sign = "+", hour, minute, second = 0, millisecond = 0 } = theTimeMatch.groups;
|
|
42
|
+
resolvedTime = createFromTimeValue((Number(hour) * require_constants.millisecondInOneHour + Number(minute) * require_constants.millisecondInOneMinute + Number(second) * require_constants.millisecondsInOneSecond + Number(millisecond)) * (sign === "-" ? -1 : 1));
|
|
43
|
+
}
|
|
36
44
|
}
|
|
45
|
+
if (!resolvedTime || require_is.isLeft(resolvedTime)) return resolvedTime || require_create.left("time-created-error", null);
|
|
46
|
+
const { week = 0, day = 0, hour = 0, minute = 0, second = 0, millisecond = 0 } = input;
|
|
47
|
+
return createFromTimeValue(require_toNative.toNative(require_unwrap.unwrapRight(resolvedTime)) + week * require_constants.millisecondInOneWeek + day * require_constants.millisecondsInOneDay + hour * require_constants.millisecondInOneHour + minute * require_constants.millisecondInOneMinute + second * require_constants.millisecondsInOneSecond + millisecond);
|
|
37
48
|
}
|
|
38
|
-
return
|
|
49
|
+
return require_create.left("time-created-error", null);
|
|
39
50
|
}
|
|
40
51
|
function createFromTimeValue(timeValue) {
|
|
41
52
|
if (!require_isSafeTimeValue.isSafeTimeValue(timeValue)) return require_create.left("time-created-error", null);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { isoTimeRegex, millisecondInOneHour, millisecondInOneMinute, millisecondInOneWeek, millisecondsInOneDay, millisecondsInOneSecond, serializeTheTimeRegex } from "./constants.mjs";
|
|
2
2
|
import { TheTime } from "./theTime.mjs";
|
|
3
|
+
import { isTime } from "./isTime.mjs";
|
|
3
4
|
import { left } from "../either/left/create.mjs";
|
|
5
|
+
import { isLeft } from "../either/left/is.mjs";
|
|
4
6
|
import { right } from "../either/right/create.mjs";
|
|
7
|
+
import { unwrapRight } from "../either/right/unwrap.mjs";
|
|
8
|
+
import { toNative } from "./toNative.mjs";
|
|
5
9
|
import { isSafeTimeValue } from "./isSafeTimeValue.mjs";
|
|
6
10
|
//#region scripts/chrono/createTime.ts
|
|
7
11
|
const unitMapper = {
|
|
@@ -18,24 +22,31 @@ function createTime(input, unit) {
|
|
|
18
22
|
if (unit) return TheTime.new(input * unitMapper[unit]);
|
|
19
23
|
return createFromTimeValue(input * unitMapper[unit ?? "millisecond"]);
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!serializeTheTimeMatch) return left("time-created-error", null);
|
|
25
|
+
const serializeTheTimeMatch = typeof input === "string" && input.match(serializeTheTimeRegex);
|
|
26
|
+
if (serializeTheTimeMatch) {
|
|
24
27
|
const { value, sign } = serializeTheTimeMatch.groups;
|
|
25
28
|
return createFromTimeValue(Number(sign === "-" ? `-${value}` : value));
|
|
26
29
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
if (typeof input === "object") {
|
|
31
|
+
let resolvedTime = void 0;
|
|
32
|
+
const serializeTheTimeMatch = typeof input.value === "string" && input.value.match(serializeTheTimeRegex);
|
|
33
|
+
if (serializeTheTimeMatch) {
|
|
34
|
+
const { value, sign } = serializeTheTimeMatch.groups;
|
|
35
|
+
resolvedTime = createFromTimeValue(Number(sign === "-" ? `-${value}` : value));
|
|
36
|
+
} else if (typeof input.value === "number") resolvedTime = createFromTimeValue(input.value);
|
|
37
|
+
else if (isTime(input.value)) resolvedTime = right("time-created", input.value);
|
|
38
|
+
else {
|
|
39
|
+
const theTimeMatch = input.value?.match(isoTimeRegex);
|
|
40
|
+
if (theTimeMatch) {
|
|
41
|
+
const { sign = "+", hour, minute, second = 0, millisecond = 0 } = theTimeMatch.groups;
|
|
42
|
+
resolvedTime = createFromTimeValue((Number(hour) * millisecondInOneHour + Number(minute) * millisecondInOneMinute + Number(second) * millisecondsInOneSecond + Number(millisecond)) * (sign === "-" ? -1 : 1));
|
|
43
|
+
}
|
|
36
44
|
}
|
|
45
|
+
if (!resolvedTime || isLeft(resolvedTime)) return resolvedTime || left("time-created-error", null);
|
|
46
|
+
const { week = 0, day = 0, hour = 0, minute = 0, second = 0, millisecond = 0 } = input;
|
|
47
|
+
return createFromTimeValue(toNative(unwrapRight(resolvedTime)) + week * millisecondInOneWeek + day * millisecondsInOneDay + hour * millisecondInOneHour + minute * millisecondInOneMinute + second * millisecondsInOneSecond + millisecond);
|
|
37
48
|
}
|
|
38
|
-
return
|
|
49
|
+
return left("time-created-error", null);
|
|
39
50
|
}
|
|
40
51
|
function createFromTimeValue(timeValue) {
|
|
41
52
|
if (!isSafeTimeValue(timeValue)) return left("time-created-error", null);
|
package/dist/chrono/theDate.cjs
CHANGED
|
@@ -20,96 +20,95 @@ var TheDate = class TheDate extends require_parentClass.parentClass(require_kind
|
|
|
20
20
|
/**
|
|
21
21
|
* @deprecated this method does not work on ImmutableDate
|
|
22
22
|
*/
|
|
23
|
-
setDate(
|
|
23
|
+
setDate() {
|
|
24
24
|
return this.getTime();
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* @deprecated this method does not work on ImmutableDate
|
|
28
28
|
*/
|
|
29
|
-
setFullYear(
|
|
29
|
+
setFullYear() {
|
|
30
30
|
return this.getTime();
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* @deprecated this method does not work on ImmutableDate
|
|
34
34
|
*/
|
|
35
|
-
setHours(
|
|
35
|
+
setHours() {
|
|
36
36
|
return this.getTime();
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* @deprecated this method does not work on ImmutableDate
|
|
40
40
|
*/
|
|
41
|
-
setMilliseconds(
|
|
41
|
+
setMilliseconds() {
|
|
42
42
|
return this.getTime();
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* @deprecated this method does not work on ImmutableDate
|
|
46
46
|
*/
|
|
47
|
-
setMinutes(
|
|
47
|
+
setMinutes() {
|
|
48
48
|
return this.getTime();
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* @deprecated this method does not work on ImmutableDate
|
|
52
52
|
*/
|
|
53
|
-
setMonth(
|
|
53
|
+
setMonth() {
|
|
54
54
|
return this.getTime();
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* @deprecated this method does not work on ImmutableDate
|
|
58
58
|
*/
|
|
59
|
-
setSeconds(
|
|
59
|
+
setSeconds() {
|
|
60
60
|
return this.getTime();
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* @deprecated this method does not work on ImmutableDate
|
|
64
64
|
*/
|
|
65
|
-
setTime(
|
|
65
|
+
setTime() {
|
|
66
66
|
return this.getTime();
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* @deprecated this method does not work on ImmutableDate
|
|
70
70
|
*/
|
|
71
|
-
setUTCDate(
|
|
71
|
+
setUTCDate() {
|
|
72
72
|
return this.getTime();
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* @deprecated this method does not work on ImmutableDate
|
|
76
76
|
*/
|
|
77
|
-
setUTCFullYear(
|
|
77
|
+
setUTCFullYear() {
|
|
78
78
|
return this.getTime();
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* @deprecated this method does not work on ImmutableDate
|
|
82
82
|
*/
|
|
83
|
-
setUTCHours(
|
|
83
|
+
setUTCHours() {
|
|
84
84
|
return this.getTime();
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* @deprecated this method does not work on ImmutableDate
|
|
88
88
|
*/
|
|
89
|
-
setUTCMilliseconds(
|
|
89
|
+
setUTCMilliseconds() {
|
|
90
90
|
return this.getTime();
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* @deprecated this method does not work on ImmutableDate
|
|
94
94
|
*/
|
|
95
|
-
setUTCMinutes(
|
|
95
|
+
setUTCMinutes() {
|
|
96
96
|
return this.getTime();
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* @deprecated this method does not work on ImmutableDate
|
|
100
100
|
*/
|
|
101
|
-
setUTCMonth(
|
|
101
|
+
setUTCMonth() {
|
|
102
102
|
return this.getTime();
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* @deprecated this method does not work on ImmutableDate
|
|
106
106
|
*/
|
|
107
|
-
setUTCSeconds(
|
|
107
|
+
setUTCSeconds() {
|
|
108
108
|
return this.getTime();
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* @internal
|
|
112
|
-
* @deprecated use DChrono.createDate | DChrono.createDateOrThrow function
|
|
113
112
|
*/
|
|
114
113
|
static "new"(timestamp) {
|
|
115
114
|
return new TheDate(require_makeSafeTimestamp.makeSafeTimestamp(timestamp));
|
package/dist/chrono/theDate.d.ts
CHANGED
|
@@ -9,62 +9,62 @@ export declare class TheDate extends TheDate_base {
|
|
|
9
9
|
/**
|
|
10
10
|
* @deprecated this method does not work on ImmutableDate
|
|
11
11
|
*/
|
|
12
|
-
setDate(
|
|
12
|
+
setDate(): number;
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated this method does not work on ImmutableDate
|
|
15
15
|
*/
|
|
16
|
-
setFullYear(
|
|
16
|
+
setFullYear(): number;
|
|
17
17
|
/**
|
|
18
18
|
* @deprecated this method does not work on ImmutableDate
|
|
19
19
|
*/
|
|
20
|
-
setHours(
|
|
20
|
+
setHours(): number;
|
|
21
21
|
/**
|
|
22
22
|
* @deprecated this method does not work on ImmutableDate
|
|
23
23
|
*/
|
|
24
|
-
setMilliseconds(
|
|
24
|
+
setMilliseconds(): number;
|
|
25
25
|
/**
|
|
26
26
|
* @deprecated this method does not work on ImmutableDate
|
|
27
27
|
*/
|
|
28
|
-
setMinutes(
|
|
28
|
+
setMinutes(): number;
|
|
29
29
|
/**
|
|
30
30
|
* @deprecated this method does not work on ImmutableDate
|
|
31
31
|
*/
|
|
32
|
-
setMonth(
|
|
32
|
+
setMonth(): number;
|
|
33
33
|
/**
|
|
34
34
|
* @deprecated this method does not work on ImmutableDate
|
|
35
35
|
*/
|
|
36
|
-
setSeconds(
|
|
36
|
+
setSeconds(): number;
|
|
37
37
|
/**
|
|
38
38
|
* @deprecated this method does not work on ImmutableDate
|
|
39
39
|
*/
|
|
40
|
-
setTime(
|
|
40
|
+
setTime(): number;
|
|
41
41
|
/**
|
|
42
42
|
* @deprecated this method does not work on ImmutableDate
|
|
43
43
|
*/
|
|
44
|
-
setUTCDate(
|
|
44
|
+
setUTCDate(): number;
|
|
45
45
|
/**
|
|
46
46
|
* @deprecated this method does not work on ImmutableDate
|
|
47
47
|
*/
|
|
48
|
-
setUTCFullYear(
|
|
48
|
+
setUTCFullYear(): number;
|
|
49
49
|
/**
|
|
50
50
|
* @deprecated this method does not work on ImmutableDate
|
|
51
51
|
*/
|
|
52
|
-
setUTCHours(
|
|
52
|
+
setUTCHours(): number;
|
|
53
53
|
/**
|
|
54
54
|
* @deprecated this method does not work on ImmutableDate
|
|
55
55
|
*/
|
|
56
|
-
setUTCMilliseconds(
|
|
56
|
+
setUTCMilliseconds(): number;
|
|
57
57
|
/**
|
|
58
58
|
* @deprecated this method does not work on ImmutableDate
|
|
59
59
|
*/
|
|
60
|
-
setUTCMinutes(
|
|
60
|
+
setUTCMinutes(): number;
|
|
61
61
|
/**
|
|
62
62
|
* @deprecated this method does not work on ImmutableDate
|
|
63
63
|
*/
|
|
64
|
-
setUTCMonth(
|
|
64
|
+
setUTCMonth(): number;
|
|
65
65
|
/**
|
|
66
66
|
* @deprecated this method does not work on ImmutableDate
|
|
67
67
|
*/
|
|
68
|
-
setUTCSeconds(
|
|
68
|
+
setUTCSeconds(): number;
|
|
69
69
|
}
|
|
70
70
|
export {};
|
package/dist/chrono/theDate.mjs
CHANGED
|
@@ -20,96 +20,95 @@ var TheDate = class TheDate extends parentClass(createKind("the-date"), Date) {
|
|
|
20
20
|
/**
|
|
21
21
|
* @deprecated this method does not work on ImmutableDate
|
|
22
22
|
*/
|
|
23
|
-
setDate(
|
|
23
|
+
setDate() {
|
|
24
24
|
return this.getTime();
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* @deprecated this method does not work on ImmutableDate
|
|
28
28
|
*/
|
|
29
|
-
setFullYear(
|
|
29
|
+
setFullYear() {
|
|
30
30
|
return this.getTime();
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* @deprecated this method does not work on ImmutableDate
|
|
34
34
|
*/
|
|
35
|
-
setHours(
|
|
35
|
+
setHours() {
|
|
36
36
|
return this.getTime();
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* @deprecated this method does not work on ImmutableDate
|
|
40
40
|
*/
|
|
41
|
-
setMilliseconds(
|
|
41
|
+
setMilliseconds() {
|
|
42
42
|
return this.getTime();
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* @deprecated this method does not work on ImmutableDate
|
|
46
46
|
*/
|
|
47
|
-
setMinutes(
|
|
47
|
+
setMinutes() {
|
|
48
48
|
return this.getTime();
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* @deprecated this method does not work on ImmutableDate
|
|
52
52
|
*/
|
|
53
|
-
setMonth(
|
|
53
|
+
setMonth() {
|
|
54
54
|
return this.getTime();
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* @deprecated this method does not work on ImmutableDate
|
|
58
58
|
*/
|
|
59
|
-
setSeconds(
|
|
59
|
+
setSeconds() {
|
|
60
60
|
return this.getTime();
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* @deprecated this method does not work on ImmutableDate
|
|
64
64
|
*/
|
|
65
|
-
setTime(
|
|
65
|
+
setTime() {
|
|
66
66
|
return this.getTime();
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* @deprecated this method does not work on ImmutableDate
|
|
70
70
|
*/
|
|
71
|
-
setUTCDate(
|
|
71
|
+
setUTCDate() {
|
|
72
72
|
return this.getTime();
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* @deprecated this method does not work on ImmutableDate
|
|
76
76
|
*/
|
|
77
|
-
setUTCFullYear(
|
|
77
|
+
setUTCFullYear() {
|
|
78
78
|
return this.getTime();
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* @deprecated this method does not work on ImmutableDate
|
|
82
82
|
*/
|
|
83
|
-
setUTCHours(
|
|
83
|
+
setUTCHours() {
|
|
84
84
|
return this.getTime();
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* @deprecated this method does not work on ImmutableDate
|
|
88
88
|
*/
|
|
89
|
-
setUTCMilliseconds(
|
|
89
|
+
setUTCMilliseconds() {
|
|
90
90
|
return this.getTime();
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* @deprecated this method does not work on ImmutableDate
|
|
94
94
|
*/
|
|
95
|
-
setUTCMinutes(
|
|
95
|
+
setUTCMinutes() {
|
|
96
96
|
return this.getTime();
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
99
|
* @deprecated this method does not work on ImmutableDate
|
|
100
100
|
*/
|
|
101
|
-
setUTCMonth(
|
|
101
|
+
setUTCMonth() {
|
|
102
102
|
return this.getTime();
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* @deprecated this method does not work on ImmutableDate
|
|
106
106
|
*/
|
|
107
|
-
setUTCSeconds(
|
|
107
|
+
setUTCSeconds() {
|
|
108
108
|
return this.getTime();
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
111
|
* @internal
|
|
112
|
-
* @deprecated use DChrono.createDate | DChrono.createDateOrThrow function
|
|
113
112
|
*/
|
|
114
113
|
static "new"(timestamp) {
|
|
115
114
|
return new TheDate(makeSafeTimestamp(timestamp));
|
package/dist/chrono/theTime.cjs
CHANGED
|
@@ -21,7 +21,6 @@ var TheTime = class TheTime extends require_parentClass.parentClass(require_kind
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* @internal
|
|
24
|
-
* @deprecated use DDate.createTime | DDate.createTimeOrThrow function
|
|
25
24
|
*/
|
|
26
25
|
static "new"(time) {
|
|
27
26
|
return new TheTime(require_makeSafeTimeValue.makeSafeTimeValue(time));
|
package/dist/chrono/theTime.mjs
CHANGED
|
@@ -7,6 +7,10 @@ export interface ComputeCastConstraintStringRule<GenericValue extends string, Ge
|
|
|
7
7
|
maxCharacters: GenericExpectedConstraint extends DString.MaxCharacters<number> ? DCommon.NeverCoalescing<(DString.ComputeMaxCharactersCompatibility<GenericValue, GenericExpectedConstraint, unknown> extends infer InferredResult extends CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends CompatibilityConstraintResult<true> ? unknown : DCommon.IsNever<DString.ExtractLengthEqual<GenericValue>> extends true ? CastError<`Impossible to cast on MaxCharacters<${InferredResult["to"]}> because constraint MaxCharacters<${InferredResult["from"]}> from the value is more than.`, GenericValue, GenericExpectedConstraint> : CastError<`Impossible to cast on MaxCharacters<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is more than.`, GenericValue, GenericExpectedConstraint> : never), CastError<"Impossible to cast on MaxCharacters because value does not have MaxCharacters constraint.", GenericValue, GenericExpectedConstraint>> : never;
|
|
8
8
|
minCharacters: GenericExpectedConstraint extends DString.MinCharacters<number> ? DCommon.NeverCoalescing<(DString.ComputeMinCharactersCompatibility<GenericValue, GenericExpectedConstraint, unknown> extends infer InferredResult extends CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends CompatibilityConstraintResult<true> ? unknown : DCommon.IsNever<DString.ExtractLengthEqual<GenericValue>> extends true ? CastError<`Impossible to cast on MinCharacters<${InferredResult["to"]}> because constraint MinCharacters<${InferredResult["from"]}> from the value is less than.`, GenericValue, GenericExpectedConstraint> : CastError<`Impossible to cast on MinCharacters<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is less than.`, GenericValue, GenericExpectedConstraint> : never), CastError<"Impossible to cast on MinCharacters because value does not have MinCharacters constraint.", GenericValue, GenericExpectedConstraint>> : never;
|
|
9
9
|
lengthEqual: GenericExpectedConstraint extends DString.LengthEqual<number> ? DCommon.NeverCoalescing<(DString.ComputeLengthEqualCompatibility<GenericValue, GenericExpectedConstraint, unknown> extends infer InferredResult extends CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends CompatibilityConstraintResult<true> ? unknown : CastError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`, GenericValue, GenericExpectedConstraint> : never), CastError<"Impossible to cast on LengthEqual because value does not have LengthEqual constraint.", GenericValue, GenericExpectedConstraint>> : never;
|
|
10
|
+
number: DCommon.IsExtends<GenericExpectedConstraint, DString.Number> extends true ? DCommon.Or<[
|
|
11
|
+
DCommon.IsExtends<GenericValue, DString.NumberInString>,
|
|
12
|
+
DCommon.IsExtends<GenericValue, DString.Number>
|
|
13
|
+
]> extends true ? unknown : CastError<`Impossible to cast on Number because value ${GenericValue} is not a number.`, GenericValue, GenericExpectedConstraint> : never;
|
|
10
14
|
path: DCommon.IsExtends<GenericExpectedConstraint, DPath.Path> extends true ? DCommon.Or<[
|
|
11
15
|
DPath.IsLiteralPath<GenericValue>,
|
|
12
16
|
DCommon.IsExtends<GenericValue, DPath.Path | DPath.Absolute | DPath.Segment>
|
|
@@ -5,6 +5,7 @@ export interface ComputeInferConstraintStringRule<GenericInput extends string, G
|
|
|
5
5
|
maxCharacters: DString.ComputeMaxCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.MaxCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MaxCharacters<${InferredResult["to"]}> because constraint MaxCharacters<${InferredResult["from"]}> from the value is more than.`> : never;
|
|
6
6
|
minCharacters: DString.ComputeMinCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.MinCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MinCharacters<${InferredResult["to"]}> because constraint MinCharacters<${InferredResult["from"]}> from the value is less than.`> : never;
|
|
7
7
|
lengthEqual: DString.ComputeLengthEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? DString.LengthEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`> : never;
|
|
8
|
+
number: DCommon.IsExtends<GenericOutput, DString.Number> extends true ? GenericInput extends DString.NumberInString ? DString.Number : DCommon.ComputedTypeError<`Impossible to cast on Number because value ${GenericInput} is not a number.`> : never;
|
|
8
9
|
path: DCommon.IsExtends<GenericOutput, DPath.Path> extends true ? DPath.IsLiteralPath<GenericInput> extends true ? DPath.Path : DCommon.ComputedTypeError<`Impossible to cast on Path because value ${GenericInput} is not path.`> : never;
|
|
9
10
|
absolutePath: DCommon.IsExtends<GenericOutput, DPath.Absolute> extends true ? DPath.IsLiteralAbsolutePath<GenericInput> extends true ? DPath.Absolute : DCommon.ComputedTypeError<`Impossible to cast on AbsolutePath because value ${GenericInput} is not absolute path.`> : never;
|
|
10
11
|
segment: DCommon.IsExtends<GenericOutput, DPath.Segment> extends true ? DPath.IsLiteralSegmentPath<GenericInput> extends true ? DPath.Segment : DCommon.ComputedTypeError<`Impossible to cast on SegmentPath because value ${GenericInput} is not segment path.`> : never;
|
package/dist/common/isType.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RemoveConstraint } from './constraint';
|
|
1
2
|
import { IsEqual, AnyFunction, AnyValue, BreakGenericLink } from './types';
|
|
2
3
|
interface Type {
|
|
3
4
|
string: [string, never];
|
|
@@ -17,6 +18,6 @@ type ComputeResult<GenericInput extends unknown, GenericTypeEntry extends Type[k
|
|
|
17
18
|
type EligibleType<GenericInput extends unknown> = {
|
|
18
19
|
[Prop in keyof Type]: IsEqual<ComputeResult<GenericInput, Type[Prop]>, never> extends true ? never : Prop;
|
|
19
20
|
}[keyof Type];
|
|
20
|
-
export declare function isType<GenericInput extends AnyValue, GenericType extends EligibleType<GenericInput
|
|
21
|
-
export declare function isType<GenericInput extends AnyValue, GenericType extends EligibleType<GenericInput
|
|
21
|
+
export declare function isType<GenericInput extends AnyValue, GenericType extends EligibleType<RemoveConstraint<GenericInput>>>(type: GenericType): (input: GenericInput) => input is ComputeResult<BreakGenericLink<GenericInput>, Type[GenericType]>;
|
|
22
|
+
export declare function isType<GenericInput extends AnyValue, GenericType extends EligibleType<RemoveConstraint<GenericInput>>>(input: GenericInput, type: GenericType): input is ComputeResult<GenericInput, Type[GenericType]>;
|
|
22
23
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_callThen = require("
|
|
2
|
-
const require_memo = require("
|
|
3
|
-
const require_kind = require("
|
|
4
|
-
const require_resultSymbol = require("
|
|
5
|
-
//#region scripts/dataStructure/common/codec.ts
|
|
1
|
+
const require_callThen = require("../../../common/callThen.cjs");
|
|
2
|
+
const require_memo = require("../../../common/memo.cjs");
|
|
3
|
+
const require_kind = require("../../kind.cjs");
|
|
4
|
+
const require_resultSymbol = require("../resultSymbol.cjs");
|
|
5
|
+
//#region scripts/dataStructure/common/codec/base.ts
|
|
6
6
|
const codecKind = require_kind.createKind("codec");
|
|
7
7
|
const codecsKind = require_kind.createKind("codecs");
|
|
8
8
|
function createCodec(fundamentalType, predicateEncode, encode, decode) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FundamentalTypeValue, FundamentalType } from '
|
|
2
|
-
import { GetErrorHandler } from '
|
|
3
|
-
import { ErrorSymbol } from '
|
|
4
|
-
import type * as DKind from '
|
|
5
|
-
import * as DCommon from '
|
|
6
|
-
import type * as DObject from '
|
|
1
|
+
import { FundamentalTypeValue, FundamentalType } from '../../fundamentalType';
|
|
2
|
+
import { GetErrorHandler } from '../error';
|
|
3
|
+
import { ErrorSymbol } from '../resultSymbol';
|
|
4
|
+
import type * as DKind from '../../../kind';
|
|
5
|
+
import * as DCommon from '../../../common';
|
|
6
|
+
import type * as DObject from '../../../object';
|
|
7
7
|
export declare const codecKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/codec", unknown>>;
|
|
8
8
|
export interface Codec<GenericFundamentalType extends FundamentalType = FundamentalType, GenericEncodedValue extends unknown = unknown> extends DKind.Kind<typeof codecKind> {
|
|
9
9
|
readonly fundamentalType: GenericFundamentalType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { callThen } from "
|
|
2
|
-
import { memo } from "
|
|
3
|
-
import { createKind } from "
|
|
4
|
-
import { ErrorSymbol } from "
|
|
5
|
-
//#region scripts/dataStructure/common/codec.ts
|
|
1
|
+
import { callThen } from "../../../common/callThen.mjs";
|
|
2
|
+
import { memo } from "../../../common/memo.mjs";
|
|
3
|
+
import { createKind } from "../../kind.mjs";
|
|
4
|
+
import { ErrorSymbol } from "../resultSymbol.mjs";
|
|
5
|
+
//#region scripts/dataStructure/common/codec/base.ts
|
|
6
6
|
const codecKind = createKind("codec");
|
|
7
7
|
const codecsKind = createKind("codecs");
|
|
8
8
|
function createCodec(fundamentalType, predicateEncode, encode, decode) {
|