@bessemer/cornerstone 0.5.113 → 0.5.115
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.d.ts.map +1 -1
- package/dist/array.js +28 -28
- package/dist/array.js.map +1 -1
- package/dist/aspect-ratio.d.ts +3 -3
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/aspect-ratio.js +13 -12
- package/dist/aspect-ratio.js.map +1 -1
- package/dist/assertion.d.ts.map +1 -1
- package/dist/assertion.js +5 -5
- package/dist/assertion.js.map +1 -1
- package/dist/async-value.js +2 -2
- package/dist/async-value.js.map +1 -1
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +2 -2
- package/dist/async.js.map +1 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +11 -12
- package/dist/cache.js.map +1 -1
- package/dist/combinable.js +5 -5
- package/dist/combinable.js.map +1 -1
- package/dist/comparator.js +8 -8
- package/dist/comparator.js.map +1 -1
- package/dist/data-size.d.ts +2 -1
- package/dist/data-size.d.ts.map +1 -1
- package/dist/data-size.js +3 -3
- package/dist/data-size.js.map +1 -1
- package/dist/either.js +5 -5
- package/dist/either.js.map +1 -1
- package/dist/equalitor.d.ts.map +1 -1
- package/dist/equalitor.js +2 -2
- package/dist/equalitor.js.map +1 -1
- package/dist/error/error-cause.d.ts.map +1 -1
- package/dist/error/error-cause.js +14 -14
- package/dist/error/error-cause.js.map +1 -1
- package/dist/error/error-code.js +2 -2
- package/dist/error/error-code.js.map +1 -1
- package/dist/error/error-event.d.ts +3 -2
- package/dist/error/error-event.d.ts.map +1 -1
- package/dist/error/error-event.js +28 -28
- package/dist/error/error-event.js.map +1 -1
- package/dist/error/error-type.d.ts +2 -1
- package/dist/error/error-type.d.ts.map +1 -1
- package/dist/error/error-type.js +2 -2
- package/dist/error/error-type.js.map +1 -1
- package/dist/error/error.js +5 -5
- package/dist/error/error.js.map +1 -1
- package/dist/expression/array-expression.js +3 -3
- package/dist/expression/array-expression.js.map +1 -1
- package/dist/expression/core-expression.d.ts.map +1 -1
- package/dist/expression/core-expression.js +19 -19
- package/dist/expression/core-expression.js.map +1 -1
- package/dist/expression/expression-evaluator.js +2 -2
- package/dist/expression/expression-evaluator.js.map +1 -1
- package/dist/expression/expression-mapper.js +4 -4
- package/dist/expression/expression-mapper.js.map +1 -1
- package/dist/expression/internal.js +3 -3
- package/dist/expression/internal.js.map +1 -1
- package/dist/expression/numeric-expression.js +13 -13
- package/dist/expression/numeric-expression.js.map +1 -1
- package/dist/expression/string-expression.js +4 -4
- package/dist/expression/string-expression.js.map +1 -1
- package/dist/expression.d.ts +17 -1
- package/dist/expression.d.ts.map +1 -1
- package/dist/expression.js.map +1 -1
- package/dist/glob.d.ts +3 -3
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +11 -12
- package/dist/glob.js.map +1 -1
- package/dist/global-variable.d.ts.map +1 -1
- package/dist/global-variable.js +5 -5
- package/dist/global-variable.js.map +1 -1
- package/dist/hex-code.d.ts +3 -3
- package/dist/hex-code.d.ts.map +1 -1
- package/dist/hex-code.js +11 -10
- package/dist/hex-code.js.map +1 -1
- package/dist/index.d.ts +311 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/intl/country-code.d.ts +3 -3
- package/dist/intl/country-code.d.ts.map +1 -1
- package/dist/intl/country-code.js +9 -10
- package/dist/intl/country-code.js.map +1 -1
- package/dist/intl/country-subdivision-code.d.ts +3 -3
- package/dist/intl/country-subdivision-code.d.ts.map +1 -1
- package/dist/intl/country-subdivision-code.js +13 -11
- package/dist/intl/country-subdivision-code.js.map +1 -1
- package/dist/intl/currency-code.d.ts +3 -3
- package/dist/intl/currency-code.d.ts.map +1 -1
- package/dist/intl/currency-code.js +9 -10
- package/dist/intl/currency-code.js.map +1 -1
- package/dist/intl/language-code.d.ts +3 -3
- package/dist/intl/language-code.d.ts.map +1 -1
- package/dist/intl/language-code.js +9 -10
- package/dist/intl/language-code.js.map +1 -1
- package/dist/intl/locale.d.ts +3 -3
- package/dist/intl/locale.d.ts.map +1 -1
- package/dist/intl/locale.js +18 -19
- package/dist/intl/locale.js.map +1 -1
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +2 -2
- package/dist/json.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +12 -12
- package/dist/logger.js.map +1 -1
- package/dist/map.d.ts +306 -0
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +8 -8
- package/dist/map.js.map +1 -1
- package/dist/mime-type.d.ts +3 -3
- package/dist/mime-type.d.ts.map +1 -1
- package/dist/mime-type.js +9 -10
- package/dist/mime-type.js.map +1 -1
- package/dist/misc.js +4 -4
- package/dist/misc.js.map +1 -1
- package/dist/monetary-amount.d.ts +3 -2
- package/dist/monetary-amount.d.ts.map +1 -1
- package/dist/monetary-amount.js +16 -16
- package/dist/monetary-amount.js.map +1 -1
- package/dist/net/content-type.d.ts +2 -1
- package/dist/net/content-type.d.ts.map +1 -1
- package/dist/net/content-type.js +2 -2
- package/dist/net/content-type.js.map +1 -1
- package/dist/net/domain-name.d.ts +3 -3
- package/dist/net/domain-name.d.ts.map +1 -1
- package/dist/net/domain-name.js +10 -11
- package/dist/net/domain-name.js.map +1 -1
- package/dist/net/http-method.d.ts.map +1 -1
- package/dist/net/http-method.js +9 -9
- package/dist/net/http-method.js.map +1 -1
- package/dist/net/ipv4-address.d.ts +3 -3
- package/dist/net/ipv4-address.d.ts.map +1 -1
- package/dist/net/ipv4-address.js +10 -11
- package/dist/net/ipv4-address.js.map +1 -1
- package/dist/net/ipv6-address.d.ts +3 -3
- package/dist/net/ipv6-address.d.ts.map +1 -1
- package/dist/net/ipv6-address.js +10 -11
- package/dist/net/ipv6-address.js.map +1 -1
- package/dist/net/uri-host-name.d.ts +3 -3
- package/dist/net/uri-host-name.d.ts.map +1 -1
- package/dist/net/uri-host-name.js +15 -16
- package/dist/net/uri-host-name.js.map +1 -1
- package/dist/net/uri.d.ts +1 -2
- package/dist/net/uri.d.ts.map +1 -1
- package/dist/net/uri.js +5 -3
- package/dist/net/uri.js.map +1 -1
- package/dist/net/url.d.ts.map +1 -1
- package/dist/net/url.js +6 -7
- package/dist/net/url.js.map +1 -1
- package/dist/object/object-path.d.ts.map +1 -1
- package/dist/object/object-path.js +23 -28
- package/dist/object/object-path.js.map +1 -1
- package/dist/object/type-path.js +19 -19
- package/dist/object/type-path.js.map +1 -1
- package/dist/patch.js +4 -4
- package/dist/patch.js.map +1 -1
- package/dist/promise.js +2 -2
- package/dist/promise.js.map +1 -1
- package/dist/property.d.ts.map +1 -1
- package/dist/property.js +7 -7
- package/dist/property.js.map +1 -1
- package/dist/proxy.js +2 -2
- package/dist/proxy.js.map +1 -1
- package/dist/range.js +2 -2
- package/dist/range.js.map +1 -1
- package/dist/reference.d.ts +2 -1
- package/dist/reference.d.ts.map +1 -1
- package/dist/reference.js +13 -13
- package/dist/reference.js.map +1 -1
- package/dist/resource-key.js +2 -2
- package/dist/resource-key.js.map +1 -1
- package/dist/result.js +5 -5
- package/dist/result.js.map +1 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +12 -12
- package/dist/retry.js.map +1 -1
- package/dist/rich-text.js +2 -2
- package/dist/rich-text.js.map +1 -1
- package/dist/signature.d.ts.map +1 -1
- package/dist/signature.js +9 -9
- package/dist/signature.js.map +1 -1
- package/dist/sql/sql-expression-parser.js +2 -2
- package/dist/sql/sql-expression-parser.js.map +1 -1
- package/dist/sql.d.ts +5 -1
- package/dist/sql.d.ts.map +1 -1
- package/dist/sql.js.map +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +9 -9
- package/dist/store.js.map +1 -1
- package/dist/string.js +4 -4
- package/dist/string.js.map +1 -1
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js +10 -10
- package/dist/tag.js.map +1 -1
- package/dist/temporal/clock.d.ts +13 -13
- package/dist/temporal/clock.d.ts.map +1 -1
- package/dist/temporal/clock.js +10 -10
- package/dist/temporal/clock.js.map +1 -1
- package/dist/temporal/duration.d.ts +15 -9
- package/dist/temporal/duration.d.ts.map +1 -1
- package/dist/temporal/duration.js +30 -31
- package/dist/temporal/duration.js.map +1 -1
- package/dist/temporal/instant.d.ts +18 -15
- package/dist/temporal/instant.d.ts.map +1 -1
- package/dist/temporal/instant.js +42 -43
- package/dist/temporal/instant.js.map +1 -1
- package/dist/temporal/plain-date-time.d.ts +16 -13
- package/dist/temporal/plain-date-time.d.ts.map +1 -1
- package/dist/temporal/plain-date-time.js +36 -38
- package/dist/temporal/plain-date-time.js.map +1 -1
- package/dist/temporal/plain-date.d.ts +16 -13
- package/dist/temporal/plain-date.d.ts.map +1 -1
- package/dist/temporal/plain-date.js +35 -37
- package/dist/temporal/plain-date.js.map +1 -1
- package/dist/temporal/plain-month-day.d.ts +37 -0
- package/dist/temporal/plain-month-day.d.ts.map +1 -0
- package/dist/temporal/plain-month-day.js +84 -0
- package/dist/temporal/plain-month-day.js.map +1 -0
- package/dist/temporal/plain-time.d.ts +19 -17
- package/dist/temporal/plain-time.d.ts.map +1 -1
- package/dist/temporal/plain-time.js +43 -42
- package/dist/temporal/plain-time.js.map +1 -1
- package/dist/temporal/plain-year-month.d.ts +57 -0
- package/dist/temporal/plain-year-month.d.ts.map +1 -0
- package/dist/temporal/plain-year-month.js +109 -0
- package/dist/temporal/plain-year-month.js.map +1 -0
- package/dist/temporal/time-zone-id.d.ts +5 -4
- package/dist/temporal/time-zone-id.d.ts.map +1 -1
- package/dist/temporal/time-zone-id.js +11 -11
- package/dist/temporal/time-zone-id.js.map +1 -1
- package/dist/temporal/time-zone-offset.d.ts +12 -11
- package/dist/temporal/time-zone-offset.d.ts.map +1 -1
- package/dist/temporal/time-zone-offset.js +42 -50
- package/dist/temporal/time-zone-offset.js.map +1 -1
- package/dist/temporal/zoned-date-time.d.ts +16 -13
- package/dist/temporal/zoned-date-time.d.ts.map +1 -1
- package/dist/temporal/zoned-date-time.js +35 -36
- package/dist/temporal/zoned-date-time.js.map +1 -1
- package/dist/uuid/ulid.d.ts +3 -3
- package/dist/uuid/ulid.d.ts.map +1 -1
- package/dist/uuid/ulid.js +9 -10
- package/dist/uuid/ulid.js.map +1 -1
- package/dist/uuid/uuid-v4.d.ts +3 -3
- package/dist/uuid/uuid-v4.d.ts.map +1 -1
- package/dist/uuid/uuid-v4.js +13 -14
- package/dist/uuid/uuid-v4.js.map +1 -1
- package/dist/uuid/uuid-v7.d.ts +1 -2
- package/dist/uuid/uuid-v7.d.ts.map +1 -1
- package/dist/uuid/uuid-v7.js +1 -2
- package/dist/uuid/uuid-v7.js.map +1 -1
- package/dist/zod-util.d.ts +4 -3
- package/dist/zod-util.d.ts.map +1 -1
- package/dist/zod-util.js +21 -11
- package/dist/zod-util.js.map +1 -1
- package/package.json +6 -4
package/dist/temporal/clock.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/temporal/clock.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import * as TimeZoneIds from "@bessemer/cornerstone/temporal/time-zone-id";
|
|
3
|
+
import * as Durations from "@bessemer/cornerstone/temporal/duration";
|
|
4
|
+
import * as Instants from "@bessemer/cornerstone/temporal/instant";
|
|
5
5
|
import { Temporal } from "@js-temporal/polyfill";
|
|
6
6
|
var SystemClock = class _SystemClock {
|
|
7
7
|
constructor(zone) {
|
|
@@ -49,22 +49,22 @@ var OffsetClock = class _OffsetClock {
|
|
|
49
49
|
return new _OffsetClock(this.clock.withZone(zone), this.offset);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
var SystemUtc = new SystemClock(Utc);
|
|
52
|
+
var SystemUtc = new SystemClock(TimeZoneIds.Utc);
|
|
53
53
|
var Default = SystemUtc;
|
|
54
|
-
var system = (zone = Utc) => {
|
|
55
|
-
if (zone == Utc) {
|
|
54
|
+
var system = (zone = TimeZoneIds.Utc) => {
|
|
55
|
+
if (zone == TimeZoneIds.Utc) {
|
|
56
56
|
return SystemUtc;
|
|
57
57
|
}
|
|
58
58
|
return new SystemClock(zone);
|
|
59
59
|
};
|
|
60
|
-
var fixed = (fixedInstant, zone = Utc) => {
|
|
61
|
-
return new FixedClock(
|
|
60
|
+
var fixed = (fixedInstant, zone = TimeZoneIds.Utc) => {
|
|
61
|
+
return new FixedClock(Instants.from(fixedInstant), zone);
|
|
62
62
|
};
|
|
63
63
|
var offset = (clock, offset2) => {
|
|
64
|
-
if (isZero(offset2)) {
|
|
64
|
+
if (Durations.isZero(offset2)) {
|
|
65
65
|
return clock;
|
|
66
66
|
}
|
|
67
|
-
return new OffsetClock(clock,
|
|
67
|
+
return new OffsetClock(clock, Durations.from(offset2));
|
|
68
68
|
};
|
|
69
69
|
export {
|
|
70
70
|
Default,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/clock.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/clock.ts"],"sourcesContent":["import * as TimeZoneIds from '@bessemer/cornerstone/temporal/time-zone-id'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as Instants from '@bessemer/cornerstone/temporal/instant'\nimport { Temporal } from '@js-temporal/polyfill'\n\nexport interface Clock {\n readonly zone: TimeZoneIds.TimeZoneId\n\n withZone: (zone: TimeZoneIds.TimeZoneId) => Clock\n\n instant: () => Instants.Instant\n}\n\nclass SystemClock implements Clock {\n constructor(readonly zone: TimeZoneIds.TimeZoneId) {}\n\n instant(): Instants.Instant {\n return Temporal.Now.instant()\n }\n\n withZone(zone: TimeZoneIds.TimeZoneId): Clock {\n if (zone === this.zone) {\n return this\n }\n\n return new SystemClock(zone)\n }\n}\n\nclass FixedClock implements Clock {\n constructor(private fixedInstant: Instants.Instant, readonly zone: TimeZoneIds.TimeZoneId) {}\n\n instant(): Instants.Instant {\n return this.fixedInstant\n }\n\n withZone(zone: TimeZoneIds.TimeZoneId): Clock {\n if (zone === this.zone) {\n return this\n }\n\n return new FixedClock(this.fixedInstant, zone)\n }\n}\n\nclass OffsetClock implements Clock {\n readonly zone: TimeZoneIds.TimeZoneId\n\n constructor(private clock: Clock, private offset: Durations.Duration) {\n this.zone = this.clock.zone\n }\n\n instant(): Instants.Instant {\n return this.clock.instant().add(this.offset)\n }\n\n withZone(zone: TimeZoneIds.TimeZoneId): Clock {\n if (zone === this.clock.zone) {\n return this\n }\n\n return new OffsetClock(this.clock.withZone(zone), this.offset)\n }\n}\n\nexport const SystemUtc = new SystemClock(TimeZoneIds.Utc)\nexport const Default = SystemUtc\n\nexport const system = (zone: TimeZoneIds.TimeZoneId = TimeZoneIds.Utc): Clock => {\n if (zone == TimeZoneIds.Utc) {\n return SystemUtc\n }\n\n return new SystemClock(zone)\n}\n\nexport const fixed = (fixedInstant: Instants.InstantLike, zone: TimeZoneIds.TimeZoneId = TimeZoneIds.Utc): Clock => {\n return new FixedClock(Instants.from(fixedInstant), zone)\n}\n\nexport const offset = (clock: Clock, offset: Durations.DurationLike): Clock => {\n if (Durations.isZero(offset)) {\n return clock\n }\n\n return new OffsetClock(clock, Durations.from(offset))\n}\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,eAAe;AAC3B,YAAY,cAAc;AAC1B,SAAS,gBAAgB;AAUzB,IAAM,cAAN,MAAM,aAA6B;AAAA,EACjC,YAAqB,MAA8B;AAA9B;AAAA,EAA+B;AAAA,EAEpD,UAA4B;AAC1B,WAAO,SAAS,IAAI,QAAQ;AAAA,EAC9B;AAAA,EAEA,SAAS,MAAqC;AAC5C,QAAI,SAAS,KAAK,MAAM;AACtB,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,aAAY,IAAI;AAAA,EAC7B;AACF;AAEA,IAAM,aAAN,MAAM,YAA4B;AAAA,EAChC,YAAoB,cAAyC,MAA8B;AAAvE;AAAyC;AAAA,EAA+B;AAAA,EAE5F,UAA4B;AAC1B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,SAAS,MAAqC;AAC5C,QAAI,SAAS,KAAK,MAAM;AACtB,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,YAAW,KAAK,cAAc,IAAI;AAAA,EAC/C;AACF;AAEA,IAAM,cAAN,MAAM,aAA6B;AAAA,EAGjC,YAAoB,OAAsBA,SAA4B;AAAlD;AAAsB,kBAAAA;AACxC,SAAK,OAAO,KAAK,MAAM;AAAA,EACzB;AAAA,EAJS;AAAA,EAMT,UAA4B;AAC1B,WAAO,KAAK,MAAM,QAAQ,EAAE,IAAI,KAAK,MAAM;AAAA,EAC7C;AAAA,EAEA,SAAS,MAAqC;AAC5C,QAAI,SAAS,KAAK,MAAM,MAAM;AAC5B,aAAO;AAAA,IACT;AAEA,WAAO,IAAI,aAAY,KAAK,MAAM,SAAS,IAAI,GAAG,KAAK,MAAM;AAAA,EAC/D;AACF;AAEO,IAAM,YAAY,IAAI,YAAwB,eAAG;AACjD,IAAM,UAAU;AAEhB,IAAM,SAAS,CAAC,OAA2C,oBAAe;AAC/E,MAAI,QAAoB,iBAAK;AAC3B,WAAO;AAAA,EACT;AAEA,SAAO,IAAI,YAAY,IAAI;AAC7B;AAEO,IAAM,QAAQ,CAAC,cAAoC,OAA2C,oBAAe;AAClH,SAAO,IAAI,WAAoB,cAAK,YAAY,GAAG,IAAI;AACzD;AAEO,IAAM,SAAS,CAAC,OAAcA,YAA0C;AAC7E,MAAc,iBAAOA,OAAM,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,SAAO,IAAI,YAAY,OAAiB,eAAKA,OAAM,CAAC;AACtD;","names":["offset"]}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import Zod from 'zod';
|
|
2
2
|
import { Temporal } from '@js-temporal/polyfill';
|
|
3
|
+
import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
|
|
3
4
|
import { NominalType } from '@bessemer/cornerstone/types';
|
|
4
5
|
import { Comparator } from '@bessemer/cornerstone/comparator';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import * as Equalitors from '@bessemer/cornerstone/equalitor';
|
|
7
|
+
import * as Results from '@bessemer/cornerstone/result';
|
|
8
|
+
import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
|
|
9
|
+
import * as Chrono from '@bessemer/cornerstone/temporal/chrono';
|
|
8
10
|
export type Duration = Temporal.Duration;
|
|
9
|
-
export declare const Namespace:
|
|
11
|
+
export declare const Namespace: ResourceKeys.ResourceNamespace<"duration">;
|
|
10
12
|
export type DurationLiteral = NominalType<string, typeof Namespace>;
|
|
11
13
|
export type DurationBuilder = {
|
|
14
|
+
years?: number;
|
|
15
|
+
months?: number;
|
|
16
|
+
weeks?: number;
|
|
17
|
+
days?: number;
|
|
12
18
|
hours?: number;
|
|
13
19
|
minutes?: number;
|
|
14
20
|
seconds?: number;
|
|
@@ -22,8 +28,8 @@ export declare function from(value: DurationLike | string | null): Duration | nu
|
|
|
22
28
|
export declare function from(value: DurationLike | string | undefined): Duration | undefined;
|
|
23
29
|
export declare function from(value: DurationLike | string | null | undefined): Duration | null | undefined;
|
|
24
30
|
export declare const CompareBy: Comparator<Duration>;
|
|
25
|
-
export declare const EqualBy:
|
|
26
|
-
export declare const parseString: (value: string) => Result<Duration, ErrorEvent>;
|
|
31
|
+
export declare const EqualBy: Equalitors.Equalitor<Temporal.Duration>;
|
|
32
|
+
export declare const parseString: (value: string) => Results.Result<Duration, ErrorEvents.ErrorEvent>;
|
|
27
33
|
export declare function toLiteral(value: DurationLike): DurationLiteral;
|
|
28
34
|
export declare function toLiteral(value: DurationLike | null): DurationLiteral | null;
|
|
29
35
|
export declare function toLiteral(value: DurationLike | undefined): DurationLiteral | undefined;
|
|
@@ -40,10 +46,10 @@ export declare const fromMinutes: (value: number) => Duration;
|
|
|
40
46
|
export declare const toMinutes: (duration: DurationLike) => number;
|
|
41
47
|
export declare const fromHours: (value: number) => Duration;
|
|
42
48
|
export declare const toHours: (duration: DurationLike) => number;
|
|
43
|
-
export declare const fromUnit: (value: number, timeUnit: TimeUnit) => Duration;
|
|
44
|
-
export declare const toUnit: (duration: DurationLike, timeUnit: TimeUnit) => number;
|
|
49
|
+
export declare const fromUnit: (value: number, timeUnit: Chrono.TimeUnit) => Duration;
|
|
50
|
+
export declare const toUnit: (duration: DurationLike, timeUnit: Chrono.TimeUnit) => number;
|
|
45
51
|
export declare const isZero: (duration: DurationLike) => boolean;
|
|
46
|
-
export declare const round: (element: DurationLike, unit: TimeUnit) => Duration;
|
|
52
|
+
export declare const round: (element: DurationLike, unit: Chrono.TimeUnit) => Duration;
|
|
47
53
|
export declare const add: (...durations: Array<DurationLike>) => Duration;
|
|
48
54
|
export declare const subtract: (...durations: Array<DurationLike>) => Duration;
|
|
49
55
|
export declare const negate: (element: DurationLike) => Duration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/temporal/duration.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/temporal/duration.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAC7D,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAE7D,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,WAAW,MAAM,yCAAyC,CAAA;AAEtE,OAAO,KAAK,MAAM,MAAM,uCAAuC,CAAA;AAI/D,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA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4
|
+
import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
|
|
5
|
+
import * as Equalitors from "@bessemer/cornerstone/equalitor";
|
|
6
|
+
import * as ZodUtil from "@bessemer/cornerstone/zod-util";
|
|
7
7
|
import * as Results from "@bessemer/cornerstone/result";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
var Namespace = createNamespace("duration");
|
|
8
|
+
import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
|
|
9
|
+
import * as Errors from "@bessemer/cornerstone/error/error";
|
|
10
|
+
import * as Chrono from "@bessemer/cornerstone/temporal/chrono";
|
|
11
|
+
import * as Strings from "@bessemer/cornerstone/string";
|
|
12
|
+
import * as Objects from "@bessemer/cornerstone/object";
|
|
13
|
+
var Namespace = ResourceKeys.createNamespace("duration");
|
|
15
14
|
function from(value) {
|
|
16
|
-
if (isNil(value)) {
|
|
15
|
+
if (Objects.isNil(value)) {
|
|
17
16
|
return value;
|
|
18
17
|
}
|
|
19
18
|
if (value instanceof Temporal.Duration) {
|
|
20
19
|
return value;
|
|
21
20
|
}
|
|
22
|
-
if (isString(value)) {
|
|
23
|
-
return unpackResult(parseString(value));
|
|
21
|
+
if (Strings.isString(value)) {
|
|
22
|
+
return ErrorEvents.unpackResult(parseString(value));
|
|
24
23
|
}
|
|
25
24
|
return Temporal.Duration.from(value);
|
|
26
25
|
}
|
|
27
26
|
var CompareBy = (first, second) => Temporal.Duration.compare(first, second);
|
|
28
|
-
var EqualBy = fromComparator(CompareBy);
|
|
27
|
+
var EqualBy = Equalitors.fromComparator(CompareBy);
|
|
29
28
|
var parseString = (value) => {
|
|
30
29
|
try {
|
|
31
|
-
return success(Temporal.Duration.from(value));
|
|
30
|
+
return Results.success(Temporal.Duration.from(value));
|
|
32
31
|
} catch (e) {
|
|
33
|
-
if (!isError(e)) {
|
|
32
|
+
if (!Errors.isError(e)) {
|
|
34
33
|
throw e;
|
|
35
34
|
}
|
|
36
|
-
return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
35
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
function toLiteral(value) {
|
|
40
|
-
if (isNil(value)) {
|
|
39
|
+
if (Objects.isNil(value)) {
|
|
41
40
|
return value;
|
|
42
41
|
}
|
|
43
42
|
return from(value).toString();
|
|
44
43
|
}
|
|
45
|
-
var SchemaLiteral = structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2)));
|
|
46
|
-
var SchemaInstance = structuredTransform(Zod.string(), parseString);
|
|
44
|
+
var SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2)));
|
|
45
|
+
var SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString);
|
|
47
46
|
var isDuration = (value) => {
|
|
48
47
|
return value instanceof Temporal.Duration;
|
|
49
48
|
};
|
|
@@ -54,39 +53,39 @@ var fromMilliseconds = (value) => {
|
|
|
54
53
|
return from({ milliseconds: value });
|
|
55
54
|
};
|
|
56
55
|
var toMilliseconds = (duration) => {
|
|
57
|
-
return from(duration).total(TimeUnit.Millisecond);
|
|
56
|
+
return from(duration).total(Chrono.TimeUnit.Millisecond);
|
|
58
57
|
};
|
|
59
58
|
var fromSeconds = (value) => {
|
|
60
59
|
return from({ seconds: value });
|
|
61
60
|
};
|
|
62
61
|
var toSeconds = (duration) => {
|
|
63
|
-
return from(duration).total(TimeUnit.Second);
|
|
62
|
+
return from(duration).total(Chrono.TimeUnit.Second);
|
|
64
63
|
};
|
|
65
64
|
var fromMinutes = (value) => {
|
|
66
65
|
return from({ minutes: value });
|
|
67
66
|
};
|
|
68
67
|
var toMinutes = (duration) => {
|
|
69
|
-
return from(duration).total(TimeUnit.Minute);
|
|
68
|
+
return from(duration).total(Chrono.TimeUnit.Minute);
|
|
70
69
|
};
|
|
71
70
|
var fromHours = (value) => {
|
|
72
71
|
return from({ hours: value });
|
|
73
72
|
};
|
|
74
73
|
var toHours = (duration) => {
|
|
75
|
-
return from(duration).total(TimeUnit.Hour);
|
|
74
|
+
return from(duration).total(Chrono.TimeUnit.Hour);
|
|
76
75
|
};
|
|
77
76
|
var fromUnit = (value, timeUnit) => {
|
|
78
77
|
switch (timeUnit) {
|
|
79
|
-
case TimeUnit.Nanosecond:
|
|
78
|
+
case Chrono.TimeUnit.Nanosecond:
|
|
80
79
|
return from({ nanoseconds: value });
|
|
81
|
-
case TimeUnit.Microsecond:
|
|
80
|
+
case Chrono.TimeUnit.Microsecond:
|
|
82
81
|
return from({ microseconds: value });
|
|
83
|
-
case TimeUnit.Millisecond:
|
|
82
|
+
case Chrono.TimeUnit.Millisecond:
|
|
84
83
|
return from({ milliseconds: value });
|
|
85
|
-
case TimeUnit.Second:
|
|
84
|
+
case Chrono.TimeUnit.Second:
|
|
86
85
|
return from({ seconds: value });
|
|
87
|
-
case TimeUnit.Minute:
|
|
86
|
+
case Chrono.TimeUnit.Minute:
|
|
88
87
|
return from({ minutes: value });
|
|
89
|
-
case TimeUnit.Hour:
|
|
88
|
+
case Chrono.TimeUnit.Hour:
|
|
90
89
|
return from({ hours: value });
|
|
91
90
|
}
|
|
92
91
|
};
|
|
@@ -113,7 +112,7 @@ var negate = (element) => {
|
|
|
113
112
|
return from(element).negated();
|
|
114
113
|
};
|
|
115
114
|
function isEqual(element, other) {
|
|
116
|
-
if (isNil(element) || isNil(other)) {
|
|
115
|
+
if (Objects.isNil(element) || Objects.isNil(other)) {
|
|
117
116
|
return element === other;
|
|
118
117
|
}
|
|
119
118
|
return EqualBy(from(element), from(other));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/duration.ts"],"sourcesContent":["import Zod from 'zod'\nimport { Temporal } from '@js-temporal/polyfill'\nimport { createNamespace } from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport { fromComparator } from '@bessemer/cornerstone/equalitor'\nimport { structuredTransform } from '@bessemer/cornerstone/zod-util'\nimport * as Results from '@bessemer/cornerstone/result'\nimport { failure, Result, success } from '@bessemer/cornerstone/result'\nimport { ErrorEvent, invalidValue, unpackResult } from '@bessemer/cornerstone/error/error-event'\nimport { isError } from '@bessemer/cornerstone/error/error'\nimport { TimeUnit } from '@bessemer/cornerstone/temporal/chrono'\nimport { isString } from '@bessemer/cornerstone/string'\nimport { isNil } from '@bessemer/cornerstone/object'\n\nexport type Duration = Temporal.Duration\nexport const Namespace = createNamespace('duration')\nexport type DurationLiteral = NominalType<string, typeof Namespace>\nexport type DurationBuilder = {\n hours?: number\n minutes?: number\n seconds?: number\n milliseconds?: number\n microseconds?: number\n nanoseconds?: number\n}\nexport type DurationLike = Duration | DurationLiteral | DurationBuilder\n\nexport function from(value: DurationLike | string): Duration\nexport function from(value: DurationLike | string | null): Duration | null\nexport function from(value: DurationLike | string | undefined): Duration | undefined\nexport function from(value: DurationLike | string | null | undefined): Duration | null | undefined\nexport function from(value: DurationLike | string | null | undefined): Duration | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Duration) {\n return value\n }\n if (isString(value)) {\n return unpackResult(parseString(value))\n }\n\n return Temporal.Duration.from(value)\n}\n\nexport const CompareBy: Comparator<Duration> = (first: Duration, second: Duration): number => Temporal.Duration.compare(first, second)\nexport const EqualBy = fromComparator(CompareBy)\n\nexport const parseString = (value: string): Result<Duration, ErrorEvent> => {\n try {\n return success(Temporal.Duration.from(value))\n } catch (e) {\n if (!isError(e)) {\n throw e\n }\n\n return failure(invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport function toLiteral(value: DurationLike): DurationLiteral\nexport function toLiteral(value: DurationLike | null): DurationLiteral | null\nexport function toLiteral(value: DurationLike | undefined): DurationLiteral | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined {\n if (isNil(value)) {\n return value\n }\n\n return from(value).toString() as DurationLiteral\n}\n\nexport const SchemaLiteral = structuredTransform(Zod.string(), (it: string) => Results.map(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = structuredTransform(Zod.string(), parseString)\n\nexport const isDuration = (value: unknown): value is Duration => {\n return value instanceof Temporal.Duration\n}\n\nexport const merge = (element: DurationLike, builder: DurationBuilder): Duration => {\n return from(element).with(builder)\n}\n\nexport const fromMilliseconds = (value: number): Duration => {\n return from({ milliseconds: value })\n}\n\nexport const toMilliseconds = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Millisecond)\n}\n\nexport const fromSeconds = (value: number): Duration => {\n return from({ seconds: value })\n}\n\nexport const toSeconds = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Second)\n}\n\nexport const fromMinutes = (value: number): Duration => {\n return from({ minutes: value })\n}\n\nexport const toMinutes = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Minute)\n}\n\nexport const fromHours = (value: number): Duration => {\n return from({ hours: value })\n}\n\nexport const toHours = (duration: DurationLike): number => {\n return from(duration).total(TimeUnit.Hour)\n}\n\nexport const fromUnit = (value: number, timeUnit: TimeUnit): Duration => {\n switch (timeUnit) {\n case TimeUnit.Nanosecond:\n return from({ nanoseconds: value })\n case TimeUnit.Microsecond:\n return from({ microseconds: value })\n case TimeUnit.Millisecond:\n return from({ milliseconds: value })\n case TimeUnit.Second:\n return from({ seconds: value })\n case TimeUnit.Minute:\n return from({ minutes: value })\n case TimeUnit.Hour:\n return from({ hours: value })\n }\n}\n\nexport const toUnit = (duration: DurationLike, timeUnit: TimeUnit): number => {\n return from(duration).total(timeUnit)\n}\n\nexport const isZero = (duration: DurationLike): boolean => {\n return EqualBy(from(duration), Zero)\n}\n\nexport const round = (element: DurationLike, unit: TimeUnit): Duration => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport const add = (...durations: Array<DurationLike>): Duration => {\n return durations.map((it) => from(it)).reduce((first, second) => first.add(second), Zero)\n}\n\nexport const subtract = (...durations: Array<DurationLike>): Duration => {\n if (durations.length === 0) {\n return Zero\n }\n\n const instances = durations.map((it) => from(it))\n return instances.slice(1).reduce((result, current) => result.subtract(current), instances[0]!)\n}\n\nexport const negate = (element: DurationLike): Duration => {\n return from(element).negated()\n}\n\nexport function isEqual(element: DurationLike, other: DurationLike): boolean\nexport function isEqual(element: DurationLike | null, other: DurationLike | null): boolean\nexport function isEqual(element: DurationLike | undefined, other: DurationLike | undefined): boolean\nexport function isEqual(element: DurationLike | null | undefined, other: DurationLike | null | undefined): boolean {\n if (isNil(element) || isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isLess = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isGreater = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const Zero = from({ nanoseconds: 0 })\nexport const OneMillisecond = fromMilliseconds(1)\nexport const OneSecond = fromSeconds(1)\nexport const OneMinute = fromMinutes(1)\nexport const OneHour = fromHours(1)\nexport const OneDay = fromHours(24)\n"],"mappings":";AAAA,OAAO,SAAS;AAChB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAGhC,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,YAAY,aAAa;AACzB,SAAS,SAAiB,eAAe;AACzC,SAAqB,cAAc,oBAAoB;AACvD,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,aAAa;AAGf,IAAM,YAAY,gBAAgB,UAAU;AAgB5C,SAAS,KAAK,OAA8E;AACjG,MAAI,MAAM,KAAK,GAAG;AAChB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,UAAU;AACtC,WAAO;AAAA,EACT;AACA,MAAI,SAAS,KAAK,GAAG;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IAAI,MAAM,GAAG,IAAI;AAC1F;AAEO,IAAM,WAAW,IAAI,cAA6C;AACvE,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,UAAU,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC;AAChD,SAAO,UAAU,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,YAAY,OAAO,SAAS,OAAO,GAAG,UAAU,CAAC,CAAE;AAC/F;AAEO,IAAM,SAAS,CAAC,YAAoC;AACzD,SAAO,KAAK,OAAO,EAAE,QAAQ;AAC/B;AAKO,SAAS,QAAQ,SAA0C,OAAiD;AACjH,MAAI,MAAM,OAAO,KAAK,MAAM,KAAK,GAAG;AAClC,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC;AAC3C;AAEO,IAAM,SAAS,CAAC,SAAuB,UAAiC;AAC7E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,YAAY,CAAC,SAAuB,UAAiC;AAChF,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,OAAO,KAAK,EAAE,aAAa,EAAE,CAAC;AACpC,IAAM,iBAAiB,iBAAiB,CAAC;AACzC,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,UAAU,UAAU,CAAC;AAC3B,IAAM,SAAS,UAAU,EAAE;","names":["it"]}
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/duration.ts"],"sourcesContent":["import Zod from 'zod'\nimport { Temporal } from '@js-temporal/polyfill'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as Chrono from '@bessemer/cornerstone/temporal/chrono'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Objects from '@bessemer/cornerstone/object'\n\nexport type Duration = Temporal.Duration\nexport const Namespace = ResourceKeys.createNamespace('duration')\nexport type DurationLiteral = NominalType<string, typeof Namespace>\nexport type DurationBuilder = {\n // JOHN consider splitting into 'TimeDuration' and 'CalendarDuration' -----\n years?: number\n months?: number\n weeks?: number\n days?: number\n // -----\n hours?: number\n minutes?: number\n seconds?: number\n milliseconds?: number\n microseconds?: number\n nanoseconds?: number\n}\nexport type DurationLike = Duration | DurationLiteral | DurationBuilder\n\nexport function from(value: DurationLike | string): Duration\nexport function from(value: DurationLike | string | null): Duration | null\nexport function from(value: DurationLike | string | undefined): Duration | undefined\nexport function from(value: DurationLike | string | null | undefined): Duration | null | undefined\nexport function from(value: DurationLike | string | null | undefined): Duration | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Duration) {\n return value\n }\n\n if (Strings.isString(value)) {\n return ErrorEvents.unpackResult(parseString(value))\n }\n\n return Temporal.Duration.from(value)\n}\n\nexport const CompareBy: Comparator<Duration> = (first: Duration, second: Duration): number => Temporal.Duration.compare(first, second)\nexport const EqualBy = Equalitors.fromComparator(CompareBy)\n\nexport const parseString = (value: string): Results.Result<Duration, ErrorEvents.ErrorEvent> => {\n try {\n return Results.success(Temporal.Duration.from(value))\n } catch (e) {\n if (!Errors.isError(e)) {\n throw e\n }\n\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport function toLiteral(value: DurationLike): DurationLiteral\nexport function toLiteral(value: DurationLike | null): DurationLiteral | null\nexport function toLiteral(value: DurationLike | undefined): DurationLiteral | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined\nexport function toLiteral(value: DurationLike | null | undefined): DurationLiteral | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n return from(value).toString() as DurationLiteral\n}\n\nexport const SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it: string) => Results.map(parseString(it), (it) => toLiteral(it)))\nexport const SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString)\n\nexport const isDuration = (value: unknown): value is Duration => {\n return value instanceof Temporal.Duration\n}\n\nexport const merge = (element: DurationLike, builder: DurationBuilder): Duration => {\n return from(element).with(builder)\n}\n\nexport const fromMilliseconds = (value: number): Duration => {\n return from({ milliseconds: value })\n}\n\nexport const toMilliseconds = (duration: DurationLike): number => {\n return from(duration).total(Chrono.TimeUnit.Millisecond)\n}\n\nexport const fromSeconds = (value: number): Duration => {\n return from({ seconds: value })\n}\n\nexport const toSeconds = (duration: DurationLike): number => {\n return from(duration).total(Chrono.TimeUnit.Second)\n}\n\nexport const fromMinutes = (value: number): Duration => {\n return from({ minutes: value })\n}\n\nexport const toMinutes = (duration: DurationLike): number => {\n return from(duration).total(Chrono.TimeUnit.Minute)\n}\n\nexport const fromHours = (value: number): Duration => {\n return from({ hours: value })\n}\n\nexport const toHours = (duration: DurationLike): number => {\n return from(duration).total(Chrono.TimeUnit.Hour)\n}\n\nexport const fromUnit = (value: number, timeUnit: Chrono.TimeUnit): Duration => {\n switch (timeUnit) {\n case Chrono.TimeUnit.Nanosecond:\n return from({ nanoseconds: value })\n case Chrono.TimeUnit.Microsecond:\n return from({ microseconds: value })\n case Chrono.TimeUnit.Millisecond:\n return from({ milliseconds: value })\n case Chrono.TimeUnit.Second:\n return from({ seconds: value })\n case Chrono.TimeUnit.Minute:\n return from({ minutes: value })\n case Chrono.TimeUnit.Hour:\n return from({ hours: value })\n }\n}\n\nexport const toUnit = (duration: DurationLike, timeUnit: Chrono.TimeUnit): number => {\n return from(duration).total(timeUnit)\n}\n\nexport const isZero = (duration: DurationLike): boolean => {\n return EqualBy(from(duration), Zero)\n}\n\nexport const round = (element: DurationLike, unit: Chrono.TimeUnit): Duration => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport const add = (...durations: Array<DurationLike>): Duration => {\n return durations.map((it) => from(it)).reduce((first, second) => first.add(second), Zero)\n}\n\nexport const subtract = (...durations: Array<DurationLike>): Duration => {\n if (durations.length === 0) {\n return Zero\n }\n\n const instances = durations.map((it) => from(it))\n return instances.slice(1).reduce((result, current) => result.subtract(current), instances[0]!)\n}\n\nexport const negate = (element: DurationLike): Duration => {\n return from(element).negated()\n}\n\nexport function isEqual(element: DurationLike, other: DurationLike): boolean\nexport function isEqual(element: DurationLike | null, other: DurationLike | null): boolean\nexport function isEqual(element: DurationLike | undefined, other: DurationLike | undefined): boolean\nexport function isEqual(element: DurationLike | null | undefined, other: DurationLike | null | undefined): boolean {\n if (Objects.isNil(element) || Objects.isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isLess = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isGreater = (element: DurationLike, other: DurationLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const Zero = from({ nanoseconds: 0 })\nexport const OneMillisecond = fromMilliseconds(1)\nexport const OneSecond = fromSeconds(1)\nexport const OneMinute = fromMinutes(1)\nexport const OneHour = fromHours(1)\nexport const OneDay = fromHours(24)\n"],"mappings":";AAAA,OAAO,SAAS;AAChB,SAAS,gBAAgB;AACzB,YAAY,kBAAkB;AAG9B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,YAAY,aAAa;AAGlB,IAAM,YAAyB,6BAAgB,UAAU;AAsBzD,SAAS,KAAK,OAA8E;AACjG,MAAY,cAAM,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,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E,SAAO,UAAU,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,MAAM,IAAI,MAAM,GAAG,IAAI;AAC1F;AAEO,IAAM,WAAW,IAAI,cAA6C;AACvE,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,UAAU,IAAI,CAAC,OAAO,KAAK,EAAE,CAAC;AAChD,SAAO,UAAU,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,YAAY,OAAO,SAAS,OAAO,GAAG,UAAU,CAAC,CAAE;AAC/F;AAEO,IAAM,SAAS,CAAC,YAAoC;AACzD,SAAO,KAAK,OAAO,EAAE,QAAQ;AAC/B;AAKO,SAAS,QAAQ,SAA0C,OAAiD;AACjH,MAAY,cAAM,OAAO,KAAa,cAAM,KAAK,GAAG;AAClD,WAAO,YAAY;AAAA,EACrB;AAEA,SAAO,QAAQ,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC;AAC3C;AAEO,IAAM,SAAS,CAAC,SAAuB,UAAiC;AAC7E,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,YAAY,CAAC,SAAuB,UAAiC;AAChF,SAAO,UAAU,KAAK,OAAO,GAAG,KAAK,KAAK,CAAC,IAAI;AACjD;AAEO,IAAM,OAAO,KAAK,EAAE,aAAa,EAAE,CAAC;AACpC,IAAM,iBAAiB,iBAAiB,CAAC;AACzC,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,YAAY,YAAY,CAAC;AAC/B,IAAM,UAAU,UAAU,CAAC;AAC3B,IAAM,SAAS,UAAU,EAAE;","names":["it"]}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
import * as ResourceKeys from '@bessemer/cornerstone/resource-key';
|
|
2
3
|
import { NominalType } from '@bessemer/cornerstone/types';
|
|
3
4
|
import { Comparator } from '@bessemer/cornerstone/comparator';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
5
|
+
import * as Equalitors from '@bessemer/cornerstone/equalitor';
|
|
6
|
+
import * as Results from '@bessemer/cornerstone/result';
|
|
7
|
+
import * as ErrorEvents from '@bessemer/cornerstone/error/error-event';
|
|
6
8
|
import Zod from 'zod';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { DateTimeFormatOptions } from '@bessemer/cornerstone/temporal/plain-date-time';
|
|
9
|
+
import * as Clocks from '@bessemer/cornerstone/temporal/clock';
|
|
10
|
+
import * as Durations from '@bessemer/cornerstone/temporal/duration';
|
|
11
|
+
import * as Chrono from '@bessemer/cornerstone/temporal/chrono';
|
|
11
12
|
import { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id';
|
|
13
|
+
import * as PlainDateTimes from '@bessemer/cornerstone/temporal/plain-date-time';
|
|
14
|
+
import { Locale } from '@bessemer/cornerstone/intl/locale';
|
|
12
15
|
export type Instant = Temporal.Instant;
|
|
13
|
-
export declare const Namespace:
|
|
16
|
+
export declare const Namespace: ResourceKeys.ResourceNamespace<"instant">;
|
|
14
17
|
export type InstantLiteral = NominalType<string, typeof Namespace>;
|
|
15
18
|
export type InstantLike = Instant | Date | InstantLiteral;
|
|
16
19
|
export declare function from(value: InstantLike | string): Instant;
|
|
@@ -18,8 +21,8 @@ export declare function from(value: InstantLike | string | null): Instant | null
|
|
|
18
21
|
export declare function from(value: InstantLike | string | undefined): Instant | undefined;
|
|
19
22
|
export declare function from(value: InstantLike | string | null | undefined): Instant | null | undefined;
|
|
20
23
|
export declare const CompareBy: Comparator<Instant>;
|
|
21
|
-
export declare const EqualBy:
|
|
22
|
-
export declare const parseString: (value: string) => Result<Instant, ErrorEvent>;
|
|
24
|
+
export declare const EqualBy: Equalitors.Equalitor<Temporal.Instant>;
|
|
25
|
+
export declare const parseString: (value: string) => Results.Result<Instant, ErrorEvents.ErrorEvent>;
|
|
23
26
|
export declare function toLiteral(value: InstantLike): InstantLiteral;
|
|
24
27
|
export declare function toLiteral(value: InstantLike | null): InstantLiteral | null;
|
|
25
28
|
export declare function toLiteral(value: InstantLike | undefined): InstantLiteral | undefined;
|
|
@@ -34,16 +37,16 @@ export declare const isInstant: (value: unknown) => value is Instant;
|
|
|
34
37
|
export declare const now: (clock?: {
|
|
35
38
|
readonly zone: TimeZoneId;
|
|
36
39
|
instant(): Instant;
|
|
37
|
-
withZone(zone: TimeZoneId):
|
|
40
|
+
withZone(zone: TimeZoneId): Clocks.Clock;
|
|
38
41
|
}) => Instant;
|
|
39
|
-
export declare const add: (element: InstantLike, duration: DurationLike) => Instant;
|
|
40
|
-
export declare const subtract: (element: InstantLike, duration: DurationLike) => Instant;
|
|
41
|
-
export declare const until: (element: InstantLike, other: InstantLike) => Duration;
|
|
42
|
-
export declare const round: (element: InstantLike, unit: TimeUnit) => Instant;
|
|
42
|
+
export declare const add: (element: InstantLike, duration: Durations.DurationLike) => Instant;
|
|
43
|
+
export declare const subtract: (element: InstantLike, duration: Durations.DurationLike) => Instant;
|
|
44
|
+
export declare const until: (element: InstantLike, other: InstantLike) => Durations.Duration;
|
|
45
|
+
export declare const round: (element: InstantLike, unit: Chrono.TimeUnit) => Instant;
|
|
43
46
|
export declare function isEqual(element: InstantLike, other: InstantLike): boolean;
|
|
44
47
|
export declare function isEqual(element: InstantLike | null, other: InstantLike | null): boolean;
|
|
45
48
|
export declare function isEqual(element: InstantLike | undefined, other: InstantLike | undefined): boolean;
|
|
46
49
|
export declare const isBefore: (element: InstantLike, other: InstantLike) => boolean;
|
|
47
50
|
export declare const isAfter: (element: InstantLike, other: InstantLike) => boolean;
|
|
48
|
-
export declare const format: (element: InstantLike, timeZone: TimeZoneId, locale: Locale, options: DateTimeFormatOptions) => string;
|
|
51
|
+
export declare const format: (element: InstantLike, timeZone: TimeZoneId, locale: Locale, options: PlainDateTimes.DateTimeFormatOptions) => string;
|
|
49
52
|
//# sourceMappingURL=instant.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instant.d.ts","sourceRoot":"","sources":["../../src/temporal/instant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"instant.d.ts","sourceRoot":"","sources":["../../src/temporal/instant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAC7D,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,WAAW,MAAM,yCAAyC,CAAA;AAGtE,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAA;AAC9D,OAAO,KAAK,SAAS,MAAM,yCAAyC,CAAA;AACpE,OAAO,KAAK,MAAM,MAAM,uCAAuC,CAAA;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AACxE,OAAO,KAAK,cAAc,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE1D,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;AACtC,eAAO,MAAM,SAAS,2CAA0C,CAAA;AAChE,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC,CAAA;AAClE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,IAAI,GAAG,cAAc,CAAA;AAEzD,wBAAgB,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAA;AAC1D,wBAAgB,IAAI,CAAC,K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|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
3
|
+
import * as ResourceKeys from "@bessemer/cornerstone/resource-key";
|
|
4
|
+
import * as Equalitors from "@bessemer/cornerstone/equalitor";
|
|
5
|
+
import * as Results from "@bessemer/cornerstone/result";
|
|
6
|
+
import * as ErrorEvents from "@bessemer/cornerstone/error/error-event";
|
|
7
|
+
import * as Errors from "@bessemer/cornerstone/error/error";
|
|
8
|
+
import * as ZodUtil from "@bessemer/cornerstone/zod-util";
|
|
9
9
|
import Zod from "zod";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (isNil(value)) {
|
|
10
|
+
import * as Clocks from "@bessemer/cornerstone/temporal/clock";
|
|
11
|
+
import * as Durations from "@bessemer/cornerstone/temporal/duration";
|
|
12
|
+
import * as Chrono from "@bessemer/cornerstone/temporal/chrono";
|
|
13
|
+
import * as Strings from "@bessemer/cornerstone/string";
|
|
14
|
+
import * as Objects from "@bessemer/cornerstone/object";
|
|
15
|
+
import * as PlainDateTimes from "@bessemer/cornerstone/temporal/plain-date-time";
|
|
16
|
+
var Namespace = ResourceKeys.createNamespace("instant");
|
|
17
|
+
function from2(value) {
|
|
18
|
+
if (Objects.isNil(value)) {
|
|
20
19
|
return value;
|
|
21
20
|
}
|
|
22
21
|
if (value instanceof Temporal.Instant) {
|
|
23
22
|
return value;
|
|
24
23
|
}
|
|
25
|
-
if (isString(value)) {
|
|
26
|
-
return unpackResult(parseString(value));
|
|
24
|
+
if (Strings.isString(value)) {
|
|
25
|
+
return ErrorEvents.unpackResult(parseString(value));
|
|
27
26
|
}
|
|
28
27
|
return Temporal.Instant.fromEpochMilliseconds(value.getTime());
|
|
29
28
|
}
|
|
30
29
|
var CompareBy = (first, second) => Temporal.Instant.compare(first, second);
|
|
31
|
-
var EqualBy = fromComparator(CompareBy);
|
|
30
|
+
var EqualBy = Equalitors.fromComparator(CompareBy);
|
|
32
31
|
var parseString = (value) => {
|
|
33
32
|
try {
|
|
34
|
-
return success(Temporal.Instant.from(value));
|
|
33
|
+
return Results.success(Temporal.Instant.from(value));
|
|
35
34
|
} catch (e) {
|
|
36
|
-
if (!isError(e)) {
|
|
35
|
+
if (!Errors.isError(e)) {
|
|
37
36
|
throw e;
|
|
38
37
|
}
|
|
39
|
-
return failure(invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
38
|
+
return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }));
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
function toLiteral(value) {
|
|
43
|
-
if (isNil(value)) {
|
|
42
|
+
if (Objects.isNil(value)) {
|
|
44
43
|
return value;
|
|
45
44
|
}
|
|
46
|
-
return instantToLiteral(
|
|
45
|
+
return Chrono.instantToLiteral(from2(value));
|
|
47
46
|
}
|
|
48
47
|
function toDate(value) {
|
|
49
|
-
if (isNil(value)) {
|
|
48
|
+
if (Objects.isNil(value)) {
|
|
50
49
|
return value;
|
|
51
50
|
}
|
|
52
|
-
return new Date(
|
|
51
|
+
return new Date(from2(value).epochMilliseconds);
|
|
53
52
|
}
|
|
54
|
-
var SchemaLiteral = structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2))).meta({
|
|
53
|
+
var SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it) => Results.map(parseString(it), (it2) => toLiteral(it2))).meta({
|
|
55
54
|
type: "string",
|
|
56
55
|
format: "date-time"
|
|
57
56
|
});
|
|
58
|
-
var SchemaInstance = structuredTransform(Zod.string(), parseString).meta({
|
|
57
|
+
var SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString).meta({
|
|
59
58
|
type: "string",
|
|
60
59
|
format: "date-time"
|
|
61
60
|
});
|
|
62
|
-
var isInstant = _isInstant;
|
|
63
|
-
var now = (clock =
|
|
61
|
+
var isInstant = Chrono._isInstant;
|
|
62
|
+
var now = (clock = Clocks.Default) => {
|
|
64
63
|
return clock.instant();
|
|
65
64
|
};
|
|
66
65
|
var add = (element, duration) => {
|
|
67
|
-
return
|
|
66
|
+
return from2(element).add(Durations.from(duration));
|
|
68
67
|
};
|
|
69
68
|
var subtract = (element, duration) => {
|
|
70
|
-
return
|
|
69
|
+
return from2(element).subtract(Durations.from(duration));
|
|
71
70
|
};
|
|
72
71
|
var until = (element, other) => {
|
|
73
|
-
return
|
|
72
|
+
return from2(element).until(from2(other));
|
|
74
73
|
};
|
|
75
74
|
var round = (element, unit) => {
|
|
76
|
-
return
|
|
75
|
+
return from2(element).round({ smallestUnit: unit });
|
|
77
76
|
};
|
|
78
77
|
function isEqual(element, other) {
|
|
79
|
-
if (isNil(element) || isNil(other)) {
|
|
78
|
+
if (Objects.isNil(element) || Objects.isNil(other)) {
|
|
80
79
|
return element === other;
|
|
81
80
|
}
|
|
82
|
-
return EqualBy(
|
|
81
|
+
return EqualBy(from2(element), from2(other));
|
|
83
82
|
}
|
|
84
83
|
var isBefore = (element, other) => {
|
|
85
|
-
return CompareBy(
|
|
84
|
+
return CompareBy(from2(element), from2(other)) < 0;
|
|
86
85
|
};
|
|
87
86
|
var isAfter = (element, other) => {
|
|
88
|
-
return CompareBy(
|
|
87
|
+
return CompareBy(from2(element), from2(other)) > 0;
|
|
89
88
|
};
|
|
90
|
-
var
|
|
91
|
-
const plainDateTime = fromInstant(
|
|
92
|
-
return
|
|
89
|
+
var format2 = (element, timeZone, locale, options) => {
|
|
90
|
+
const plainDateTime = PlainDateTimes.fromInstant(from2(element), timeZone);
|
|
91
|
+
return PlainDateTimes.format(plainDateTime, locale, options);
|
|
93
92
|
};
|
|
94
93
|
export {
|
|
95
94
|
CompareBy,
|
|
@@ -98,8 +97,8 @@ export {
|
|
|
98
97
|
SchemaInstance,
|
|
99
98
|
SchemaLiteral,
|
|
100
99
|
add,
|
|
101
|
-
format,
|
|
102
|
-
from,
|
|
100
|
+
format2 as format,
|
|
101
|
+
from2 as from,
|
|
103
102
|
isAfter,
|
|
104
103
|
isBefore,
|
|
105
104
|
isEqual,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/temporal/instant.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/temporal/instant.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill'\nimport * as ResourceKeys from '@bessemer/cornerstone/resource-key'\nimport { NominalType } from '@bessemer/cornerstone/types'\nimport { Comparator } from '@bessemer/cornerstone/comparator'\nimport * as Equalitors from '@bessemer/cornerstone/equalitor'\nimport * as Results from '@bessemer/cornerstone/result'\nimport * as ErrorEvents from '@bessemer/cornerstone/error/error-event'\nimport * as Errors from '@bessemer/cornerstone/error/error'\nimport * as ZodUtil from '@bessemer/cornerstone/zod-util'\nimport Zod from 'zod'\nimport * as Clocks from '@bessemer/cornerstone/temporal/clock'\nimport * as Durations from '@bessemer/cornerstone/temporal/duration'\nimport * as Chrono from '@bessemer/cornerstone/temporal/chrono'\nimport * as Strings from '@bessemer/cornerstone/string'\nimport * as Objects from '@bessemer/cornerstone/object'\nimport { TimeZoneId } from '@bessemer/cornerstone/temporal/time-zone-id'\nimport * as PlainDateTimes from '@bessemer/cornerstone/temporal/plain-date-time'\nimport { Locale } from '@bessemer/cornerstone/intl/locale'\n\nexport type Instant = Temporal.Instant\nexport const Namespace = ResourceKeys.createNamespace('instant')\nexport type InstantLiteral = NominalType<string, typeof Namespace>\nexport type InstantLike = Instant | Date | InstantLiteral\n\nexport function from(value: InstantLike | string): Instant\nexport function from(value: InstantLike | string | null): Instant | null\nexport function from(value: InstantLike | string | undefined): Instant | undefined\nexport function from(value: InstantLike | string | null | undefined): Instant | null | undefined\nexport function from(value: InstantLike | string | null | undefined): Instant | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n if (value instanceof Temporal.Instant) {\n return value\n }\n if (Strings.isString(value)) {\n return ErrorEvents.unpackResult(parseString(value))\n }\n\n return Temporal.Instant.fromEpochMilliseconds(value.getTime())\n}\n\nexport const CompareBy: Comparator<Instant> = (first: Instant, second: Instant): number => Temporal.Instant.compare(first, second)\nexport const EqualBy = Equalitors.fromComparator(CompareBy)\n\nexport const parseString = (value: string): Results.Result<Instant, ErrorEvents.ErrorEvent> => {\n try {\n return Results.success(Temporal.Instant.from(value))\n } catch (e) {\n if (!Errors.isError(e)) {\n throw e\n }\n\n return Results.failure(ErrorEvents.invalidValue(value, { namespace: Namespace, message: e.message }))\n }\n}\n\nexport function toLiteral(value: InstantLike): InstantLiteral\nexport function toLiteral(value: InstantLike | null): InstantLiteral | null\nexport function toLiteral(value: InstantLike | undefined): InstantLiteral | undefined\nexport function toLiteral(value: InstantLike | null | undefined): InstantLiteral | null | undefined\nexport function toLiteral(value: InstantLike | null | undefined): InstantLiteral | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n return Chrono.instantToLiteral(from(value))\n}\n\nexport function toDate(value: InstantLike): Date\nexport function toDate(value: InstantLike | null): Date | null\nexport function toDate(value: InstantLike | undefined): Date | undefined\nexport function toDate(value: InstantLike | null | undefined): Date | null | undefined\nexport function toDate(value: InstantLike | null | undefined): Date | null | undefined {\n if (Objects.isNil(value)) {\n return value\n }\n\n return new Date(from(value).epochMilliseconds)\n}\n\nexport const SchemaLiteral = ZodUtil.structuredTransform(Zod.string(), (it: string) => Results.map(parseString(it), (it) => toLiteral(it))).meta({\n type: 'string',\n format: 'date-time',\n})\n\nexport const SchemaInstance = ZodUtil.structuredTransform(Zod.string(), parseString).meta({\n type: 'string',\n format: 'date-time',\n})\n\nexport const isInstant = Chrono._isInstant\n\nexport const now = (clock = Clocks.Default): Instant => {\n return clock.instant()\n}\n\nexport const add = (element: InstantLike, duration: Durations.DurationLike): Instant => {\n return from(element).add(Durations.from(duration))\n}\n\nexport const subtract = (element: InstantLike, duration: Durations.DurationLike): Instant => {\n return from(element).subtract(Durations.from(duration))\n}\n\nexport const until = (element: InstantLike, other: InstantLike): Durations.Duration => {\n return from(element).until(from(other))\n}\n\nexport const round = (element: InstantLike, unit: Chrono.TimeUnit): Instant => {\n return from(element).round({ smallestUnit: unit })\n}\n\nexport function isEqual(element: InstantLike, other: InstantLike): boolean\nexport function isEqual(element: InstantLike | null, other: InstantLike | null): boolean\nexport function isEqual(element: InstantLike | undefined, other: InstantLike | undefined): boolean\nexport function isEqual(element: InstantLike | null | undefined, other: InstantLike | null | undefined): boolean {\n if (Objects.isNil(element) || Objects.isNil(other)) {\n return element === other\n }\n\n return EqualBy(from(element), from(other))\n}\n\nexport const isBefore = (element: InstantLike, other: InstantLike): boolean => {\n return CompareBy(from(element), from(other)) < 0\n}\n\nexport const isAfter = (element: InstantLike, other: InstantLike): boolean => {\n return CompareBy(from(element), from(other)) > 0\n}\n\nexport const format = (element: InstantLike, timeZone: TimeZoneId, locale: Locale, options: PlainDateTimes.DateTimeFormatOptions): string => {\n const plainDateTime = PlainDateTimes.fromInstant(from(element), timeZone)\n return PlainDateTimes.format(plainDateTime, locale, options)\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,YAAY,kBAAkB;AAG9B,YAAY,gBAAgB;AAC5B,YAAY,aAAa;AACzB,YAAY,iBAAiB;AAC7B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,OAAO,SAAS;AAChB,YAAY,YAAY;AACxB,YAAY,eAAe;AAC3B,YAAY,YAAY;AACxB,YAAY,aAAa;AACzB,YAAY,aAAa;AAEzB,YAAY,oBAAoB;AAIzB,IAAM,YAAyB,6BAAgB,SAAS;AAQxD,SAASA,MAAK,OAA4E;AAC/F,MAAY,cAAM,KAAK,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO;AAAA,EACT;AACA,MAAY,iBAAS,KAAK,GAAG;AAC3B,WAAmB,yBAAa,YAAY,KAAK,CAAC;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