@bodil/core 0.5.6 → 0.5.8

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 (81) hide show
  1. package/dist/assert.js.map +1 -1
  2. package/dist/assert.test.js +2 -2
  3. package/dist/assert.test.js.map +1 -1
  4. package/dist/async/abortable-promise.d.ts +1 -1
  5. package/dist/async/abortable-promise.js +1 -1
  6. package/dist/async/abortable-promise.js.map +1 -1
  7. package/dist/async/abortable-promise.test.js +9 -9
  8. package/dist/async/abortable-promise.test.js.map +1 -1
  9. package/dist/async/emitter.test.js +1 -1
  10. package/dist/async/emitter.test.js.map +1 -1
  11. package/dist/collections/lfu-cache.js +1 -1
  12. package/dist/collections/lfu-cache.js.map +1 -1
  13. package/dist/collections/lru-cache.js +1 -1
  14. package/dist/collections/lru-cache.js.map +1 -1
  15. package/dist/decorators.test.js.map +1 -1
  16. package/dist/disposable.js +17 -0
  17. package/dist/disposable.js.map +1 -1
  18. package/dist/disposable.test.js +19 -4
  19. package/dist/disposable.test.js.map +1 -1
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.js +2 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/logger.d.ts +19 -0
  24. package/dist/logger.js +26 -0
  25. package/dist/logger.js.map +1 -0
  26. package/dist/order.js.map +1 -1
  27. package/dist/order.test.js +1 -1
  28. package/dist/order.test.js.map +1 -1
  29. package/dist/time.test.js.map +1 -1
  30. package/package.json +40 -12
  31. package/src/assert.test.ts +11 -10
  32. package/src/assert.ts +9 -7
  33. package/src/async/abortable-promise.test.ts +24 -23
  34. package/src/async/abortable-promise.ts +17 -17
  35. package/src/async/emitter.test.ts +3 -2
  36. package/src/async.ts +2 -1
  37. package/src/collections/lfu-cache.ts +1 -1
  38. package/src/collections/linked-list.ts +1 -1
  39. package/src/collections/lru-cache.ts +2 -2
  40. package/src/decorators.test.ts +1 -0
  41. package/src/decorators.ts +1 -1
  42. package/src/disposable.test.ts +24 -4
  43. package/src/disposable.ts +20 -1
  44. package/src/index.ts +2 -1
  45. package/src/logger.ts +38 -0
  46. package/src/order.test.ts +2 -1
  47. package/src/order.ts +1 -1
  48. package/src/time.test.ts +1 -0
  49. package/src/time.ts +4 -4
  50. package/dist/assert.d.ts +0 -93
  51. package/dist/assert.test.d.ts +0 -1
  52. package/dist/async/abortable-promise.test.d.ts +0 -1
  53. package/dist/async/emitter.d.ts +0 -10
  54. package/dist/async/emitter.js +0 -22
  55. package/dist/async/emitter.js.map +0 -1
  56. package/dist/async/emitter.test.d.ts +0 -1
  57. package/dist/async.d.ts +0 -28
  58. package/dist/async.js +0 -52
  59. package/dist/async.js.map +0 -1
  60. package/dist/collections/lfu-cache.d.ts +0 -45
  61. package/dist/collections/lfu-cache.test.d.ts +0 -1
  62. package/dist/collections/linked-list.d.ts +0 -47
  63. package/dist/collections/lru-cache.d.ts +0 -45
  64. package/dist/collections/lru-cache.test.d.ts +0 -1
  65. package/dist/collections.d.ts +0 -7
  66. package/dist/collections.js +0 -8
  67. package/dist/collections.js.map +0 -1
  68. package/dist/decorators.d.ts +0 -12
  69. package/dist/decorators.test.d.ts +0 -1
  70. package/dist/disposable.d.ts +0 -115
  71. package/dist/disposable.test.d.ts +0 -1
  72. package/dist/fun.d.ts +0 -40
  73. package/dist/fun.js +0 -40
  74. package/dist/fun.js.map +0 -1
  75. package/dist/order.d.ts +0 -55
  76. package/dist/order.test.d.ts +0 -1
  77. package/dist/time.d.ts +0 -80
  78. package/dist/time.test.d.ts +0 -1
  79. package/dist/types.d.ts +0 -17
  80. package/dist/types.js +0 -6
  81. package/dist/types.js.map +0 -1
