@bodil/core 0.5.4 → 0.5.6
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/assert.d.ts +93 -0
- package/dist/assert.js +217 -0
- package/dist/assert.js.map +1 -0
- package/dist/assert.test.d.ts +1 -0
- package/dist/assert.test.js +51 -0
- package/dist/assert.test.js.map +1 -0
- package/dist/async/abortable-promise.d.ts +71 -0
- package/dist/async/abortable-promise.js +203 -0
- package/dist/async/abortable-promise.js.map +1 -0
- package/dist/async/abortable-promise.test.d.ts +1 -0
- package/dist/async/abortable-promise.test.js +134 -0
- package/dist/async/abortable-promise.test.js.map +1 -0
- package/dist/async/emitter.d.ts +10 -0
- package/dist/async/emitter.js +22 -0
- package/dist/async/emitter.js.map +1 -0
- package/dist/async/emitter.test.d.ts +1 -0
- package/dist/async/emitter.test.js +49 -0
- package/dist/async/emitter.test.js.map +1 -0
- package/dist/async.d.ts +28 -0
- package/dist/async.js +52 -0
- package/dist/async.js.map +1 -0
- package/dist/collections/lfu-cache.d.ts +45 -0
- package/dist/collections/lfu-cache.js +107 -0
- package/dist/collections/lfu-cache.js.map +1 -0
- package/dist/collections/lfu-cache.test.d.ts +1 -0
- package/dist/collections/lfu-cache.test.js +29 -0
- package/dist/collections/lfu-cache.test.js.map +1 -0
- package/dist/collections/linked-list.d.ts +47 -0
- package/dist/collections/linked-list.js +129 -0
- package/dist/collections/linked-list.js.map +1 -0
- package/dist/collections/lru-cache.d.ts +45 -0
- package/dist/collections/lru-cache.js +84 -0
- package/dist/collections/lru-cache.js.map +1 -0
- package/dist/collections/lru-cache.test.d.ts +1 -0
- package/dist/collections/lru-cache.test.js +27 -0
- package/dist/collections/lru-cache.test.js.map +1 -0
- package/dist/collections.d.ts +7 -0
- package/dist/collections.js +8 -0
- package/dist/collections.js.map +1 -0
- package/dist/decorators.d.ts +12 -0
- package/dist/decorators.js +28 -0
- package/dist/decorators.js.map +1 -0
- package/dist/decorators.test.d.ts +1 -0
- package/dist/decorators.test.js +71 -0
- package/dist/decorators.test.js.map +1 -0
- package/dist/disposable.d.ts +115 -0
- package/dist/disposable.js +251 -0
- package/dist/disposable.js.map +1 -0
- package/dist/disposable.test.d.ts +1 -0
- package/dist/disposable.test.js +54 -0
- package/dist/disposable.test.js.map +1 -0
- package/dist/fun.d.ts +40 -0
- package/dist/fun.js +40 -0
- package/dist/fun.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/order.d.ts +55 -0
- package/dist/order.js +98 -0
- package/dist/order.js.map +1 -0
- package/dist/order.test.d.ts +1 -0
- package/dist/order.test.js +63 -0
- package/dist/order.test.js.map +1 -0
- package/dist/time.d.ts +80 -0
- package/dist/time.js +130 -0
- package/dist/time.js.map +1 -0
- package/dist/time.test.d.ts +1 -0
- package/dist/time.test.js +38 -0
- package/dist/time.test.js.map +1 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +18 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.test.js","sourceRoot":"","sources":["../src/order.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,mBAAmB,CAAC;AAE3B,MAAM,YAAY,GAAG,CAAC,KAAoB,EAAE,GAAW,EAAE,EAAE,CACvD,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACjD,MAAM,aAAa,GAAG,CAAC,KAAoB,EAAE,GAAW,EAAE,EAAE,CACxD,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AAElD,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;IACnB,MAAM,IAAI,G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AC,CAAC,MAAM,EAAE,CAAC;IAE1C,sBAAsB;IACtB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAElC,2CAA2C;IAC3C,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACzC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACzC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;AAC7C,CAAC,CAAC,CAAC"}
|
package/dist/time.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for working with {@link Temporal}.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Test if the given {@link Temporal.Instant} comes before a certain moment
|
|
7
|
+
* in time.
|
|
8
|
+
*
|
|
9
|
+
* If `other` is unspecified, compare with the current time.
|
|
10
|
+
*
|
|
11
|
+
* If `other` is a {@link Temporal.Duration}, compare with that duration
|
|
12
|
+
* subtracted from the current time.
|
|
13
|
+
*
|
|
14
|
+
* If `other` is a {@link Temporal.Instant}, compare with that instant.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* time.isBefore(instant) // is `instant` in the past?
|
|
18
|
+
* time.isBefore(instant, otherInstant) // is `instant` before `otherInstant`?
|
|
19
|
+
* time.isBefore(instant, duration) // is `instant` more than `duration` ago?
|
|
20
|
+
*/
|
|
21
|
+
export declare function isBefore(instant: Temporal.Instant, other?: Temporal.Instant | Temporal.Duration): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Test if the given {@link Temporal.Instant} comes after a certain moment in
|
|
24
|
+
* time.
|
|
25
|
+
*
|
|
26
|
+
* If `other` is unspecified, compare with the current time.
|
|
27
|
+
*
|
|
28
|
+
* If `other` is a {@link Temporal.Duration}, compare with that duration added
|
|
29
|
+
* to the current time.
|
|
30
|
+
*
|
|
31
|
+
* If `other` is a {@link Temporal.Instant}, compare with that instant.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* time.isAfter(instant) // is `instant` in the future?
|
|
35
|
+
* time.isAfter(instant, otherInstant) // is `instant` after `otherInstant`?
|
|
36
|
+
* time.isAfter(instant, duration) // is `instant` more than `duration` into the future?
|
|
37
|
+
*/
|
|
38
|
+
export declare function isAfter(instant: Temporal.Instant, other?: Temporal.Instant | Temporal.Duration): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Find the shortest duration or earliest time given a series of
|
|
41
|
+
* {@link Temporal.Duration}s or {@link Temporal.Instant}s.
|
|
42
|
+
*/
|
|
43
|
+
export declare function min<T extends Temporal.Duration | Temporal.Instant>(...rest: Array<T>): T;
|
|
44
|
+
/**
|
|
45
|
+
* Find the longest duration or latest time given a series of
|
|
46
|
+
* {@link Temporal.Duration}s or {@link Temporal.Instant}s.
|
|
47
|
+
*/
|
|
48
|
+
export declare function max<T extends Temporal.Duration | Temporal.Instant>(...rest: Array<T>): T;
|
|
49
|
+
/**
|
|
50
|
+
* The current time as a {@link Temporal.Instant}.
|
|
51
|
+
*
|
|
52
|
+
* A shorthand for `Temporal.Now.instant()`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function now(): Temporal.Instant;
|
|
55
|
+
/**
|
|
56
|
+
* The current time as a {@link Temporal.ZonedDateTime}.
|
|
57
|
+
*
|
|
58
|
+
* A shorthand for `Temporal.Now.zonedDateTimeISO()`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function nowZ(): Temporal.ZonedDateTime;
|
|
61
|
+
/**
|
|
62
|
+
* Construct a duration of the given number of days.
|
|
63
|
+
*/
|
|
64
|
+
export declare function days(days: number): Temporal.Duration;
|
|
65
|
+
/**
|
|
66
|
+
* Construct a duration of the given number of hours.
|
|
67
|
+
*/
|
|
68
|
+
export declare function hours(hours: number): Temporal.Duration;
|
|
69
|
+
/**
|
|
70
|
+
* Construct a duration of the given number of minutes.
|
|
71
|
+
*/
|
|
72
|
+
export declare function minutes(minutes: number): Temporal.Duration;
|
|
73
|
+
/**
|
|
74
|
+
* Construct a duration of the given number of seconds.
|
|
75
|
+
*/
|
|
76
|
+
export declare function seconds(seconds: number): Temporal.Duration;
|
|
77
|
+
/**
|
|
78
|
+
* Construct a duration of the given number of milliseconds.
|
|
79
|
+
*/
|
|
80
|
+
export declare function millis(milliseconds: number): Temporal.Duration;
|
package/dist/time.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for working with {@link Temporal}.
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { present } from "./assert";
|
|
7
|
+
import { Cmp } from "./order";
|
|
8
|
+
/**
|
|
9
|
+
* Test if the given {@link Temporal.Instant} comes before a certain moment
|
|
10
|
+
* in time.
|
|
11
|
+
*
|
|
12
|
+
* If `other` is unspecified, compare with the current time.
|
|
13
|
+
*
|
|
14
|
+
* If `other` is a {@link Temporal.Duration}, compare with that duration
|
|
15
|
+
* subtracted from the current time.
|
|
16
|
+
*
|
|
17
|
+
* If `other` is a {@link Temporal.Instant}, compare with that instant.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* time.isBefore(instant) // is `instant` in the past?
|
|
21
|
+
* time.isBefore(instant, otherInstant) // is `instant` before `otherInstant`?
|
|
22
|
+
* time.isBefore(instant, duration) // is `instant` more than `duration` ago?
|
|
23
|
+
*/
|
|
24
|
+
export function isBefore(instant, other) {
|
|
25
|
+
if (other === undefined) {
|
|
26
|
+
return Temporal.Instant.compare(Temporal.Now.instant(), instant) === Cmp.LT;
|
|
27
|
+
}
|
|
28
|
+
return (Temporal.Instant.compare(instant, other instanceof Temporal.Duration ? Temporal.Now.instant().subtract(other) : other) === Cmp.LT);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Test if the given {@link Temporal.Instant} comes after a certain moment in
|
|
32
|
+
* time.
|
|
33
|
+
*
|
|
34
|
+
* If `other` is unspecified, compare with the current time.
|
|
35
|
+
*
|
|
36
|
+
* If `other` is a {@link Temporal.Duration}, compare with that duration added
|
|
37
|
+
* to the current time.
|
|
38
|
+
*
|
|
39
|
+
* If `other` is a {@link Temporal.Instant}, compare with that instant.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* time.isAfter(instant) // is `instant` in the future?
|
|
43
|
+
* time.isAfter(instant, otherInstant) // is `instant` after `otherInstant`?
|
|
44
|
+
* time.isAfter(instant, duration) // is `instant` more than `duration` into the future?
|
|
45
|
+
*/
|
|
46
|
+
export function isAfter(instant, other) {
|
|
47
|
+
if (other === undefined) {
|
|
48
|
+
return Temporal.Instant.compare(Temporal.Now.instant(), instant) === Cmp.GT;
|
|
49
|
+
}
|
|
50
|
+
return (Temporal.Instant.compare(instant, other instanceof Temporal.Duration ? Temporal.Now.instant().add(other) : other) === Cmp.GT);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Find the shortest duration or earliest time given a series of
|
|
54
|
+
* {@link Temporal.Duration}s or {@link Temporal.Instant}s.
|
|
55
|
+
*/
|
|
56
|
+
export function min(...rest) {
|
|
57
|
+
let first = present(rest.shift(), "time.min() called with no arguments");
|
|
58
|
+
const compare = first instanceof Temporal.Duration
|
|
59
|
+
? Temporal.Duration.compare
|
|
60
|
+
: Temporal.Instant.compare;
|
|
61
|
+
for (const next of rest) {
|
|
62
|
+
if (compare(next, first) === Cmp.LT) {
|
|
63
|
+
first = next;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return first;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Find the longest duration or latest time given a series of
|
|
70
|
+
* {@link Temporal.Duration}s or {@link Temporal.Instant}s.
|
|
71
|
+
*/
|
|
72
|
+
export function max(...rest) {
|
|
73
|
+
let first = present(rest.shift(), "time.max() called with no arguments");
|
|
74
|
+
const compare = first instanceof Temporal.Duration
|
|
75
|
+
? Temporal.Duration.compare
|
|
76
|
+
: Temporal.Instant.compare;
|
|
77
|
+
for (const next of rest) {
|
|
78
|
+
if (compare(next, first) === Cmp.GT) {
|
|
79
|
+
first = next;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return first;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The current time as a {@link Temporal.Instant}.
|
|
86
|
+
*
|
|
87
|
+
* A shorthand for `Temporal.Now.instant()`.
|
|
88
|
+
*/
|
|
89
|
+
export function now() {
|
|
90
|
+
return Temporal.Now.instant();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The current time as a {@link Temporal.ZonedDateTime}.
|
|
94
|
+
*
|
|
95
|
+
* A shorthand for `Temporal.Now.zonedDateTimeISO()`.
|
|
96
|
+
*/
|
|
97
|
+
export function nowZ() {
|
|
98
|
+
return Temporal.Now.zonedDateTimeISO();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Construct a duration of the given number of days.
|
|
102
|
+
*/
|
|
103
|
+
export function days(days) {
|
|
104
|
+
return Temporal.Duration.from({ hours: days * 24 });
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Construct a duration of the given number of hours.
|
|
108
|
+
*/
|
|
109
|
+
export function hours(hours) {
|
|
110
|
+
return Temporal.Duration.from({ hours });
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Construct a duration of the given number of minutes.
|
|
114
|
+
*/
|
|
115
|
+
export function minutes(minutes) {
|
|
116
|
+
return Temporal.Duration.from({ minutes });
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Construct a duration of the given number of seconds.
|
|
120
|
+
*/
|
|
121
|
+
export function seconds(seconds) {
|
|
122
|
+
return Temporal.Duration.from({ seconds });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Construct a duration of the given number of milliseconds.
|
|
126
|
+
*/
|
|
127
|
+
export function millis(milliseconds) {
|
|
128
|
+
return Temporal.Duration.from({ milliseconds });
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=time.js.map
|
package/dist/time.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,GAAG,EAAgB,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,QAAQ,CACpB,OAAyB,EACzB,KAA4C;IAE5C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;IAChF,CAAC;IACD,OAAO,CACH,QAAQ,CAAC,OAAO,CAAC,OAAO,CACpB,OAAO,EACP,KAAK,YAAY,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,C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AACH,MAAM,UAAU,MAAM,CAAC,YAAoB;IACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "temporal-polyfill/global";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import "temporal-polyfill/global";
|
|
2
|
+
import { expect, test } from "vitest";
|
|
3
|
+
import { time } from ".";
|
|
4
|
+
test("time.min", () => {
|
|
5
|
+
const a = time.seconds(1);
|
|
6
|
+
const b = time.seconds(5);
|
|
7
|
+
const c = time.seconds(10);
|
|
8
|
+
expect(time.min(a, b, c)).toEqual(a);
|
|
9
|
+
});
|
|
10
|
+
test("time.max", () => {
|
|
11
|
+
const a = time.seconds(1);
|
|
12
|
+
const b = time.seconds(5);
|
|
13
|
+
const c = time.seconds(10);
|
|
14
|
+
expect(time.max(a, b, c)).toEqual(c);
|
|
15
|
+
});
|
|
16
|
+
test("time.isBefore", () => {
|
|
17
|
+
const a = time.now().subtract(time.seconds(10));
|
|
18
|
+
const b = a.subtract(time.seconds(10));
|
|
19
|
+
const c = time.now().add(time.minutes(10));
|
|
20
|
+
expect(time.isBefore(c)).toBeTruthy();
|
|
21
|
+
expect(time.isBefore(a)).toBeFalsy();
|
|
22
|
+
expect(time.isBefore(a, b)).toBeFalsy();
|
|
23
|
+
expect(time.isBefore(b, a)).toBeTruthy();
|
|
24
|
+
expect(time.isBefore(a, time.seconds(5))).toBeTruthy();
|
|
25
|
+
expect(time.isBefore(a, time.seconds(60))).toBeFalsy();
|
|
26
|
+
});
|
|
27
|
+
test("time.isAfter", () => {
|
|
28
|
+
const a = time.now().add(time.seconds(10));
|
|
29
|
+
const b = a.add(time.seconds(10));
|
|
30
|
+
const c = time.now().subtract(time.minutes(10));
|
|
31
|
+
expect(time.isAfter(c)).toBeTruthy();
|
|
32
|
+
expect(time.isAfter(a)).toBeFalsy();
|
|
33
|
+
expect(time.isAfter(a, b)).toBeFalsy();
|
|
34
|
+
expect(time.isAfter(b, a)).toBeTruthy();
|
|
35
|
+
expect(time.isAfter(a, time.seconds(5))).toBeTruthy();
|
|
36
|
+
expect(time.isAfter(a, time.seconds(60))).toBeFalsy();
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=time.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.test.js","sourceRoot":"","sources":["../src/time.test.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AAEzB,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;IAClB,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAE3B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;IAClB,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAE3B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC;AAEH,IAAI,CA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EAAE,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAEhD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACrC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IACvC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACxC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACtD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAC1D,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility types.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Constructs a type by excluding `undefined` from `T`.
|
|
7
|
+
*
|
|
8
|
+
* This is like {@link NonNullable} but it only removes `undefined`, not `null`.
|
|
9
|
+
*/
|
|
10
|
+
export type Present<T> = T extends undefined ? never : T;
|
|
11
|
+
/**
|
|
12
|
+
* Interface for classes which implement equality checking.
|
|
13
|
+
*/
|
|
14
|
+
export interface Equals {
|
|
15
|
+
/** Tests whether a given value is equal to this value. */
|
|
16
|
+
equals(other: unknown): boolean;
|
|
17
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodil/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "My TypeScript standard library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,30 +79,30 @@
|
|
|
79
79
|
"access": "public"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@bodil/opt": "^0.
|
|
83
|
-
"type-fest": "^5.
|
|
82
|
+
"@bodil/opt": "^1.0.0",
|
|
83
|
+
"type-fest": "^5.6.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@bodil/opt-vitest": "^1.1.0",
|
|
87
|
-
"@eslint/eslintrc": "^3.3.
|
|
88
|
-
"@eslint/js": "^
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
90
|
-
"@typescript-eslint/parser": "^8.
|
|
87
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
88
|
+
"@eslint/js": "^10.0.1",
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^8.60.0",
|
|
90
|
+
"@typescript-eslint/parser": "^8.60.0",
|
|
91
91
|
"@typhonjs-typedoc/ts-lib-docs": "^2024.12.25",
|
|
92
|
-
"eslint": "^
|
|
92
|
+
"eslint": "^10.4.0",
|
|
93
93
|
"eslint-config-prettier": "^10.1.8",
|
|
94
|
-
"eslint-plugin-jsdoc": "^
|
|
95
|
-
"globals": "^
|
|
96
|
-
"npm-run-all2": "^
|
|
97
|
-
"prettier": "^3.
|
|
98
|
-
"temporal-polyfill": "^0.3.
|
|
99
|
-
"typedoc": "^0.28.
|
|
94
|
+
"eslint-plugin-jsdoc": "^63.0.0",
|
|
95
|
+
"globals": "^17.6.0",
|
|
96
|
+
"npm-run-all2": "^9.0.1",
|
|
97
|
+
"prettier": "^3.8.3",
|
|
98
|
+
"temporal-polyfill": "^0.3.2",
|
|
99
|
+
"typedoc": "^0.28.19",
|
|
100
100
|
"typedoc-plugin-extras": "^4.0.1",
|
|
101
|
-
"typedoc-plugin-mdn-links": "^5.
|
|
101
|
+
"typedoc-plugin-mdn-links": "^5.1.1",
|
|
102
102
|
"typedoc-theme-fresh": "^0.2.3",
|
|
103
|
-
"typescript": "^
|
|
104
|
-
"vite-plugin-doctest": "^
|
|
105
|
-
"vitest": "^
|
|
103
|
+
"typescript": "^6.0.3",
|
|
104
|
+
"vite-plugin-doctest": "^2.0.0",
|
|
105
|
+
"vitest": "^4.1.7"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"build": "tsc",
|