@bodil/core 0.5.3 → 0.5.4
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/package.json +1 -1
- package/src/disposable.ts +25 -22
- package/dist/assert.d.ts +0 -93
- package/dist/assert.js +0 -217
- package/dist/assert.js.map +0 -1
- package/dist/assert.test.d.ts +0 -1
- package/dist/assert.test.js +0 -51
- package/dist/assert.test.js.map +0 -1
- package/dist/async/abortable-promise.d.ts +0 -71
- package/dist/async/abortable-promise.js +0 -203
- package/dist/async/abortable-promise.js.map +0 -1
- package/dist/async/abortable-promise.test.d.ts +0 -1
- package/dist/async/abortable-promise.test.js +0 -134
- package/dist/async/abortable-promise.test.js.map +0 -1
- package/dist/async/emitter.d.ts +0 -10
- package/dist/async/emitter.js +0 -22
- package/dist/async/emitter.js.map +0 -1
- package/dist/async/emitter.test.d.ts +0 -1
- package/dist/async/emitter.test.js +0 -49
- package/dist/async/emitter.test.js.map +0 -1
- package/dist/async.d.ts +0 -28
- package/dist/async.js +0 -52
- package/dist/async.js.map +0 -1
- package/dist/collections/lfu-cache.d.ts +0 -45
- package/dist/collections/lfu-cache.js +0 -107
- package/dist/collections/lfu-cache.js.map +0 -1
- package/dist/collections/lfu-cache.test.d.ts +0 -1
- package/dist/collections/lfu-cache.test.js +0 -29
- package/dist/collections/lfu-cache.test.js.map +0 -1
- package/dist/collections/linked-list.d.ts +0 -47
- package/dist/collections/linked-list.js +0 -129
- package/dist/collections/linked-list.js.map +0 -1
- package/dist/collections/lru-cache.d.ts +0 -45
- package/dist/collections/lru-cache.js +0 -84
- package/dist/collections/lru-cache.js.map +0 -1
- package/dist/collections/lru-cache.test.d.ts +0 -1
- package/dist/collections/lru-cache.test.js +0 -27
- package/dist/collections/lru-cache.test.js.map +0 -1
- package/dist/collections.d.ts +0 -7
- package/dist/collections.js +0 -8
- package/dist/collections.js.map +0 -1
- package/dist/decorators.d.ts +0 -12
- package/dist/decorators.js +0 -28
- package/dist/decorators.js.map +0 -1
- package/dist/decorators.test.d.ts +0 -1
- package/dist/decorators.test.js +0 -71
- package/dist/decorators.test.js.map +0 -1
- package/dist/disposable.d.ts +0 -138
- package/dist/disposable.js +0 -250
- package/dist/disposable.js.map +0 -1
- package/dist/disposable.test.d.ts +0 -1
- package/dist/disposable.test.js +0 -54
- package/dist/disposable.test.js.map +0 -1
- package/dist/fun.d.ts +0 -40
- package/dist/fun.js +0 -40
- package/dist/fun.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/order.d.ts +0 -55
- package/dist/order.js +0 -98
- package/dist/order.js.map +0 -1
- package/dist/order.test.d.ts +0 -1
- package/dist/order.test.js +0 -63
- package/dist/order.test.js.map +0 -1
- package/dist/time.d.ts +0 -80
- package/dist/time.js +0 -130
- package/dist/time.js.map +0 -1
- package/dist/time.test.d.ts +0 -1
- package/dist/time.test.js +0 -38
- package/dist/time.test.js.map +0 -1
- package/dist/types.d.ts +0 -17
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -1
package/dist/order.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sorting and ordering.
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import { None, Some } from "@bodil/opt";
|
|
6
|
-
export var Cmp;
|
|
7
|
-
(function (Cmp) {
|
|
8
|
-
/** Less than. */
|
|
9
|
-
Cmp[Cmp["LT"] = -1] = "LT";
|
|
10
|
-
/** Equal to. */
|
|
11
|
-
Cmp[Cmp["EQ"] = 0] = "EQ";
|
|
12
|
-
/** Greater than. */
|
|
13
|
-
Cmp[Cmp["GT"] = 1] = "GT";
|
|
14
|
-
})(Cmp || (Cmp = {}));
|
|
15
|
-
/**
|
|
16
|
-
* An order function which sorts {@link OperatorComparable} items in ascending
|
|
17
|
-
* order.
|
|
18
|
-
*/
|
|
19
|
-
export function ascending(left, right) {
|
|
20
|
-
return left < right ? Cmp.LT : left === right ? Cmp.EQ : Cmp.GT;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* An order function which sorts {@link OperatorComparable} items in descending
|
|
24
|
-
* order.
|
|
25
|
-
*/
|
|
26
|
-
export function descending(left, right) {
|
|
27
|
-
return left < right ? Cmp.GT : left === right ? Cmp.EQ : Cmp.LT;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Take an order function and invert its order.
|
|
31
|
-
*/
|
|
32
|
-
export function reverse(fn) {
|
|
33
|
-
return (left, right) => {
|
|
34
|
-
switch (fn(left, right)) {
|
|
35
|
-
case Cmp.LT:
|
|
36
|
-
return Cmp.GT;
|
|
37
|
-
case Cmp.GT:
|
|
38
|
-
return Cmp.LT;
|
|
39
|
-
case Cmp.EQ:
|
|
40
|
-
return Cmp.EQ;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Given a value, a sorted array and a comparison function by which the array
|
|
46
|
-
* has been sorted, find the lowest index at which the value could be inserted
|
|
47
|
-
* while maintaining sort order.
|
|
48
|
-
*/
|
|
49
|
-
export function bisectLow(cmp, array, key) {
|
|
50
|
-
let low = 0, high = array.length;
|
|
51
|
-
while (low < high) {
|
|
52
|
-
const mid = Math.floor((low + high) / 2);
|
|
53
|
-
if (cmp(key, array[mid]) === Cmp.GT) {
|
|
54
|
-
low = mid + 1;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
high = mid;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return low;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Given a value, a sorted array and a comparison function by which the array
|
|
64
|
-
* has been sorted, find the highest index at which the value could be inserted
|
|
65
|
-
* while maintaining sort order.
|
|
66
|
-
*/
|
|
67
|
-
export function bisectHigh(cmp, array, key) {
|
|
68
|
-
let low = 0, high = array.length;
|
|
69
|
-
while (low < high) {
|
|
70
|
-
const mid = Math.floor((low + high) / 2);
|
|
71
|
-
if (cmp(key, array[mid]) !== Cmp.LT) {
|
|
72
|
-
low = mid + 1;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
high = mid;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return low;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Given a value, a sorted array and a comparison function by which the array
|
|
82
|
-
* has been sorted, find the index of the specific value if it exists in the
|
|
83
|
-
* array.
|
|
84
|
-
*/
|
|
85
|
-
export function find(cmp, array, key) {
|
|
86
|
-
let index = bisectLow(cmp, array, key);
|
|
87
|
-
while (index < array.length) {
|
|
88
|
-
if (Object.is(key, array[index])) {
|
|
89
|
-
return Some(index);
|
|
90
|
-
}
|
|
91
|
-
index++;
|
|
92
|
-
if (index >= array.length || cmp(key, array[index]) !== Cmp.EQ) {
|
|
93
|
-
return None;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return None;
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=order.js.map
|
package/dist/order.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../src/order.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAe,IAAI,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,CAAN,IAAY,GAOX;AAPD,WAAY,GAAG;IACX,iBAAiB;IACjB,0BAAO,CAAA;IACP,gBAAgB;IAChB,yBAAM,CAAA;IACN,oBAAoB;IACpB,yBAAM,CAAA;AACV,CAAC,EAPW,GAAG,KAAH,GAAG,QAOd;AAcD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAA+B,IAAO,EAAE,KAAQ;IACrE,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GA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ETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "vitest";
|
|
2
|
-
import * as Order from "./order";
|
|
3
|
-
import "@bodil/opt-vitest";
|
|
4
|
-
const bisectLowNum = (array, key) => Order.bisectLow(Order.ascending, array, key);
|
|
5
|
-
const bisectHighNum = (array, key) => Order.bisectHigh(Order.ascending, array, key);
|
|
6
|
-
test("bisectLow", () => {
|
|
7
|
-
const list = [2, 4, 6, 8, 10];
|
|
8
|
-
expect(bisectLowNum(list, 1)).toEqual(0);
|
|
9
|
-
expect(bisectLowNum(list, 5)).toEqual(2);
|
|
10
|
-
expect(bisectLowNum(list, 6)).toEqual(2);
|
|
11
|
-
expect(bisectLowNum(list, 7)).toEqual(3);
|
|
12
|
-
expect(bisectLowNum(list, 12)).toEqual(5);
|
|
13
|
-
expect(bisectLowNum([], 1)).toEqual(0);
|
|
14
|
-
});
|
|
15
|
-
test("bisectLow dupes", () => {
|
|
16
|
-
const list = [1, 2, 3, 3, 3, 3, 4, 5];
|
|
17
|
-
expect(bisectLowNum(list, 0)).toEqual(0);
|
|
18
|
-
expect(bisectLowNum(list, 1)).toEqual(0);
|
|
19
|
-
expect(bisectLowNum(list, 5)).toEqual(7);
|
|
20
|
-
expect(bisectLowNum(list, 6)).toEqual(8);
|
|
21
|
-
// Should always return the dupe with the lowest index.
|
|
22
|
-
expect(bisectLowNum(list, 3)).toEqual(2);
|
|
23
|
-
});
|
|
24
|
-
test("bisectHigh", () => {
|
|
25
|
-
const list = [2, 4, 6, 8, 10];
|
|
26
|
-
expect(bisectHighNum(list, 1)).toEqual(0);
|
|
27
|
-
expect(bisectHighNum(list, 5)).toEqual(2);
|
|
28
|
-
expect(bisectHighNum(list, 6)).toEqual(3);
|
|
29
|
-
expect(bisectHighNum(list, 7)).toEqual(3);
|
|
30
|
-
expect(bisectHighNum(list, 12)).toEqual(5);
|
|
31
|
-
expect(bisectHighNum([], 1)).toEqual(0);
|
|
32
|
-
});
|
|
33
|
-
test("bisectHigh dupes", () => {
|
|
34
|
-
const list = [1, 2, 3, 3, 3, 3, 4, 5];
|
|
35
|
-
expect(bisectHighNum(list, 0)).toEqual(0);
|
|
36
|
-
expect(bisectHighNum(list, 1)).toEqual(1);
|
|
37
|
-
expect(bisectHighNum(list, 5)).toEqual(8);
|
|
38
|
-
expect(bisectHighNum(list, 6)).toEqual(8);
|
|
39
|
-
// Should always return the index after the last dupe.
|
|
40
|
-
expect(bisectHighNum(list, 3)).toEqual(6);
|
|
41
|
-
});
|
|
42
|
-
test("find", () => {
|
|
43
|
-
const e0 = { foo: 0 };
|
|
44
|
-
const e1 = { foo: 1 };
|
|
45
|
-
const e2 = { foo: 1 };
|
|
46
|
-
const e3 = { foo: 2 };
|
|
47
|
-
const eCmp = (a, b) => Order.ascending(a.foo, b.foo);
|
|
48
|
-
const findE = (array, key) => Order.find(eCmp, array, key);
|
|
49
|
-
const list = [e0, e1, e2, e3];
|
|
50
|
-
// Entries not in the list
|
|
51
|
-
expect(findE(list, { foo: 5 })).isNone();
|
|
52
|
-
expect(findE(list, { foo: -1 })).isNone();
|
|
53
|
-
// Entries in the list
|
|
54
|
-
expect(findE(list, e0)).isSome(0);
|
|
55
|
-
expect(findE(list, e1)).isSome(1);
|
|
56
|
-
expect(findE(list, e2)).isSome(2);
|
|
57
|
-
expect(findE(list, e3)).isSome(3);
|
|
58
|
-
// Entries comparing to entries in the list
|
|
59
|
-
expect(findE(list, { foo: 0 })).isNone();
|
|
60
|
-
expect(findE(list, { foo: 1 })).isNone();
|
|
61
|
-
expect(findE(list, { foo: 2 })).isNone();
|
|
62
|
-
});
|
|
63
|
-
//# sourceMappingURL=order.test.js.map
|
package/dist/order.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,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0,0 @@
|
|
|
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
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
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
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,O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AAC,KAAa;IAC/B,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,YAAoB;IACvC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/time.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "temporal-polyfill/global";
|
package/dist/time.test.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
package/dist/time.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,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AAC,CAAC"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|