@bodil/core 0.5.8 → 0.6.0
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 +0 -2
- package/dist/assert.js.map +1 -1
- package/dist/assert.test.d.ts +1 -0
- package/dist/assert.test.js +2 -2
- package/dist/assert.test.js.map +1 -1
- package/dist/async/abortable-promise.js +12 -9
- package/dist/async/abortable-promise.js.map +1 -1
- package/dist/async/abortable-promise.test.d.ts +1 -0
- package/dist/async/abortable-promise.test.js +10 -1
- package/dist/async/abortable-promise.test.js.map +1 -1
- 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 +2 -3
- package/dist/async/emitter.test.js.map +1 -1
- 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 +3 -3
- package/dist/collections/lfu-cache.js.map +1 -1
- package/dist/collections/lfu-cache.test.d.ts +1 -0
- package/dist/collections/lfu-cache.test.js +12 -12
- package/dist/collections/lfu-cache.test.js.map +1 -1
- package/dist/collections/linked-list.d.ts +47 -0
- package/dist/collections/linked-list.js +1 -1
- package/dist/collections/linked-list.js.map +1 -1
- package/dist/collections/lru-cache.d.ts +45 -0
- package/dist/collections/lru-cache.js +3 -3
- package/dist/collections/lru-cache.js.map +1 -1
- package/dist/collections/lru-cache.test.d.ts +1 -0
- package/dist/collections/lru-cache.test.js +10 -10
- package/dist/collections/lru-cache.test.js.map +1 -1
- 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.test.d.ts +1 -0
- package/dist/decorators.test.js +1 -1
- package/dist/decorators.test.js.map +1 -1
- package/dist/disposable.d.ts +122 -0
- package/dist/disposable.js +1 -1
- package/dist/disposable.js.map +1 -1
- package/dist/disposable.test.d.ts +1 -0
- package/dist/disposable.test.js +1 -1
- package/dist/disposable.test.js.map +1 -1
- 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 +10 -10
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/order.d.ts +55 -0
- package/dist/order.test.d.ts +1 -0
- package/dist/order.test.js +11 -11
- package/dist/order.test.js.map +1 -1
- package/dist/time.d.ts +80 -0
- package/dist/time.js +2 -2
- package/dist/time.js.map +1 -1
- package/dist/time.test.d.ts +1 -0
- package/dist/time.test.js +1 -1
- package/dist/time.test.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +18 -39
- package/src/assert.test.ts +3 -3
- package/src/assert.ts +2 -6
- package/src/async/abortable-promise.test.ts +14 -1
- package/src/async/abortable-promise.ts +13 -9
- package/src/async/emitter.test.ts +2 -3
- package/src/async/emitter.ts +2 -2
- package/src/async.ts +3 -4
- package/src/collections/lfu-cache.test.ts +12 -13
- package/src/collections/lfu-cache.ts +3 -3
- package/src/collections/linked-list.ts +1 -1
- package/src/collections/lru-cache.test.ts +10 -11
- package/src/collections/lru-cache.ts +3 -3
- package/src/collections.ts +3 -3
- package/src/decorators.test.ts +1 -1
- package/src/disposable.test.ts +1 -1
- package/src/disposable.ts +1 -1
- package/src/index.ts +10 -10
- package/src/order.test.ts +11 -12
- package/src/time.test.ts +1 -1
- package/src/time.ts +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { None, Some, type Option } from "@bodil/opt";
|
|
2
2
|
|
|
3
|
-
import { assert } from "../assert";
|
|
4
|
-
import { isDisposable } from "../disposable";
|
|
5
|
-
import { LinkedList, type ListNode } from "./linked-list";
|
|
3
|
+
import { assert } from "../assert.js";
|
|
4
|
+
import { isDisposable } from "../disposable.js";
|
|
5
|
+
import { LinkedList, type ListNode } from "./linked-list.js";
|
|
6
6
|
|
|
7
7
|
interface LRUNode<K, V> extends ListNode {
|
|
8
8
|
key: K;
|
package/src/collections.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { LinkedList, type ListNode } from "./collections/linked-list";
|
|
7
|
-
export { LFUCache, type LFUCacheOptions } from "./collections/lfu-cache";
|
|
8
|
-
export { LRUCache, type LRUCacheOptions } from "./collections/lru-cache";
|
|
6
|
+
export { LinkedList, type ListNode } from "./collections/linked-list.js";
|
|
7
|
+
export { LFUCache, type LFUCacheOptions } from "./collections/lfu-cache.js";
|
|
8
|
+
export { LRUCache, type LRUCacheOptions } from "./collections/lru-cache.js";
|
package/src/decorators.test.ts
CHANGED
package/src/disposable.test.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { Unsubscribable } from "type-fest/globals";
|
|
4
4
|
import { expect, test } from "vitest";
|
|
5
5
|
|
|
6
|
-
import { DisposableContext, isDisposifiable } from "./disposable";
|
|
6
|
+
import { DisposableContext, isDisposifiable } from "./disposable.js";
|
|
7
7
|
|
|
8
8
|
test("disposes resources", () => {
|
|
9
9
|
const context = new DisposableContext();
|
package/src/disposable.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { Constructor } from "type-fest";
|
|
9
9
|
import type { Unsubscribable } from "type-fest/globals";
|
|
10
10
|
|
|
11
|
-
import { assert } from "./assert";
|
|
11
|
+
import { assert } from "./assert.js";
|
|
12
12
|
|
|
13
13
|
// @ts-ignore polyfill Symbol.dispose if missing
|
|
14
14
|
Symbol.dispose ??= Symbol.for("Symbol.dispose");
|
package/src/index.ts
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import * as assert from "./assert";
|
|
7
|
-
import * as async from "./async";
|
|
8
|
-
import * as collections from "./collections";
|
|
9
|
-
import * as decorators from "./decorators";
|
|
10
|
-
import * as disposable from "./disposable";
|
|
11
|
-
import * as fun from "./fun";
|
|
12
|
-
import * as logger from "./logger";
|
|
13
|
-
import * as order from "./order";
|
|
14
|
-
import * as time from "./time";
|
|
15
|
-
import * as types from "./types";
|
|
6
|
+
import * as assert from "./assert.js";
|
|
7
|
+
import * as async from "./async.js";
|
|
8
|
+
import * as collections from "./collections.js";
|
|
9
|
+
import * as decorators from "./decorators.js";
|
|
10
|
+
import * as disposable from "./disposable.js";
|
|
11
|
+
import * as fun from "./fun.js";
|
|
12
|
+
import * as logger from "./logger.js";
|
|
13
|
+
import * as order from "./order.js";
|
|
14
|
+
import * as time from "./time.js";
|
|
15
|
+
import * as types from "./types.js";
|
|
16
16
|
|
|
17
17
|
export { assert, async, collections, decorators, disposable, fun, logger, order, time, types };
|
package/src/order.test.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { None, Some } from "@bodil/opt";
|
|
1
2
|
import { expect, test } from "vitest";
|
|
2
3
|
|
|
3
|
-
import * as Order from "./order";
|
|
4
|
-
|
|
5
|
-
import "@bodil/opt-vitest";
|
|
4
|
+
import * as Order from "./order.js";
|
|
6
5
|
|
|
7
6
|
const bisectLowNum = (array: Array<number>, key: number) =>
|
|
8
7
|
Order.bisectLow(Order.ascending, array, key);
|
|
@@ -69,17 +68,17 @@ test("find", () => {
|
|
|
69
68
|
const list: Array<FindTestData> = [e0, e1, e2, e3];
|
|
70
69
|
|
|
71
70
|
// Entries not in the list
|
|
72
|
-
expect(findE(list, { foo: 5 })).
|
|
73
|
-
expect(findE(list, { foo: -1 })).
|
|
71
|
+
expect(findE(list, { foo: 5 })).toEqual(None);
|
|
72
|
+
expect(findE(list, { foo: -1 })).toEqual(None);
|
|
74
73
|
|
|
75
74
|
// Entries in the list
|
|
76
|
-
expect(findE(list, e0)).
|
|
77
|
-
expect(findE(list, e1)).
|
|
78
|
-
expect(findE(list, e2)).
|
|
79
|
-
expect(findE(list, e3)).
|
|
75
|
+
expect(findE(list, e0)).toEqual(Some(0));
|
|
76
|
+
expect(findE(list, e1)).toEqual(Some(1));
|
|
77
|
+
expect(findE(list, e2)).toEqual(Some(2));
|
|
78
|
+
expect(findE(list, e3)).toEqual(Some(3));
|
|
80
79
|
|
|
81
80
|
// Entries comparing to entries in the list
|
|
82
|
-
expect(findE(list, { foo: 0 })).
|
|
83
|
-
expect(findE(list, { foo: 1 })).
|
|
84
|
-
expect(findE(list, { foo: 2 })).
|
|
81
|
+
expect(findE(list, { foo: 0 })).toEqual(None);
|
|
82
|
+
expect(findE(list, { foo: 1 })).toEqual(None);
|
|
83
|
+
expect(findE(list, { foo: 2 })).toEqual(None);
|
|
85
84
|
});
|
package/src/time.test.ts
CHANGED
package/src/time.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { present } from "./assert";
|
|
8
|
-
import { Cmp, type OrderFn } from "./order";
|
|
7
|
+
import { present } from "./assert.js";
|
|
8
|
+
import { Cmp, type OrderFn } from "./order.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Test if the given {@link Temporal.Instant} comes before a certain moment
|