@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.
Files changed (89) hide show
  1. package/dist/assert.d.ts +93 -0
  2. package/dist/assert.js +0 -2
  3. package/dist/assert.js.map +1 -1
  4. package/dist/assert.test.d.ts +1 -0
  5. package/dist/assert.test.js +2 -2
  6. package/dist/assert.test.js.map +1 -1
  7. package/dist/async/abortable-promise.js +12 -9
  8. package/dist/async/abortable-promise.js.map +1 -1
  9. package/dist/async/abortable-promise.test.d.ts +1 -0
  10. package/dist/async/abortable-promise.test.js +10 -1
  11. package/dist/async/abortable-promise.test.js.map +1 -1
  12. package/dist/async/emitter.d.ts +10 -0
  13. package/dist/async/emitter.js +22 -0
  14. package/dist/async/emitter.js.map +1 -0
  15. package/dist/async/emitter.test.d.ts +1 -0
  16. package/dist/async/emitter.test.js +2 -3
  17. package/dist/async/emitter.test.js.map +1 -1
  18. package/dist/async.d.ts +28 -0
  19. package/dist/async.js +52 -0
  20. package/dist/async.js.map +1 -0
  21. package/dist/collections/lfu-cache.d.ts +45 -0
  22. package/dist/collections/lfu-cache.js +3 -3
  23. package/dist/collections/lfu-cache.js.map +1 -1
  24. package/dist/collections/lfu-cache.test.d.ts +1 -0
  25. package/dist/collections/lfu-cache.test.js +12 -12
  26. package/dist/collections/lfu-cache.test.js.map +1 -1
  27. package/dist/collections/linked-list.d.ts +47 -0
  28. package/dist/collections/linked-list.js +1 -1
  29. package/dist/collections/linked-list.js.map +1 -1
  30. package/dist/collections/lru-cache.d.ts +45 -0
  31. package/dist/collections/lru-cache.js +3 -3
  32. package/dist/collections/lru-cache.js.map +1 -1
  33. package/dist/collections/lru-cache.test.d.ts +1 -0
  34. package/dist/collections/lru-cache.test.js +10 -10
  35. package/dist/collections/lru-cache.test.js.map +1 -1
  36. package/dist/collections.d.ts +7 -0
  37. package/dist/collections.js +8 -0
  38. package/dist/collections.js.map +1 -0
  39. package/dist/decorators.d.ts +12 -0
  40. package/dist/decorators.test.d.ts +1 -0
  41. package/dist/decorators.test.js +1 -1
  42. package/dist/decorators.test.js.map +1 -1
  43. package/dist/disposable.d.ts +122 -0
  44. package/dist/disposable.js +1 -1
  45. package/dist/disposable.js.map +1 -1
  46. package/dist/disposable.test.d.ts +1 -0
  47. package/dist/disposable.test.js +1 -1
  48. package/dist/disposable.test.js.map +1 -1
  49. package/dist/fun.d.ts +40 -0
  50. package/dist/fun.js +40 -0
  51. package/dist/fun.js.map +1 -0
  52. package/dist/index.d.ts +10 -10
  53. package/dist/index.js +10 -10
  54. package/dist/index.js.map +1 -1
  55. package/dist/logger.js.map +1 -1
  56. package/dist/order.d.ts +55 -0
  57. package/dist/order.test.d.ts +1 -0
  58. package/dist/order.test.js +11 -11
  59. package/dist/order.test.js.map +1 -1
  60. package/dist/time.d.ts +80 -0
  61. package/dist/time.js +2 -2
  62. package/dist/time.js.map +1 -1
  63. package/dist/time.test.d.ts +1 -0
  64. package/dist/time.test.js +1 -1
  65. package/dist/time.test.js.map +1 -1
  66. package/dist/types.d.ts +17 -0
  67. package/dist/types.js +6 -0
  68. package/dist/types.js.map +1 -0
  69. package/package.json +18 -39
  70. package/src/assert.test.ts +3 -3
  71. package/src/assert.ts +2 -6
  72. package/src/async/abortable-promise.test.ts +14 -1
  73. package/src/async/abortable-promise.ts +13 -9
  74. package/src/async/emitter.test.ts +2 -3
  75. package/src/async/emitter.ts +2 -2
  76. package/src/async.ts +3 -4
  77. package/src/collections/lfu-cache.test.ts +12 -13
  78. package/src/collections/lfu-cache.ts +3 -3
  79. package/src/collections/linked-list.ts +1 -1
  80. package/src/collections/lru-cache.test.ts +10 -11
  81. package/src/collections/lru-cache.ts +3 -3
  82. package/src/collections.ts +3 -3
  83. package/src/decorators.test.ts +1 -1
  84. package/src/disposable.test.ts +1 -1
  85. package/src/disposable.ts +1 -1
  86. package/src/index.ts +10 -10
  87. package/src/order.test.ts +11 -12
  88. package/src/time.test.ts +1 -1
  89. 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;
@@ -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";
@@ -1,6 +1,6 @@
1
1
  import { expect, test } from "vitest";
2
2
 
3
- import { cache } from "./decorators";
3
+ import { cache } from "./decorators.js";
4
4
 
5
5
  test("@cache", () => {
6
6
  let called = 0;
@@ -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 })).isNone();
73
- expect(findE(list, { foo: -1 })).isNone();
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)).isSome(0);
77
- expect(findE(list, e1)).isSome(1);
78
- expect(findE(list, e2)).isSome(2);
79
- expect(findE(list, e3)).isSome(3);
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 })).isNone();
83
- expect(findE(list, { foo: 1 })).isNone();
84
- expect(findE(list, { foo: 2 })).isNone();
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
@@ -2,7 +2,7 @@ import "temporal-polyfill/global";
2
2
 
3
3
  import { expect, test } from "vitest";
4
4
 
5
- import { time } from ".";
5
+ import { time } from "./index.js";
6
6
 
7
7
  test("time.min", () => {
8
8
  const a = time.seconds(1);
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