package/dist/fun.js DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * The functional programmer's toolkit.
3
- * @module
4
- */
5
- /**
6
- * Create a function that always returns `value`.
7
- *
8
- * @example
9
- * ```ts @import.meta.vitest
10
- * const alwaysFive: () => number = always(5);
11
- * expect(alwaysFive()).toEqual(5);
12
- * ```
13
- */
14
- export function always(value) {
15
- return () => value;
16
- }
17
- /**
18
- * The identity function: it just returns its argument unchanged.
19
- *
20
- * @example
21
- * ```ts @import.meta.vitest
22
- * expect(id(1337)).toEqual(1337);
23
- * expect(id("Hello Joe!")).toEqual("Hello Joe!");
24
- * ```
25
- */
26
- export function id(value) {
27
- return value;
28
- }
29
- /**
30
- * A function which does nothing and returns `void`.
31
- */
32
- export function nop() {
33
- // nop
34
- }
35
- export function sum(a, b) {
36
- // @ts-ignore
37
- // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
38
- return a + b;
39
- }
40
- //# sourceMappingURL=fun.js.map
package/dist/fun.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"fun.js","sourceRoot":"","sources":["../src/fun.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAI,KAAQ;IAC9B,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;AACvB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC1B,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG;IACf,MAAM;AACV,CAAC;AAcD,MAAM,UAAU,GAAG,CAAqC,CAAI,EAAE,CAAI;IAC9D,aAAa;IACb,qEAAqE;IACrE,OAAO,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC"}
package/dist/order.d.ts DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * Sorting and ordering.
3
- * @module
4
- */
5
- import { type Option } from "@bodil/opt";
6
- export declare enum Cmp {
7
- /** Less than. */
8
- LT = -1,
9
- /** Equal to. */
10
- EQ = 0,
11
- /** Greater than. */
12
- GT = 1
13
- }
14
- /**
15
- * An order function is a function which is used to compare two items, returning
16
- * a {@link Cmp} to describe the first item in relation to the second, eg.
17
- * {@link Cmp.GT} says the first item is greater than the second item.
18
- */
19
- export type OrderFn<A> = (left: A, right: A) => Cmp;
20
- /**
21
- * The set of types which can be compared using the `<` and `>` operators.
22
- */
23
- export type OperatorComparable = number | string | bigint | Date;
24
- /**
25
- * An order function which sorts {@link OperatorComparable} items in ascending
26
- * order.
27
- */
28
- export declare function ascending<A extends OperatorComparable>(left: A, right: A): Cmp;
29
- /**
30
- * An order function which sorts {@link OperatorComparable} items in descending
31
- * order.
32
- */
33
- export declare function descending<A extends OperatorComparable>(left: A, right: A): Cmp;
34
- /**
35
- * Take an order function and invert its order.
36
- */
37
- export declare function reverse<T>(fn: OrderFn<T>): OrderFn<T>;
38
- /**
39
- * Given a value, a sorted array and a comparison function by which the array
40
- * has been sorted, find the lowest index at which the value could be inserted
41
- * while maintaining sort order.
42
- */
43
- export declare function bisectLow<A>(cmp: OrderFn<A>, array: Array<A>, key: A): number;
44
- /**
45
- * Given a value, a sorted array and a comparison function by which the array
46
- * has been sorted, find the highest index at which the value could be inserted
47
- * while maintaining sort order.
48
- */
49
- export declare function bisectHigh<A>(cmp: OrderFn<A>, array: Array<A>, key: A): number;
50
- /**
51
- * Given a value, a sorted array and a comparison function by which the array
52
- * has been sorted, find the index of the specific value if it exists in the
53
- * array.
54
- */
55
- export declare function find<A>(cmp: OrderFn<A>, array: Array<A>, key: A): Option<number>;
@@ -1 +0,0 @@
1
- import "@bodil/opt-vitest";
package/dist/time.d.ts DELETED
@@ -1,80 +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;
@@ -1 +0,0 @@
1
- import "temporal-polyfill/global";
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
@@ -1,6 +0,0 @@
1
- /**
2
- * Utility types.
3
- * @module
4
- */
5
- export {};
6
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}