@duplojs/utils 1.4.57 → 1.4.58
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/clean/constraint/base.d.ts +6 -4
- package/dist/clean/constraint/defaultConstraint/index.d.ts +1 -0
- package/dist/clean/constraint/defaultConstraint/number.d.ts +6 -6
- package/dist/clean/constraint/defaultConstraint/string.d.ts +4 -4
- package/dist/clean/constraint/defaultConstraint/time.cjs +19 -0
- package/dist/clean/constraint/defaultConstraint/time.d.ts +61 -0
- package/dist/clean/constraint/defaultConstraint/time.mjs +16 -0
- package/dist/clean/constraint/set.d.ts +6 -4
- package/dist/clean/entity.d.ts +2 -1
- package/dist/clean/index.cjs +3 -0
- package/dist/clean/index.mjs +1 -0
- package/dist/clean/newType.d.ts +7 -5
- package/dist/clean/primitive/base.d.ts +25 -34
- package/dist/clean/primitive/operations/date/dateAddTime.d.ts +7 -11
- package/dist/clean/primitive/operations/date/dateGreaterThan.d.ts +9 -7
- package/dist/clean/primitive/operations/date/dateLessThan.d.ts +9 -7
- package/dist/clean/primitive/operations/date/dateMax.d.ts +3 -10
- package/dist/clean/primitive/operations/date/dateMin.d.ts +3 -10
- package/dist/clean/primitive/operations/date/dateSubtractTime.d.ts +7 -11
- package/dist/clean/primitive/operations/equal.cjs +1 -1
- package/dist/clean/primitive/operations/equal.d.ts +3 -3
- package/dist/clean/primitive/operations/equal.mjs +1 -1
- package/dist/clean/primitive/operations/sort.d.ts +8 -10
- package/dist/clean/primitive/operations/time/timeGreaterThan.d.ts +11 -9
- package/dist/clean/primitive/operations/time/timeLessThan.d.ts +11 -9
- package/dist/clean/primitive/operations/time/timeMax.cjs +2 -2
- package/dist/clean/primitive/operations/time/timeMax.d.ts +10 -17
- package/dist/clean/primitive/operations/time/timeMax.mjs +2 -2
- package/dist/clean/primitive/operations/time/timeMin.cjs +3 -3
- package/dist/clean/primitive/operations/time/timeMin.d.ts +10 -17
- package/dist/clean/primitive/operations/time/timeMin.mjs +3 -3
- package/dist/clean/unwrapEntity.cjs +13 -3
- package/dist/clean/unwrapEntity.d.ts +57 -5
- package/dist/clean/unwrapEntity.mjs +13 -3
- package/dist/common/index.d.ts +2 -4
- package/dist/common/kind.d.ts +1 -0
- package/dist/common/transformer.cjs +45 -0
- package/dist/common/transformer.d.ts +61 -0
- package/dist/common/transformer.mjs +40 -0
- package/dist/common/types/DeepReadonly.d.ts +1 -1
- package/dist/common/types/toLargeEnsemble.d.ts +2 -2
- package/dist/dataParser/extended/date.d.ts +9 -4
- package/dist/dataParser/extended/time.d.ts +28 -12
- package/dist/dataParser/identifier.d.ts +20 -8
- package/dist/dataParser/parsers/date.cjs +16 -12
- package/dist/dataParser/parsers/date.d.ts +15 -9
- package/dist/dataParser/parsers/date.mjs +16 -12
- package/dist/dataParser/parsers/time/checkers/max.cjs +3 -0
- package/dist/dataParser/parsers/time/checkers/max.d.ts +28 -0
- package/dist/dataParser/parsers/time/checkers/max.mjs +3 -0
- package/dist/dataParser/parsers/time/checkers/min.cjs +3 -0
- package/dist/dataParser/parsers/time/checkers/min.d.ts +28 -0
- package/dist/dataParser/parsers/time/checkers/min.mjs +3 -0
- package/dist/dataParser/parsers/time/index.cjs +14 -10
- package/dist/dataParser/parsers/time/index.d.ts +15 -9
- package/dist/dataParser/parsers/time/index.mjs +14 -10
- package/dist/date/applyTimezone.cjs +4 -4
- package/dist/date/applyTimezone.d.ts +18 -16
- package/dist/date/applyTimezone.mjs +2 -2
- package/dist/date/closestTo.cjs +6 -2
- package/dist/date/closestTo.d.ts +15 -15
- package/dist/date/closestTo.mjs +6 -2
- package/dist/date/constants.cjs +4 -4
- package/dist/date/constants.d.ts +2 -2
- package/dist/date/constants.mjs +3 -3
- package/dist/date/create.cjs +20 -10
- package/dist/date/create.d.ts +24 -38
- package/dist/date/create.mjs +21 -11
- package/dist/date/createOrThrow.d.ts +18 -20
- package/dist/date/createTime.cjs +16 -7
- package/dist/date/createTime.d.ts +19 -18
- package/dist/date/createTime.mjs +17 -8
- package/dist/date/createTimeOrThrow.d.ts +17 -20
- package/dist/date/each.cjs +6 -4
- package/dist/date/each.d.ts +21 -19
- package/dist/date/each.mjs +6 -4
- package/dist/date/format.d.ts +17 -15
- package/dist/date/formatTime.d.ts +17 -16
- package/dist/date/getTimezoneOffset.cjs +6 -3
- package/dist/date/getTimezoneOffset.d.ts +17 -18
- package/dist/date/getTimezoneOffset.mjs +6 -3
- package/dist/date/getters/getDayOfMonth.cjs +3 -3
- package/dist/date/getters/getDayOfMonth.d.ts +20 -14
- package/dist/date/getters/getDayOfMonth.mjs +3 -3
- package/dist/date/getters/getDayOfWeek.cjs +3 -3
- package/dist/date/getters/getDayOfWeek.d.ts +15 -12
- package/dist/date/getters/getDayOfWeek.mjs +3 -3
- package/dist/date/getters/getDayOfYear.cjs +6 -6
- package/dist/date/getters/getDayOfYear.d.ts +21 -13
- package/dist/date/getters/getDayOfYear.mjs +6 -6
- package/dist/date/getters/getFirstDayOfMonth.cjs +2 -3
- package/dist/date/getters/getFirstDayOfMonth.d.ts +16 -10
- package/dist/date/getters/getFirstDayOfMonth.mjs +2 -3
- package/dist/date/getters/getFirstDayOfWeek.cjs +2 -3
- package/dist/date/getters/getFirstDayOfWeek.d.ts +17 -10
- package/dist/date/getters/getFirstDayOfWeek.mjs +2 -3
- package/dist/date/getters/getHour.cjs +3 -3
- package/dist/date/getters/getHour.d.ts +16 -14
- package/dist/date/getters/getHour.mjs +3 -3
- package/dist/date/getters/getLastDayOfMonth.cjs +2 -3
- package/dist/date/getters/getLastDayOfMonth.d.ts +16 -10
- package/dist/date/getters/getLastDayOfMonth.mjs +2 -3
- package/dist/date/getters/getLastDayOfWeek.cjs +2 -3
- package/dist/date/getters/getLastDayOfWeek.d.ts +17 -10
- package/dist/date/getters/getLastDayOfWeek.mjs +2 -3
- package/dist/date/getters/getMilliseconds.cjs +2 -2
- package/dist/date/getters/getMilliseconds.d.ts +11 -9
- package/dist/date/getters/getMilliseconds.mjs +2 -2
- package/dist/date/getters/getMinute.cjs +3 -3
- package/dist/date/getters/getMinute.d.ts +17 -15
- package/dist/date/getters/getMinute.mjs +3 -3
- package/dist/date/getters/getMonth.cjs +3 -3
- package/dist/date/getters/getMonth.d.ts +20 -15
- package/dist/date/getters/getMonth.mjs +3 -3
- package/dist/date/getters/getSecond.cjs +3 -3
- package/dist/date/getters/getSecond.d.ts +17 -15
- package/dist/date/getters/getSecond.mjs +3 -3
- package/dist/date/getters/getWeekOfYear.cjs +12 -11
- package/dist/date/getters/getWeekOfYear.d.ts +17 -11
- package/dist/date/getters/getWeekOfYear.mjs +12 -11
- package/dist/date/getters/getYear.cjs +3 -3
- package/dist/date/getters/getYear.d.ts +16 -15
- package/dist/date/getters/getYear.mjs +3 -3
- package/dist/date/index.cjs +12 -6
- package/dist/date/index.d.ts +5 -2
- package/dist/date/index.mjs +6 -3
- package/dist/date/is.cjs +3 -8
- package/dist/date/is.d.ts +9 -14
- package/dist/date/is.mjs +3 -8
- package/dist/date/isSafeTimeValue.d.ts +9 -13
- package/dist/date/isSafeTimestamp.d.ts +7 -16
- package/dist/date/isSerializedTheDate.cjs +20 -0
- package/dist/date/isSerializedTheDate.d.ts +31 -0
- package/dist/date/isSerializedTheDate.mjs +18 -0
- package/dist/date/isSerializedTheTime.cjs +20 -0
- package/dist/date/isSerializedTheTime.d.ts +31 -0
- package/dist/date/isSerializedTheTime.mjs +18 -0
- package/dist/date/isTime.cjs +3 -8
- package/dist/date/isTime.d.ts +7 -14
- package/dist/date/isTime.mjs +3 -8
- package/dist/date/kind.cjs +9 -0
- package/dist/date/kind.d.ts +1 -0
- package/dist/date/kind.mjs +7 -0
- package/dist/date/makeSafeTimeValue.d.ts +12 -11
- package/dist/date/makeSafeTimestamp.d.ts +12 -11
- package/dist/date/max.cjs +2 -2
- package/dist/date/max.d.ts +13 -13
- package/dist/date/max.mjs +2 -2
- package/dist/date/maxTime.cjs +2 -2
- package/dist/date/maxTime.d.ts +13 -21
- package/dist/date/maxTime.mjs +2 -2
- package/dist/date/min.cjs +2 -2
- package/dist/date/min.d.ts +13 -13
- package/dist/date/min.mjs +2 -2
- package/dist/date/minTime.cjs +2 -2
- package/dist/date/minTime.d.ts +13 -21
- package/dist/date/minTime.mjs +2 -2
- package/dist/date/now.cjs +3 -1
- package/dist/date/now.d.ts +9 -7
- package/dist/date/now.mjs +3 -1
- package/dist/date/operators/addDays.cjs +3 -5
- package/dist/date/operators/addDays.d.ts +14 -11
- package/dist/date/operators/addDays.mjs +3 -5
- package/dist/date/operators/addHours.cjs +3 -5
- package/dist/date/operators/addHours.d.ts +14 -11
- package/dist/date/operators/addHours.mjs +3 -5
- package/dist/date/operators/addMilliseconds.cjs +3 -5
- package/dist/date/operators/addMilliseconds.d.ts +14 -11
- package/dist/date/operators/addMilliseconds.mjs +3 -5
- package/dist/date/operators/addMinutes.cjs +3 -5
- package/dist/date/operators/addMinutes.d.ts +14 -11
- package/dist/date/operators/addMinutes.mjs +3 -5
- package/dist/date/operators/addMonths.cjs +2 -2
- package/dist/date/operators/addMonths.d.ts +13 -13
- package/dist/date/operators/addMonths.mjs +2 -2
- package/dist/date/operators/addSeconds.cjs +3 -5
- package/dist/date/operators/addSeconds.d.ts +14 -11
- package/dist/date/operators/addSeconds.mjs +3 -5
- package/dist/date/operators/addTime.cjs +13 -6
- package/dist/date/operators/addTime.d.ts +20 -18
- package/dist/date/operators/addTime.mjs +13 -6
- package/dist/date/operators/addWeeks.cjs +6 -5
- package/dist/date/operators/addWeeks.d.ts +14 -11
- package/dist/date/operators/addWeeks.mjs +6 -5
- package/dist/date/operators/addYears.cjs +2 -2
- package/dist/date/operators/addYears.d.ts +13 -13
- package/dist/date/operators/addYears.mjs +2 -2
- package/dist/date/operators/between.d.ts +11 -11
- package/dist/date/operators/betweenThan.d.ts +11 -11
- package/dist/date/operators/betweenThanTime.d.ts +18 -22
- package/dist/date/operators/betweenTime.d.ts +17 -21
- package/dist/date/operators/greater.d.ts +12 -9
- package/dist/date/operators/greaterThan.d.ts +14 -11
- package/dist/date/operators/greaterThanTime.d.ts +17 -21
- package/dist/date/operators/greaterTime.d.ts +16 -20
- package/dist/date/operators/less.d.ts +12 -9
- package/dist/date/operators/lessThan.d.ts +13 -10
- package/dist/date/operators/lessThanTime.d.ts +17 -21
- package/dist/date/operators/lessTime.d.ts +16 -20
- package/dist/date/operators/subtractDays.cjs +3 -5
- package/dist/date/operators/subtractDays.d.ts +14 -11
- package/dist/date/operators/subtractDays.mjs +3 -5
- package/dist/date/operators/subtractHours.cjs +3 -5
- package/dist/date/operators/subtractHours.d.ts +14 -11
- package/dist/date/operators/subtractHours.mjs +3 -5
- package/dist/date/operators/subtractMilliseconds.cjs +3 -5
- package/dist/date/operators/subtractMilliseconds.d.ts +14 -11
- package/dist/date/operators/subtractMilliseconds.mjs +3 -5
- package/dist/date/operators/subtractMinutes.cjs +3 -5
- package/dist/date/operators/subtractMinutes.d.ts +14 -11
- package/dist/date/operators/subtractMinutes.mjs +3 -5
- package/dist/date/operators/subtractMonths.cjs +2 -2
- package/dist/date/operators/subtractMonths.d.ts +17 -11
- package/dist/date/operators/subtractMonths.mjs +2 -2
- package/dist/date/operators/subtractSeconds.cjs +3 -5
- package/dist/date/operators/subtractSeconds.d.ts +14 -11
- package/dist/date/operators/subtractSeconds.mjs +3 -5
- package/dist/date/operators/subtractTime.cjs +13 -6
- package/dist/date/operators/subtractTime.d.ts +20 -18
- package/dist/date/operators/subtractTime.mjs +13 -6
- package/dist/date/operators/subtractWeeks.cjs +3 -5
- package/dist/date/operators/subtractWeeks.d.ts +14 -11
- package/dist/date/operators/subtractWeeks.mjs +3 -5
- package/dist/date/operators/subtractYears.cjs +2 -2
- package/dist/date/operators/subtractYears.d.ts +17 -11
- package/dist/date/operators/subtractYears.mjs +2 -2
- package/dist/date/round.cjs +2 -2
- package/dist/date/round.d.ts +11 -14
- package/dist/date/round.mjs +2 -2
- package/dist/date/serialize.cjs +14 -0
- package/dist/date/serialize.d.ts +41 -0
- package/dist/date/serialize.mjs +12 -0
- package/dist/date/sort.cjs +2 -2
- package/dist/date/sort.d.ts +16 -15
- package/dist/date/sort.mjs +2 -2
- package/dist/date/sortTimes.cjs +2 -2
- package/dist/date/sortTimes.d.ts +15 -21
- package/dist/date/sortTimes.mjs +2 -2
- package/dist/date/theDate.cjs +124 -0
- package/dist/date/theDate.d.ts +114 -0
- package/dist/date/theDate.mjs +122 -0
- package/dist/date/theTime.cjs +36 -0
- package/dist/date/theTime.d.ts +53 -0
- package/dist/date/theTime.mjs +34 -0
- package/dist/date/timezone.cjs +3 -0
- package/dist/date/timezone.d.ts +27 -0
- package/dist/date/timezone.mjs +3 -0
- package/dist/date/toISOString.cjs +5 -2
- package/dist/date/toISOString.d.ts +12 -10
- package/dist/date/toISOString.mjs +5 -2
- package/dist/date/toNative.cjs +4 -0
- package/dist/date/toNative.d.ts +12 -10
- package/dist/date/toNative.mjs +4 -0
- package/dist/date/toTimeValue.cjs +6 -2
- package/dist/date/toTimeValue.d.ts +14 -12
- package/dist/date/toTimeValue.mjs +6 -2
- package/dist/date/toTimestamp.cjs +5 -3
- package/dist/date/toTimestamp.d.ts +11 -9
- package/dist/date/toTimestamp.mjs +6 -4
- package/dist/date/today.cjs +3 -1
- package/dist/date/today.d.ts +14 -7
- package/dist/date/today.mjs +3 -1
- package/dist/date/tomorrow.cjs +2 -1
- package/dist/date/tomorrow.d.ts +12 -7
- package/dist/date/tomorrow.mjs +2 -1
- package/dist/date/types/index.d.ts +2 -2
- package/dist/date/types/serializedTheDate.d.ts +1 -0
- package/dist/date/types/serializedTheTime.d.ts +42 -0
- package/dist/date/types/spoolingDate.d.ts +2 -1
- package/dist/date/yesterday.cjs +2 -1
- package/dist/date/yesterday.d.ts +12 -7
- package/dist/date/yesterday.mjs +2 -1
- package/dist/index.cjs +5 -6
- package/dist/index.mjs +1 -3
- package/dist/metadata.json +73 -46
- package/package.json +1 -1
- package/dist/common/toJSON.cjs +0 -37
- package/dist/common/toJSON.d.ts +0 -44
- package/dist/common/toJSON.mjs +0 -35
- package/dist/common/toString.cjs +0 -10
- package/dist/common/toString.d.ts +0 -17
- package/dist/common/toString.mjs +0 -8
- package/dist/common/toTransform.cjs +0 -37
- package/dist/common/toTransform.d.ts +0 -50
- package/dist/common/toTransform.mjs +0 -35
- package/dist/date/createTheDate.cjs +0 -13
- package/dist/date/createTheDate.d.ts +0 -28
- package/dist/date/createTheDate.mjs +0 -11
- package/dist/date/createTheTime.cjs +0 -13
- package/dist/date/createTheTime.d.ts +0 -25
- package/dist/date/createTheTime.mjs +0 -11
- package/dist/date/types/theDate.d.ts +0 -11
- package/dist/date/types/theTime.d.ts +0 -10
package/dist/date/tomorrow.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants.cjs');
|
|
4
|
+
var theDate = require('./theDate.cjs');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* {@include date/tomorrow/index.md}
|
|
7
8
|
*/
|
|
8
9
|
function tomorrow() {
|
|
9
10
|
const timestamp = Date.now() + constants.millisecondsInOneDay;
|
|
10
|
-
return
|
|
11
|
+
return theDate.TheDate.new(timestamp);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
exports.tomorrow = tomorrow;
|
package/dist/date/tomorrow.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import { TheDate } from "./theDate";
|
|
1
2
|
/**
|
|
2
|
-
* Returns
|
|
3
|
+
* Returns an instant approximately one day after now as `TheDate`.
|
|
3
4
|
*
|
|
4
|
-
* Signature: `tomorrow()` →
|
|
5
|
-
*
|
|
6
|
-
* The input value is not mutated.
|
|
5
|
+
* Signature: `tomorrow()` → `TheDate`
|
|
7
6
|
*
|
|
8
7
|
* ```ts
|
|
9
|
-
* const
|
|
10
|
-
* //
|
|
8
|
+
* const value = D.tomorrow();
|
|
9
|
+
* // value: TheDate
|
|
10
|
+
*
|
|
11
|
+
* const iso = D.toISOString(value);
|
|
12
|
+
* // iso: string
|
|
11
13
|
*
|
|
12
14
|
* ```
|
|
13
15
|
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - Computed from current timestamp plus one day in milliseconds.
|
|
18
|
+
*
|
|
14
19
|
* @see https://utils.duplojs.dev/en/v1/api/date/tomorrow
|
|
15
20
|
*
|
|
16
21
|
* @namespace D
|
|
17
22
|
*
|
|
18
23
|
*/
|
|
19
|
-
export declare function tomorrow():
|
|
24
|
+
export declare function tomorrow(): TheDate;
|
package/dist/date/tomorrow.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { millisecondsInOneDay } from './constants.mjs';
|
|
2
|
+
import { TheDate } from './theDate.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* {@include date/tomorrow/index.md}
|
|
5
6
|
*/
|
|
6
7
|
function tomorrow() {
|
|
7
8
|
const timestamp = Date.now() + millisecondsInOneDay;
|
|
8
|
-
return
|
|
9
|
+
return TheDate.new(timestamp);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export { tomorrow };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./serializedTheDate";
|
|
2
2
|
export * from "./isLeapYear";
|
|
3
3
|
export * from "./unit";
|
|
4
4
|
export * from "./month";
|
|
5
5
|
export * from "./time";
|
|
6
6
|
export * from "./isSafeYear";
|
|
7
7
|
export * from "./spoolingDate";
|
|
8
|
-
export * from "./
|
|
8
|
+
export * from "./serializedTheTime";
|
|
9
9
|
export * from "./spoolingTime";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SerializedTheDate = `date${number}${"-" | "+"}`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an immutable time value object (`TheTime`) stored in milliseconds.
|
|
3
|
+
*
|
|
4
|
+
* Signature: `TheTime` → immutable class-like value object
|
|
5
|
+
*
|
|
6
|
+
* `TheTime` solves unit-fragmentation issues (`hours`, `minutes`, `seconds`) by using a single safe millisecond representation while keeping strong typing and explicit serialization.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const theTime = D.createTime(2, "hour");
|
|
10
|
+
* // theTime: TheTime
|
|
11
|
+
*
|
|
12
|
+
* const timeValue = theTime.toNative();
|
|
13
|
+
* // timeValue: number
|
|
14
|
+
*
|
|
15
|
+
* const serialized = D.serialize(theTime);
|
|
16
|
+
* // serialized: SerializedTheTime
|
|
17
|
+
*
|
|
18
|
+
* const date = D.create("2025-10-20");
|
|
19
|
+
* const dateWithDuration = D.addTime(date, theTime);
|
|
20
|
+
* // dateWithDuration: TheDate
|
|
21
|
+
*
|
|
22
|
+
* const threeHours = D.createTime(3, "hour");
|
|
23
|
+
* // threeHours: TheTime
|
|
24
|
+
*
|
|
25
|
+
* const asMilliseconds = D.toTimeValue(theTime);
|
|
26
|
+
* // asMilliseconds: number
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* - `TheTime` is not a `number`, but it behaves as an immutable numeric time value.
|
|
31
|
+
* - Date unit operators (`addMinutes`, `subtractDays`, etc.) target `TheDate`; `TheTime` is used as a normalized duration value.
|
|
32
|
+
* - Use `D.serialize(theTime)` to convert to `SerializedTheTime`.
|
|
33
|
+
* - Use `D.createTime(...)` / `D.createTimeOrThrow(...)` to construct instances.
|
|
34
|
+
*
|
|
35
|
+
* @see https://utils.duplojs.dev/en/v1/api/date/theTime
|
|
36
|
+
* @see https://utils.duplojs.dev/en/v1/api/date/serialize
|
|
37
|
+
* @see https://utils.duplojs.dev/en/v1/api/date/createTime
|
|
38
|
+
*
|
|
39
|
+
* @namespace D
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export type SerializedTheTime = `time${number}${"+" | "-"}`;
|
package/dist/date/yesterday.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var constants = require('./constants.cjs');
|
|
4
|
+
var theDate = require('./theDate.cjs');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* {@include date/yesterday/index.md}
|
|
7
8
|
*/
|
|
8
9
|
function yesterday() {
|
|
9
10
|
const timestamp = Date.now() - constants.millisecondsInOneDay;
|
|
10
|
-
return
|
|
11
|
+
return theDate.TheDate.new(timestamp);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
exports.yesterday = yesterday;
|
package/dist/date/yesterday.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import { TheDate } from "./theDate";
|
|
1
2
|
/**
|
|
2
|
-
* Returns
|
|
3
|
+
* Returns an instant approximately one day before now as `TheDate`.
|
|
3
4
|
*
|
|
4
|
-
* Signature: `yesterday()` →
|
|
5
|
-
*
|
|
6
|
-
* The input value is not mutated.
|
|
5
|
+
* Signature: `yesterday()` → `TheDate`
|
|
7
6
|
*
|
|
8
7
|
* ```ts
|
|
9
|
-
* const
|
|
10
|
-
* //
|
|
8
|
+
* const value = D.yesterday();
|
|
9
|
+
* // value: TheDate
|
|
10
|
+
*
|
|
11
|
+
* const iso = D.toISOString(value);
|
|
12
|
+
* // iso: string
|
|
11
13
|
*
|
|
12
14
|
* ```
|
|
13
15
|
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - Computed from current timestamp minus one day in milliseconds.
|
|
18
|
+
*
|
|
14
19
|
* @see https://utils.duplojs.dev/en/v1/api/date/yesterday
|
|
15
20
|
*
|
|
16
21
|
* @namespace D
|
|
17
22
|
*
|
|
18
23
|
*/
|
|
19
|
-
export declare function yesterday():
|
|
24
|
+
export declare function yesterday(): TheDate;
|
package/dist/date/yesterday.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { millisecondsInOneDay } from './constants.mjs';
|
|
2
|
+
import { TheDate } from './theDate.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* {@include date/yesterday/index.md}
|
|
5
6
|
*/
|
|
6
7
|
function yesterday() {
|
|
7
8
|
const timestamp = Date.now() - millisecondsInOneDay;
|
|
8
|
-
return
|
|
9
|
+
return TheDate.new(timestamp);
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export { yesterday };
|
package/dist/index.cjs
CHANGED
|
@@ -27,15 +27,12 @@ var sleep = require('./common/sleep.cjs');
|
|
|
27
27
|
var stringToBytes = require('./common/stringToBytes.cjs');
|
|
28
28
|
var mimeType = require('./common/mimeType.cjs');
|
|
29
29
|
var stringToMillisecond = require('./common/stringToMillisecond.cjs');
|
|
30
|
-
var toJSON = require('./common/toJSON.cjs');
|
|
31
|
-
var toTransform = require('./common/toTransform.cjs');
|
|
32
30
|
var toWrappedValue = require('./common/toWrappedValue.cjs');
|
|
33
31
|
var unwrap = require('./common/unwrap.cjs');
|
|
34
32
|
var unwrapGroup = require('./common/unwrapGroup.cjs');
|
|
35
33
|
var asyncLoop = require('./common/asyncLoop.cjs');
|
|
36
34
|
var asyncRetry = require('./common/asyncRetry.cjs');
|
|
37
35
|
var wrapValue = require('./common/wrapValue.cjs');
|
|
38
|
-
var toString = require('./common/toString.cjs');
|
|
39
36
|
var innerPipe = require('./common/innerPipe.cjs');
|
|
40
37
|
var asyncInnerPipe = require('./common/asyncInnerPipe.cjs');
|
|
41
38
|
var loop = require('./common/loop.cjs');
|
|
@@ -65,6 +62,7 @@ var toCurriedPredicate = require('./common/toCurriedPredicate.cjs');
|
|
|
65
62
|
var pipeCall = require('./common/pipeCall.cjs');
|
|
66
63
|
var asserts = require('./common/asserts.cjs');
|
|
67
64
|
var path = require('./common/path.cjs');
|
|
65
|
+
var transformer = require('./common/transformer.cjs');
|
|
68
66
|
|
|
69
67
|
|
|
70
68
|
|
|
@@ -113,8 +111,6 @@ exports.stringToBytes = stringToBytes.stringToBytes;
|
|
|
113
111
|
exports.mimeType = mimeType.mimeType;
|
|
114
112
|
exports.InvalidMillisecondInStringError = stringToMillisecond.InvalidMillisecondInStringError;
|
|
115
113
|
exports.stringToMillisecond = stringToMillisecond.stringToMillisecond;
|
|
116
|
-
exports.toJSON = toJSON.toJSON;
|
|
117
|
-
exports.toTransform = toTransform.toTransform;
|
|
118
114
|
exports.toWrappedValue = toWrappedValue.toWrappedValue;
|
|
119
115
|
exports.unwrap = unwrap.unwrap;
|
|
120
116
|
exports.unwrapGroup = unwrapGroup.unwrapGroup;
|
|
@@ -125,7 +121,6 @@ exports.isRuntimeWrappedValueKey = wrapValue.isRuntimeWrappedValueKey;
|
|
|
125
121
|
exports.isWrappedValue = wrapValue.isWrappedValue;
|
|
126
122
|
exports.keyWrappedValue = wrapValue.keyWrappedValue;
|
|
127
123
|
exports.wrapValue = wrapValue.wrapValue;
|
|
128
|
-
exports.toString = toString.toString;
|
|
129
124
|
exports.innerPipe = innerPipe.innerPipe;
|
|
130
125
|
exports.asyncInnerPipe = asyncInnerPipe.asyncInnerPipe;
|
|
131
126
|
exports.loop = loop.loop;
|
|
@@ -161,3 +156,7 @@ Object.defineProperty(exports, "Path", {
|
|
|
161
156
|
enumerable: true,
|
|
162
157
|
get: function () { return path.Path; }
|
|
163
158
|
});
|
|
159
|
+
exports.createTransformer = transformer.createTransformer;
|
|
160
|
+
exports.toJSON = transformer.toJSON;
|
|
161
|
+
exports.toNative = transformer.toNative;
|
|
162
|
+
exports.transformer = transformer.transformer;
|
package/dist/index.mjs
CHANGED
|
@@ -49,15 +49,12 @@ export { sleep } from './common/sleep.mjs';
|
|
|
49
49
|
export { InvalidBytesInStringError, stringToBytes } from './common/stringToBytes.mjs';
|
|
50
50
|
export { mimeType } from './common/mimeType.mjs';
|
|
51
51
|
export { InvalidMillisecondInStringError, stringToMillisecond } from './common/stringToMillisecond.mjs';
|
|
52
|
-
export { toJSON } from './common/toJSON.mjs';
|
|
53
|
-
export { toTransform } from './common/toTransform.mjs';
|
|
54
52
|
export { toWrappedValue } from './common/toWrappedValue.mjs';
|
|
55
53
|
export { unwrap } from './common/unwrap.mjs';
|
|
56
54
|
export { unwrapGroup } from './common/unwrapGroup.mjs';
|
|
57
55
|
export { asyncLoop } from './common/asyncLoop.mjs';
|
|
58
56
|
export { createAsyncRetry, useAsyncRetry } from './common/asyncRetry.mjs';
|
|
59
57
|
export { isRuntimeWrappedValueKey, isWrappedValue, keyWrappedValue, wrapValue } from './common/wrapValue.mjs';
|
|
60
|
-
export { toString } from './common/toString.mjs';
|
|
61
58
|
export { innerPipe } from './common/innerPipe.mjs';
|
|
62
59
|
export { asyncInnerPipe } from './common/asyncInnerPipe.mjs';
|
|
63
60
|
export { loop } from './common/loop.mjs';
|
|
@@ -87,3 +84,4 @@ export { toCurriedPredicate } from './common/toCurriedPredicate.mjs';
|
|
|
87
84
|
export { pipeCall } from './common/pipeCall.mjs';
|
|
88
85
|
export { AssertsError, asserts } from './common/asserts.mjs';
|
|
89
86
|
export { Path } from './common/path.mjs';
|
|
87
|
+
export { createTransformer, toJSON, toNative, transformer } from './common/transformer.mjs';
|
package/dist/metadata.json
CHANGED
|
@@ -612,6 +612,15 @@
|
|
|
612
612
|
},
|
|
613
613
|
{
|
|
614
614
|
"name": "string.mjs"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
"name": "time.cjs"
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
"name": "time.d.ts"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
"name": "time.mjs"
|
|
615
624
|
}
|
|
616
625
|
]
|
|
617
626
|
},
|
|
@@ -1551,40 +1560,22 @@
|
|
|
1551
1560
|
"name": "toCurriedPredicate.mjs"
|
|
1552
1561
|
},
|
|
1553
1562
|
{
|
|
1554
|
-
"name": "
|
|
1555
|
-
},
|
|
1556
|
-
{
|
|
1557
|
-
"name": "toJSON.d.ts"
|
|
1558
|
-
},
|
|
1559
|
-
{
|
|
1560
|
-
"name": "toJSON.mjs"
|
|
1561
|
-
},
|
|
1562
|
-
{
|
|
1563
|
-
"name": "toString.cjs"
|
|
1564
|
-
},
|
|
1565
|
-
{
|
|
1566
|
-
"name": "toString.d.ts"
|
|
1567
|
-
},
|
|
1568
|
-
{
|
|
1569
|
-
"name": "toString.mjs"
|
|
1570
|
-
},
|
|
1571
|
-
{
|
|
1572
|
-
"name": "toTransform.cjs"
|
|
1563
|
+
"name": "toWrappedValue.cjs"
|
|
1573
1564
|
},
|
|
1574
1565
|
{
|
|
1575
|
-
"name": "
|
|
1566
|
+
"name": "toWrappedValue.d.ts"
|
|
1576
1567
|
},
|
|
1577
1568
|
{
|
|
1578
|
-
"name": "
|
|
1569
|
+
"name": "toWrappedValue.mjs"
|
|
1579
1570
|
},
|
|
1580
1571
|
{
|
|
1581
|
-
"name": "
|
|
1572
|
+
"name": "transformer.cjs"
|
|
1582
1573
|
},
|
|
1583
1574
|
{
|
|
1584
|
-
"name": "
|
|
1575
|
+
"name": "transformer.d.ts"
|
|
1585
1576
|
},
|
|
1586
1577
|
{
|
|
1587
|
-
"name": "
|
|
1578
|
+
"name": "transformer.mjs"
|
|
1588
1579
|
},
|
|
1589
1580
|
{
|
|
1590
1581
|
"name": "truthy.cjs"
|
|
@@ -3032,16 +3023,16 @@
|
|
|
3032
3023
|
"name": "month.d.ts"
|
|
3033
3024
|
},
|
|
3034
3025
|
{
|
|
3035
|
-
"name": "
|
|
3026
|
+
"name": "serializedTheDate.d.ts"
|
|
3036
3027
|
},
|
|
3037
3028
|
{
|
|
3038
|
-
"name": "
|
|
3029
|
+
"name": "serializedTheTime.d.ts"
|
|
3039
3030
|
},
|
|
3040
3031
|
{
|
|
3041
|
-
"name": "
|
|
3032
|
+
"name": "spoolingDate.d.ts"
|
|
3042
3033
|
},
|
|
3043
3034
|
{
|
|
3044
|
-
"name": "
|
|
3035
|
+
"name": "spoolingTime.d.ts"
|
|
3045
3036
|
},
|
|
3046
3037
|
{
|
|
3047
3038
|
"name": "time.d.ts"
|
|
@@ -3096,24 +3087,6 @@
|
|
|
3096
3087
|
{
|
|
3097
3088
|
"name": "createOrThrow.mjs"
|
|
3098
3089
|
},
|
|
3099
|
-
{
|
|
3100
|
-
"name": "createTheDate.cjs"
|
|
3101
|
-
},
|
|
3102
|
-
{
|
|
3103
|
-
"name": "createTheDate.d.ts"
|
|
3104
|
-
},
|
|
3105
|
-
{
|
|
3106
|
-
"name": "createTheDate.mjs"
|
|
3107
|
-
},
|
|
3108
|
-
{
|
|
3109
|
-
"name": "createTheTime.cjs"
|
|
3110
|
-
},
|
|
3111
|
-
{
|
|
3112
|
-
"name": "createTheTime.d.ts"
|
|
3113
|
-
},
|
|
3114
|
-
{
|
|
3115
|
-
"name": "createTheTime.mjs"
|
|
3116
|
-
},
|
|
3117
3090
|
{
|
|
3118
3091
|
"name": "createTime.cjs"
|
|
3119
3092
|
},
|
|
@@ -3204,6 +3177,24 @@
|
|
|
3204
3177
|
{
|
|
3205
3178
|
"name": "isSafeTimeValue.mjs"
|
|
3206
3179
|
},
|
|
3180
|
+
{
|
|
3181
|
+
"name": "isSerializedTheDate.cjs"
|
|
3182
|
+
},
|
|
3183
|
+
{
|
|
3184
|
+
"name": "isSerializedTheDate.d.ts"
|
|
3185
|
+
},
|
|
3186
|
+
{
|
|
3187
|
+
"name": "isSerializedTheDate.mjs"
|
|
3188
|
+
},
|
|
3189
|
+
{
|
|
3190
|
+
"name": "isSerializedTheTime.cjs"
|
|
3191
|
+
},
|
|
3192
|
+
{
|
|
3193
|
+
"name": "isSerializedTheTime.d.ts"
|
|
3194
|
+
},
|
|
3195
|
+
{
|
|
3196
|
+
"name": "isSerializedTheTime.mjs"
|
|
3197
|
+
},
|
|
3207
3198
|
{
|
|
3208
3199
|
"name": "isTime.cjs"
|
|
3209
3200
|
},
|
|
@@ -3213,6 +3204,15 @@
|
|
|
3213
3204
|
{
|
|
3214
3205
|
"name": "isTime.mjs"
|
|
3215
3206
|
},
|
|
3207
|
+
{
|
|
3208
|
+
"name": "kind.cjs"
|
|
3209
|
+
},
|
|
3210
|
+
{
|
|
3211
|
+
"name": "kind.d.ts"
|
|
3212
|
+
},
|
|
3213
|
+
{
|
|
3214
|
+
"name": "kind.mjs"
|
|
3215
|
+
},
|
|
3216
3216
|
{
|
|
3217
3217
|
"name": "makeSafeTimestamp.cjs"
|
|
3218
3218
|
},
|
|
@@ -3285,6 +3285,15 @@
|
|
|
3285
3285
|
{
|
|
3286
3286
|
"name": "round.mjs"
|
|
3287
3287
|
},
|
|
3288
|
+
{
|
|
3289
|
+
"name": "serialize.cjs"
|
|
3290
|
+
},
|
|
3291
|
+
{
|
|
3292
|
+
"name": "serialize.d.ts"
|
|
3293
|
+
},
|
|
3294
|
+
{
|
|
3295
|
+
"name": "serialize.mjs"
|
|
3296
|
+
},
|
|
3288
3297
|
{
|
|
3289
3298
|
"name": "sort.cjs"
|
|
3290
3299
|
},
|
|
@@ -3303,6 +3312,24 @@
|
|
|
3303
3312
|
{
|
|
3304
3313
|
"name": "sortTimes.mjs"
|
|
3305
3314
|
},
|
|
3315
|
+
{
|
|
3316
|
+
"name": "theDate.cjs"
|
|
3317
|
+
},
|
|
3318
|
+
{
|
|
3319
|
+
"name": "theDate.d.ts"
|
|
3320
|
+
},
|
|
3321
|
+
{
|
|
3322
|
+
"name": "theDate.mjs"
|
|
3323
|
+
},
|
|
3324
|
+
{
|
|
3325
|
+
"name": "theTime.cjs"
|
|
3326
|
+
},
|
|
3327
|
+
{
|
|
3328
|
+
"name": "theTime.d.ts"
|
|
3329
|
+
},
|
|
3330
|
+
{
|
|
3331
|
+
"name": "theTime.mjs"
|
|
3332
|
+
},
|
|
3306
3333
|
{
|
|
3307
3334
|
"name": "timezone.cjs"
|
|
3308
3335
|
},
|
package/package.json
CHANGED
package/dist/common/toJSON.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* {@include common/toJSON/index.md}
|
|
5
|
-
*/
|
|
6
|
-
function toJSON(value) {
|
|
7
|
-
if (typeof value === "string"
|
|
8
|
-
|| typeof value === "number"
|
|
9
|
-
|| value === null
|
|
10
|
-
|| value === undefined) {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
else if (typeof value === "object"
|
|
14
|
-
&& "toJSON" in value
|
|
15
|
-
&& typeof value.toJSON === "function") {
|
|
16
|
-
return value.toJSON();
|
|
17
|
-
}
|
|
18
|
-
else if (typeof value === "object"
|
|
19
|
-
&& (!value.constructor
|
|
20
|
-
|| value.constructor.name === "Object")) {
|
|
21
|
-
return Object
|
|
22
|
-
.entries(value)
|
|
23
|
-
.reduce((pv, [key, value]) => ({
|
|
24
|
-
...pv,
|
|
25
|
-
[key]: toJSON(value),
|
|
26
|
-
}), {});
|
|
27
|
-
}
|
|
28
|
-
else if (value instanceof Array
|
|
29
|
-
&& value.constructor.name === "Array") {
|
|
30
|
-
return value.map(toJSON);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.toJSON = toJSON;
|
package/dist/common/toJSON.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type AnyFunction } from "./types/anyFunction";
|
|
2
|
-
import { type IsEqual } from "./types/isEqual";
|
|
3
|
-
export type ToJSON<GenericValue extends unknown> = GenericValue extends number | string | null | undefined ? GenericValue : GenericValue extends ({
|
|
4
|
-
toJSON: AnyFunction;
|
|
5
|
-
}) ? ReturnType<GenericValue["toJSON"]> : GenericValue extends [infer InferredFirst, ...infer InferredRest] ? [
|
|
6
|
-
ToJSON<InferredFirst>,
|
|
7
|
-
...(ToJSON<InferredRest> extends infer InferredSubRest extends any[] ? IsEqual<InferredSubRest, never[]> extends false ? InferredSubRest : [] : [])
|
|
8
|
-
] : GenericValue extends any[] ? ToJSON<GenericValue[number]>[] : GenericValue extends object ? {
|
|
9
|
-
[Prop in keyof GenericValue as GenericValue[Prop] extends AnyFunction ? never : Prop]: ToJSON<GenericValue[Prop]>;
|
|
10
|
-
} : undefined;
|
|
11
|
-
/**
|
|
12
|
-
* The toJSON() function prepares a value for JSON serialization while respecting objects' toJSON methods, traversing arrays/tuples, and excluding functions.
|
|
13
|
-
*
|
|
14
|
-
* Signature: `toJSON(value)` → returns a value
|
|
15
|
-
*
|
|
16
|
-
* The input value is not mutated.
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* const result = toJSON({
|
|
20
|
-
* prop: 1,
|
|
21
|
-
* prop1: "test",
|
|
22
|
-
* prop2: new Date("2025-08-19T15:14:19.467Z"),
|
|
23
|
-
* prop3: null,
|
|
24
|
-
* prop4: undefined,
|
|
25
|
-
* prop5: {
|
|
26
|
-
* subProp: [{ prop1: 1 }],
|
|
27
|
-
* subProp1: {
|
|
28
|
-
* toJSON() {
|
|
29
|
-
* return "test";
|
|
30
|
-
* },
|
|
31
|
-
* },
|
|
32
|
-
* },
|
|
33
|
-
* method() {
|
|
34
|
-
* return void 0;
|
|
35
|
-
* },
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* // type: { prop: number; prop1: string; prop2: string; prop3: null; prop4: undefined; prop5: { subProp: { prop1: number; }[]; subProp1: "test"; }; }
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @see https://utils.duplojs.dev/en/v1/api/common/toJSON
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
export declare function toJSON<GenericValue extends unknown>(value: GenericValue): ToJSON<GenericValue>;
|
package/dist/common/toJSON.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* {@include common/toJSON/index.md}
|
|
3
|
-
*/
|
|
4
|
-
function toJSON(value) {
|
|
5
|
-
if (typeof value === "string"
|
|
6
|
-
|| typeof value === "number"
|
|
7
|
-
|| value === null
|
|
8
|
-
|| value === undefined) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
else if (typeof value === "object"
|
|
12
|
-
&& "toJSON" in value
|
|
13
|
-
&& typeof value.toJSON === "function") {
|
|
14
|
-
return value.toJSON();
|
|
15
|
-
}
|
|
16
|
-
else if (typeof value === "object"
|
|
17
|
-
&& (!value.constructor
|
|
18
|
-
|| value.constructor.name === "Object")) {
|
|
19
|
-
return Object
|
|
20
|
-
.entries(value)
|
|
21
|
-
.reduce((pv, [key, value]) => ({
|
|
22
|
-
...pv,
|
|
23
|
-
[key]: toJSON(value),
|
|
24
|
-
}), {});
|
|
25
|
-
}
|
|
26
|
-
else if (value instanceof Array
|
|
27
|
-
&& value.constructor.name === "Array") {
|
|
28
|
-
return value.map(toJSON);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { toJSON };
|
package/dist/common/toString.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The toString() function converts a literal (number, string, bigint, boolean, null, undefined) into a typed template string.
|
|
3
|
-
*
|
|
4
|
-
* Signature: `toString(value)` → returns a value
|
|
5
|
-
*
|
|
6
|
-
* The input value is not mutated.
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const result = toString(42n);
|
|
10
|
-
*
|
|
11
|
-
* // type: "42"
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @see https://utils.duplojs.dev/en/v1/api/common/toString
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare function toString<GenericValue extends number | string | bigint | boolean | null | undefined>(value: GenericValue): `${GenericValue}`;
|
package/dist/common/toString.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* {@include common/toTransform/index.md}
|
|
5
|
-
*/
|
|
6
|
-
function toTransform(value) {
|
|
7
|
-
if (typeof value === "string"
|
|
8
|
-
|| typeof value === "number"
|
|
9
|
-
|| value === null
|
|
10
|
-
|| value === undefined) {
|
|
11
|
-
return value;
|
|
12
|
-
}
|
|
13
|
-
else if (value
|
|
14
|
-
&& typeof value === "object"
|
|
15
|
-
&& "toTransform" in value
|
|
16
|
-
&& typeof value.toTransform === "function") {
|
|
17
|
-
return (value.toTransform());
|
|
18
|
-
}
|
|
19
|
-
else if (typeof value === "object"
|
|
20
|
-
&& (!value.constructor
|
|
21
|
-
|| value.constructor.name === "Object")) {
|
|
22
|
-
return Object.entries(value)
|
|
23
|
-
.reduce((pv, [key, value]) => ({
|
|
24
|
-
...pv,
|
|
25
|
-
[key]: toTransform(value),
|
|
26
|
-
}), {});
|
|
27
|
-
}
|
|
28
|
-
else if (value instanceof Array
|
|
29
|
-
&& value.constructor.name === "Array") {
|
|
30
|
-
return value.map((subValue) => toTransform(subValue));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.toTransform = toTransform;
|