shelving 1.120.0 → 1.121.1

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 (76) hide show
  1. package/{change → db}/Change.d.ts +6 -1
  2. package/{change → db}/Change.js +9 -0
  3. package/db/{LoggedProvider.d.ts → ChangesProvider.d.ts} +5 -5
  4. package/db/{LoggedProvider.js → ChangesProvider.js} +12 -12
  5. package/db/index.d.ts +2 -1
  6. package/db/index.js +3 -1
  7. package/index.d.ts +0 -1
  8. package/index.js +0 -1
  9. package/package.json +1 -3
  10. package/util/array.d.ts +2 -4
  11. package/util/array.js +6 -4
  12. package/util/async.d.ts +2 -2
  13. package/util/async.js +6 -2
  14. package/util/boolean.d.ts +5 -5
  15. package/util/boolean.js +15 -5
  16. package/util/class.d.ts +2 -2
  17. package/util/class.js +6 -2
  18. package/util/color.d.ts +1 -1
  19. package/util/color.js +9 -3
  20. package/util/data.d.ts +1 -1
  21. package/util/data.js +3 -1
  22. package/util/dictionary.d.ts +2 -2
  23. package/util/dictionary.js +6 -2
  24. package/util/dispose.d.ts +1 -1
  25. package/util/dispose.js +3 -1
  26. package/util/entry.d.ts +2 -2
  27. package/util/entry.js +6 -2
  28. package/util/equal.d.ts +16 -16
  29. package/util/equal.js +48 -16
  30. package/util/error.d.ts +1 -1
  31. package/util/error.js +4 -2
  32. package/util/function.d.ts +3 -3
  33. package/util/function.js +9 -3
  34. package/util/hydrate.js +4 -2
  35. package/util/jsx.d.ts +2 -2
  36. package/util/jsx.js +6 -2
  37. package/util/map.d.ts +2 -2
  38. package/util/map.js +6 -2
  39. package/util/merge.d.ts +1 -1
  40. package/util/merge.js +3 -1
  41. package/util/null.d.ts +5 -5
  42. package/util/null.js +15 -5
  43. package/util/number.d.ts +6 -6
  44. package/util/number.js +18 -6
  45. package/util/object.d.ts +1 -1
  46. package/util/object.js +3 -1
  47. package/util/optional.d.ts +1 -1
  48. package/util/optional.js +3 -1
  49. package/util/path.d.ts +2 -2
  50. package/util/path.js +6 -2
  51. package/util/query.d.ts +1 -1
  52. package/util/query.js +3 -1
  53. package/util/random.d.ts +4 -4
  54. package/util/random.js +15 -5
  55. package/util/regexp.d.ts +5 -6
  56. package/util/regexp.js +15 -5
  57. package/util/sequence.d.ts +1 -1
  58. package/util/sequence.js +3 -1
  59. package/util/serialise.js +12 -8
  60. package/util/set.d.ts +2 -2
  61. package/util/set.js +6 -2
  62. package/util/sort.d.ts +1 -1
  63. package/util/sort.js +3 -1
  64. package/util/string.d.ts +26 -16
  65. package/util/string.js +65 -34
  66. package/util/time.d.ts +6 -6
  67. package/util/time.js +21 -7
  68. package/util/undefined.d.ts +3 -3
  69. package/util/undefined.js +6 -2
  70. package/util/units.js +3 -1
  71. package/util/url.d.ts +1 -1
  72. package/util/url.js +3 -1
  73. package/util/validate.d.ts +1 -1
  74. package/util/validate.js +3 -1
  75. package/change/index.d.ts +0 -1
  76. package/change/index.js +0 -1
@@ -1,8 +1,9 @@
1
- import type { AsyncProvider, Provider } from "../db/Provider.js";
1
+ import type { AsyncProvider, Provider } from "./Provider.js";
2
2
  import type { ImmutableArray } from "../util/array.js";
3
3
  import type { DataKey, Database } from "../util/data.js";
4
4
  import type { ItemQuery } from "../util/item.js";
5
5
  import type { Updates } from "../util/update.js";
6
+ import { type Optional } from "../util/optional.js";
6
7
  /** A change to a database. */
7
8
  export interface Change {
8
9
  readonly action: string;
@@ -66,5 +67,9 @@ export type DatabaseChange<T extends Database> = ItemAddChange<T, DataKey<T>> |
66
67
  export type DatabaseChanges<T extends Database> = ImmutableArray<DatabaseChange<T>>;
67
68
  /** Write a single change to a synchronous provider and return an array of the changes that were written. */
68
69
  export declare function writeChange<T extends Database>(provider: Provider<T>, change: DatabaseChange<T>): DatabaseChange<T>;
70
+ /** Write a set of changes to a synchronous provider. */
71
+ export declare function writeChanges<T extends Database>(provider: Provider<T>, ...changes: Optional<DatabaseChange<T>>[]): DatabaseChanges<T>;
69
72
  /** Write a single change to an asynchronous provider and return the change that was written. */
70
73
  export declare function writeAsyncChange<T extends Database>(provider: AsyncProvider<T>, change: DatabaseChange<T>): Promise<DatabaseChange<T>>;
74
+ /** Write a set of changes to an asynchronous provider. */
75
+ export declare function writeAsyncChanges<T extends Database>(provider: AsyncProvider<T>, ...changes: Optional<DatabaseChange<T>>[]): Promise<DatabaseChanges<T>>;
@@ -1,3 +1,4 @@
1
+ import { notOptional } from "../util/optional.js";
1
2
  /** Write a single change to a synchronous provider and return an array of the changes that were written. */
2
3
  export function writeChange(provider, change) {
3
4
  const { action, collection, id, query } = change;
@@ -23,6 +24,10 @@ export function writeChange(provider, change) {
23
24
  }
24
25
  return change;
25
26
  }
27
+ /** Write a set of changes to a synchronous provider. */
28
+ export function writeChanges(provider, ...changes) {
29
+ return changes.filter(notOptional).map(change => writeChange(provider, change));
30
+ }
26
31
  /** Write a single change to an asynchronous provider and return the change that was written. */
27
32
  export async function writeAsyncChange(provider, change) {
28
33
  const { collection, action, id, query } = change;
@@ -48,3 +53,7 @@ export async function writeAsyncChange(provider, change) {
48
53
  }
49
54
  return change;
50
55
  }
56
+ /** Write a set of changes to an asynchronous provider. */
57
+ export function writeAsyncChanges(provider, ...changes) {
58
+ return Promise.all(changes.filter(notOptional).map(change => writeAsyncChange(provider, change)));
59
+ }
@@ -1,13 +1,13 @@
1
- import type { DatabaseChange, DatabaseChanges } from "../change/Change.js";
1
+ import type { DatabaseChange, DatabaseChanges } from "./Change.js";
2
2
  import type { MutableArray } from "../util/array.js";
3
3
  import type { DataKey, Database } from "../util/data.js";
4
4
  import type { ItemQuery } from "../util/item.js";
5
5
  import type { Updates } from "../util/update.js";
6
6
  import { AsyncThroughProvider, ThroughProvider } from "./ThroughProvider.js";
7
- /** Synchronous provider that keeps a log of any written changes to its `.written` property. */
8
- export declare class LoggedProvider<T extends Database> extends ThroughProvider<T> {
9
- get written(): DatabaseChanges<T>;
10
- readonly _written: MutableArray<DatabaseChange<T>>;
7
+ /** Synchronous provider that keeps a log of any written changes to its `.changes` property. */
8
+ export declare class ChangesProvider<T extends Database> extends ThroughProvider<T> {
9
+ get changes(): DatabaseChanges<T>;
10
+ readonly _changes: MutableArray<DatabaseChange<T>>;
11
11
  addItem<K extends DataKey<T>>(collection: K, data: T[K]): string;
12
12
  setItem<K extends DataKey<T>>(collection: K, id: string, data: T[K]): void;
13
13
  updateItem<K extends DataKey<T>>(collection: K, id: string, updates: Updates<T[K]>): void;
@@ -1,38 +1,38 @@
1
1
  import { AsyncThroughProvider, ThroughProvider } from "./ThroughProvider.js";
2
- /** Synchronous provider that keeps a log of any written changes to its `.written` property. */
3
- export class LoggedProvider extends ThroughProvider {
4
- get written() {
5
- return this._written;
2
+ /** Synchronous provider that keeps a log of any written changes to its `.changes` property. */
3
+ export class ChangesProvider extends ThroughProvider {
4
+ get changes() {
5
+ return this._changes;
6
6
  }
7
- _written = [];
7
+ _changes = [];
8
8
  addItem(collection, data) {
9
9
  const id = super.addItem(collection, data);
10
- this._written.push({ action: "set", collection, id, data });
10
+ this._changes.push({ action: "set", collection, id, data });
11
11
  return id;
12
12
  }
13
13
  setItem(collection, id, data) {
14
14
  super.setItem(collection, id, data);
15
- this._written.push({ action: "set", collection, id, data });
15
+ this._changes.push({ action: "set", collection, id, data });
16
16
  }
17
17
  updateItem(collection, id, updates) {
18
18
  super.updateItem(collection, id, updates);
19
- this._written.push({ action: "update", collection, id, updates });
19
+ this._changes.push({ action: "update", collection, id, updates });
20
20
  }
21
21
  deleteItem(collection, id) {
22
22
  super.deleteItem(collection, id);
23
- this._written.push({ action: "delete", collection, id });
23
+ this._changes.push({ action: "delete", collection, id });
24
24
  }
25
25
  setQuery(collection, query, data) {
26
26
  super.setQuery(collection, query, data);
27
- this._written.push({ action: "set", collection, query, data });
27
+ this._changes.push({ action: "set", collection, query, data });
28
28
  }
29
29
  updateQuery(collection, query, updates) {
30
30
  super.updateQuery(collection, query, updates);
31
- this._written.push({ action: "update", collection, query, updates });
31
+ this._changes.push({ action: "update", collection, query, updates });
32
32
  }
33
33
  deleteQuery(collection, query) {
34
34
  super.deleteQuery(collection, query);
35
- this._written.push({ action: "delete", collection, query });
35
+ this._changes.push({ action: "delete", collection, query });
36
36
  }
37
37
  }
38
38
  /** Asynchronous provider that keeps a log of any written changes to its `.written` property. */
package/db/index.d.ts CHANGED
@@ -3,7 +3,8 @@ export * from "./QueryStore.js";
3
3
  export * from "./Provider.js";
4
4
  export * from "./ThroughProvider.js";
5
5
  export * from "./CacheProvider.js";
6
+ export * from "./ChangesProvider.js";
6
7
  export * from "./DebugProvider.js";
7
- export * from "./LoggedProvider.js";
8
8
  export * from "./MemoryProvider.js";
9
9
  export * from "./ValidationProvider.js";
10
+ export * from "./Change.js";
package/db/index.js CHANGED
@@ -5,7 +5,9 @@ export * from "./QueryStore.js";
5
5
  export * from "./Provider.js";
6
6
  export * from "./ThroughProvider.js";
7
7
  export * from "./CacheProvider.js";
8
+ export * from "./ChangesProvider.js";
8
9
  export * from "./DebugProvider.js";
9
- export * from "./LoggedProvider.js";
10
10
  export * from "./MemoryProvider.js";
11
11
  export * from "./ValidationProvider.js";
12
+ // Util.
13
+ export * from "./Change.js";
package/index.d.ts CHANGED
@@ -4,7 +4,6 @@
4
4
  * - Modules that are for internal use, like `shelving/test`
5
5
  */
6
6
  export * from "./api/index.js";
7
- export * from "./change/index.js";
8
7
  export * from "./db/index.js";
9
8
  export * from "./error/index.js";
10
9
  export * from "./feedback/index.js";
package/index.js CHANGED
@@ -4,7 +4,6 @@
4
4
  * - Modules that are for internal use, like `shelving/test`
5
5
  */
6
6
  export * from "./api/index.js";
7
- export * from "./change/index.js";
8
7
  export * from "./db/index.js";
9
8
  export * from "./error/index.js";
10
9
  export * from "./feedback/index.js";
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.120.0",
14
+ "version": "1.121.1",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -22,7 +22,6 @@
22
22
  "exports": {
23
23
  ".": "./index.js",
24
24
  "./api": "./api/index.js",
25
- "./change": "./change/index.js",
26
25
  "./db": "./db/index.js",
27
26
  "./error": "./error/index.js",
28
27
  "./feedback": "./feedback/index.js",
@@ -31,7 +30,6 @@
31
30
  "./firestore/server": "./firestore/server/index.js",
32
31
  "./iterate": "./iterate/index.js",
33
32
  "./markup": "./markup/index.js",
34
- "./provider": "./provider/index.js",
35
33
  "./react": "./react/index.js",
36
34
  "./schema": "./schema/index.js",
37
35
  "./sequence": "./sequence/index.js",
package/util/array.d.ts CHANGED
@@ -13,11 +13,11 @@ export type ArrayItem<T extends ImmutableArray> = T[number];
13
13
  /** Things that can be converted to arrays. */
14
14
  export type PossibleArray<T> = ImmutableArray<T> | Iterable<T>;
15
15
  /** Is an unknown value an array? */
16
- export declare const isArray: (value: unknown) => value is ImmutableArray<unknown>;
16
+ export declare function isArray(value: unknown): value is ImmutableArray;
17
17
  /** Assert that an unknown value is an array. */
18
18
  export declare function assertArray<T>(arr: unknown): asserts arr is ImmutableArray<T>;
19
19
  /** Is an unknown value an item in a specified array? */
20
- export declare const isArrayItem: <T>(arr: ImmutableArray<T>, item: unknown) => item is T;
20
+ export declare function isArrayItem<T>(arr: ImmutableArray<T>, item: unknown): item is T;
21
21
  /** Assert that an unknown value is an item in a specified array. */
22
22
  export declare function assertArrayItem<T>(arr: ImmutableArray<T>, item: unknown): asserts item is T;
23
23
  /** Convert an iterable to an array (if its not already an array). */
@@ -28,8 +28,6 @@ export declare function withArrayItems<T>(arr: ImmutableArray<T>, ...items: T[])
28
28
  export declare function pickArrayItems<T>(input: ImmutableArray<T> | Iterable<T>, ...pick: T[]): ImmutableArray<T>;
29
29
  /** Remove multiple items from an array (immutably) and return a new array without those items (or the same array if no changes were made). */
30
30
  export declare function omitArrayItems<T>(input: ImmutableArray<T> | Iterable<T>, ...omit: T[]): ImmutableArray<T>;
31
- /** Clear an array (immutably) and return a new empty array (or the same array if no changes were made). */
32
- export declare const clearArray: <T>(input: ImmutableArray<T>) => ImmutableArray<T>;
33
31
  /** Toggle an item in and out of an array (immutably) and return a new array with or without the specified items (or the same array if no changes were made). */
34
32
  export declare function toggleArrayItems<T>(input: ImmutableArray<T>, ...items: T[]): ImmutableArray<T>;
35
33
  /** Get the first item from an array or iterable, or `undefined` if it didn't exist. */
package/util/array.js CHANGED
@@ -3,14 +3,18 @@ import { ValueError } from "../error/ValueError.js";
3
3
  import { omitItems, pickItems } from "./iterate.js";
4
4
  import { formatRange } from "./number.js";
5
5
  /** Is an unknown value an array? */
6
- export const isArray = (value) => Array.isArray(value);
6
+ export function isArray(value) {
7
+ return Array.isArray(value);
8
+ }
7
9
  /** Assert that an unknown value is an array. */
8
10
  export function assertArray(arr) {
9
11
  if (!isArray(arr))
10
12
  throw new ValueError(`Must be array`, arr);
11
13
  }
12
14
  /** Is an unknown value an item in a specified array? */
13
- export const isArrayItem = (arr, item) => arr.includes(item);
15
+ export function isArrayItem(arr, item) {
16
+ return arr.includes(item);
17
+ }
14
18
  /** Assert that an unknown value is an item in a specified array. */
15
19
  export function assertArrayItem(arr, item) {
16
20
  if (!isArrayItem(arr, item))
@@ -38,8 +42,6 @@ export function omitArrayItems(input, ...omit) {
38
42
  const output = Array.from(omitItems(input, ...omit));
39
43
  return isArray(input) && output.length === input.length ? input : output;
40
44
  }
41
- /** Clear an array (immutably) and return a new empty array (or the same array if no changes were made). */
42
- export const clearArray = (input) => (input.length ? [] : input);
43
45
  /** Toggle an item in and out of an array (immutably) and return a new array with or without the specified items (or the same array if no changes were made). */
44
46
  export function toggleArrayItems(input, ...items) {
45
47
  const extras = items.filter(_doesNotInclude, input);
package/util/async.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { ValueCallback } from "./callback.js";
2
2
  import type { Report } from "./error.js";
3
3
  /** Is a value an asynchronous value implementing a `then()` function. */
4
- export declare const isAsync: <T>(value: T | PromiseLike<T>) => value is PromiseLike<T>;
4
+ export declare function isAsync<T>(value: PromiseLike<T> | T): value is PromiseLike<T>;
5
5
  /** Is a value a synchronous value. */
6
- export declare const notAsync: <T>(value: T | PromiseLike<T>) => value is T;
6
+ export declare function notAsync<T>(value: PromiseLike<T> | T): value is T;
7
7
  /**
8
8
  * Throw the value if it's an async (promised) value.
9
9
  * @returns Synchronous (not promised) value.
package/util/async.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import { ValueError } from "../error/ValueError.js";
2
2
  /** Is a value an asynchronous value implementing a `then()` function. */
3
- export const isAsync = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
3
+ export function isAsync(value) {
4
+ return typeof value === "object" && value !== null && typeof value.then === "function";
5
+ }
4
6
  /** Is a value a synchronous value. */
5
- export const notAsync = (value) => !isAsync(value);
7
+ export function notAsync(value) {
8
+ return !isAsync(value);
9
+ }
6
10
  /**
7
11
  * Throw the value if it's an async (promised) value.
8
12
  * @returns Synchronous (not promised) value.
package/util/boolean.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  /** Is a value a boolean? */
2
- export declare const isBoolean: (value: unknown) => value is boolean;
2
+ export declare function isBoolean(value: unknown): value is boolean;
3
3
  /** Is a value true? */
4
- export declare const isTrue: (value: unknown) => value is true;
4
+ export declare function isTrue(value: unknown): value is true;
5
5
  /** Is a value false? */
6
- export declare const isFalse: (value: unknown) => value is false;
6
+ export declare function isFalse(value: unknown): value is false;
7
7
  /** Is a value truthy? */
8
- export declare const isTruthy: (value: unknown) => boolean;
8
+ export declare function isTruthy(value: unknown): boolean;
9
9
  /** Is a value falsey? */
10
- export declare const isFalsey: (value: unknown) => boolean;
10
+ export declare function isFalsey(value: unknown): boolean;
11
11
  /** Assert that a value is a boolean. */
12
12
  export declare function assertBoolean(value: unknown): asserts value is boolean;
13
13
  /** Assert that a value is true. */
package/util/boolean.js CHANGED
@@ -1,14 +1,24 @@
1
1
  import { ValueError } from "../error/ValueError.js";
2
2
  /** Is a value a boolean? */
3
- export const isBoolean = (value) => typeof value === "boolean";
3
+ export function isBoolean(value) {
4
+ return typeof value === "boolean";
5
+ }
4
6
  /** Is a value true? */
5
- export const isTrue = (value) => value === true;
7
+ export function isTrue(value) {
8
+ return value === true;
9
+ }
6
10
  /** Is a value false? */
7
- export const isFalse = (value) => value === false;
11
+ export function isFalse(value) {
12
+ return value === false;
13
+ }
8
14
  /** Is a value truthy? */
9
- export const isTruthy = (value) => !!value;
15
+ export function isTruthy(value) {
16
+ return !!value;
17
+ }
10
18
  /** Is a value falsey? */
11
- export const isFalsey = (value) => !value;
19
+ export function isFalsey(value) {
20
+ return !value;
21
+ }
12
22
  /** Assert that a value is a boolean. */
13
23
  export function assertBoolean(value) {
14
24
  if (typeof value !== "boolean")
package/util/class.d.ts CHANGED
@@ -6,8 +6,8 @@ export type AnyConstructor = new (...args: any) => any;
6
6
  /** Class prototype that can be used with `instanceof`. */
7
7
  export type Class<T> = new (...args: any) => T;
8
8
  /** Is a given value a class constructor? */
9
- export declare const isConstructor: (value: unknown) => value is AnyConstructor;
9
+ export declare function isConstructor(value: unknown): value is AnyConstructor;
10
10
  /** Is a value an instance of a class? */
11
- export declare const isInstance: <T>(value: unknown, type: Class<T>) => value is T;
11
+ export declare function isInstance<T>(value: unknown, type: Class<T>): value is T;
12
12
  /** Assert that a value is an instance of something. */
13
13
  export declare function assertInstance<T>(value: unknown, type: Class<T>): asserts value is T;
package/util/class.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { ValueError } from "../error/ValueError.js";
2
2
  import { debug } from "./debug.js";
3
3
  /** Is a given value a class constructor? */
4
- export const isConstructor = (value) => typeof value === "function" && value.toString().startsWith("class");
4
+ export function isConstructor(value) {
5
+ return typeof value === "function" && value.toString().startsWith("class");
6
+ }
5
7
  /** Is a value an instance of a class? */
6
- export const isInstance = (value, type) => value instanceof type;
8
+ export function isInstance(value, type) {
9
+ return value instanceof type;
10
+ }
7
11
  /** Assert that a value is an instance of something. */
8
12
  export function assertInstance(value, type) {
9
13
  if (!(value instanceof type))
package/util/color.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare class Color {
26
26
  toString(): string;
27
27
  }
28
28
  /** Is an unknown value a `Color` instance. */
29
- export declare const isColor: (value: unknown) => value is Color;
29
+ export declare function isColor(value: unknown): value is Color;
30
30
  /** Assert that an unknown value is a `Color` instance. */
31
31
  export declare function assertColor(value: unknown): asserts value is Color;
32
32
  /** Convert a possible color to a `Color` instance or `undefined` */
package/util/color.js CHANGED
@@ -58,10 +58,16 @@ export class Color {
58
58
  return this.rgba;
59
59
  }
60
60
  }
61
- const _parse = (hex) => parseInt(hex.padStart(2, "00"), 16);
62
- const _hex = (channel) => channel.toString(16).padStart(2, "00");
61
+ function _parse(hex) {
62
+ return parseInt(hex.padStart(2, "00"), 16);
63
+ }
64
+ function _hex(channel) {
65
+ return channel.toString(16).padStart(2, "00");
66
+ }
63
67
  /** Is an unknown value a `Color` instance. */
64
- export const isColor = (value) => value instanceof Color;
68
+ export function isColor(value) {
69
+ return value instanceof Color;
70
+ }
65
71
  /** Assert that an unknown value is a `Color` instance. */
66
72
  export function assertColor(value) {
67
73
  if (!isColor(value))
package/util/data.d.ts CHANGED
@@ -44,7 +44,7 @@ export type LeafProp<T extends Data> = {
44
44
  readonly [K in DataKey<T>]: (T[K] extends Data ? LeafProp<T[K]> : readonly [null, T[K]]) extends infer E ? E extends readonly [infer KK, infer VV] ? readonly [KK extends string ? `${K}.${KK}` : K, VV] : never : never;
45
45
  }[DataKey<T>];
46
46
  /** Is an unknown value a data object? */
47
- export declare const isData: (value: unknown) => value is Data;
47
+ export declare function isData(value: unknown): value is Data;
48
48
  /** Assert that an unknown value is a data object. */
49
49
  export declare function assertData(value: unknown): asserts value is Data;
50
50
  /** Is an unknown value the key for an own prop of a data object. */
package/util/data.js CHANGED
@@ -2,7 +2,9 @@ import { ValueError } from "../error/ValueError.js";
2
2
  import { isIterable } from "./iterate.js";
3
3
  import { isObject, isPlainObject } from "./object.js";
4
4
  /** Is an unknown value a data object? */
5
- export const isData = (value) => isPlainObject(value);
5
+ export function isData(value) {
6
+ return isPlainObject(value);
7
+ }
6
8
  /** Assert that an unknown value is a data object. */
7
9
  export function assertData(value) {
8
10
  if (!isPlainObject(value))
@@ -13,7 +13,7 @@ export type DictionaryValue<T extends ImmutableDictionary> = T[string];
13
13
  /** Something that can be converted to a dictionary object. */
14
14
  export type PossibleDictionary<T> = ImmutableDictionary<T> | Iterable<DictionaryItem<T>>;
15
15
  /** Is an unknown value a dictionary object? */
16
- export declare const isDictionary: (value: unknown) => value is ImmutableDictionary<unknown>;
16
+ export declare function isDictionary(value: unknown): value is ImmutableDictionary;
17
17
  /** Assert that an unknown value is a dictionary object */
18
18
  export declare function assertDictionary(value: unknown): asserts value is ImmutableDictionary;
19
19
  /** turn a possible dictionary into a dictionary. */
@@ -22,7 +22,7 @@ export declare function getDictionary<T>(obj: PossibleDictionary<T>): ImmutableD
22
22
  export declare function getDictionaryItems<T>(obj: ImmutableDictionary<T>): readonly DictionaryItem<T>[];
23
23
  export declare function getDictionaryItems<T>(obj: PossibleDictionary<T>): Iterable<DictionaryItem<T>>;
24
24
  /** Is an unknown value the key for an own prop of a dictionary. */
25
- export declare const isDictionaryItem: <T>(obj: ImmutableDictionary<T>, key: unknown) => key is string;
25
+ export declare function isDictionaryItem<T>(obj: ImmutableDictionary<T>, key: unknown): key is string;
26
26
  /** Assert that an unknown value is the key for an own prop of a dictionary. */
27
27
  export declare function assertDictionaryItem<T>(obj: ImmutableDictionary<T>, key: unknown): asserts key is string;
28
28
  /** Get an item in a map or throw an error if it doesn't exist. */
@@ -3,7 +3,9 @@ import { ValueError } from "../error/ValueError.js";
3
3
  import { isIterable } from "./iterate.js";
4
4
  import { deleteProps, isPlainObject, omitProps, pickProps, setProp, setProps, withProp, withProps } from "./object.js";
5
5
  /** Is an unknown value a dictionary object? */
6
- export const isDictionary = (value) => isPlainObject(value);
6
+ export function isDictionary(value) {
7
+ return isPlainObject(value);
8
+ }
7
9
  /** Assert that an unknown value is a dictionary object */
8
10
  export function assertDictionary(value) {
9
11
  if (!isDictionary(value))
@@ -17,7 +19,9 @@ export function getDictionaryItems(obj) {
17
19
  return isIterable(obj) ? obj : Object.entries(obj);
18
20
  }
19
21
  /** Is an unknown value the key for an own prop of a dictionary. */
20
- export const isDictionaryItem = (obj, key) => typeof key === "string" && Object.hasOwn(obj, key);
22
+ export function isDictionaryItem(obj, key) {
23
+ return typeof key === "string" && Object.hasOwn(obj, key);
24
+ }
21
25
  /** Assert that an unknown value is the key for an own prop of a dictionary. */
22
26
  export function assertDictionaryItem(obj, key) {
23
27
  if (!isDictionaryItem(obj, key))
package/util/dispose.d.ts CHANGED
@@ -18,7 +18,7 @@ export interface Disposable {
18
18
  /** Safely dispose a disposable. */
19
19
  export declare function dispose(value: Disposable): void;
20
20
  /** Is an unknown value a disposable object? */
21
- export declare const isDisposable: (v: unknown) => v is Disposable;
21
+ export declare function isDisposable(v: unknown): v is Disposable;
22
22
  /**
23
23
  * Version of `Map` that is disposable.
24
24
  * - If items are `Disposable` they are disposed when they're deleted from the map.
package/util/dispose.js CHANGED
@@ -15,7 +15,9 @@ export function dispose(value) {
15
15
  }
16
16
  }
17
17
  /** Is an unknown value a disposable object? */
18
- export const isDisposable = (v) => isObject(v) && typeof v[Symbol.dispose] === "function";
18
+ export function isDisposable(v) {
19
+ return isObject(v) && typeof v[Symbol.dispose] === "function";
20
+ }
19
21
  /**
20
22
  * Version of `Map` that is disposable.
21
23
  * - If items are `Disposable` they are disposed when they're deleted from the map.
package/util/entry.d.ts CHANGED
@@ -16,9 +16,9 @@ export type EntryObject<T extends Entry<PropertyKey, unknown>> = {
16
16
  readonly [E in T as E[0]]: E[1];
17
17
  };
18
18
  /** Extract the key from an object entry. */
19
- export declare const getEntryKey: <K, T>([k]: Entry<K, T>) => K;
19
+ export declare function getEntryKey<K, T>([k]: Entry<K, T>): K;
20
20
  /** Extract the value from an object entry. */
21
- export declare const getEntryValue: <K, T>([, v]: Entry<K, T>) => T;
21
+ export declare function getEntryValue<K, T>([, v]: Entry<K, T>): T;
22
22
  /** Yield the keys of an iterable set of entries. */
23
23
  export declare function getEntryKeys<K, T>(input: Iterable<Entry<K, T>>): Iterable<K>;
24
24
  /** Yield the values of an iterable set of entries. */
package/util/entry.js CHANGED
@@ -2,9 +2,13 @@ import { isArray } from "./array.js";
2
2
  import { isIterable } from "./iterate.js";
3
3
  import { isSet } from "./set.js";
4
4
  /** Extract the key from an object entry. */
5
- export const getEntryKey = ([k]) => k;
5
+ export function getEntryKey([k]) {
6
+ return k;
7
+ }
6
8
  /** Extract the value from an object entry. */
7
- export const getEntryValue = ([, v]) => v;
9
+ export function getEntryValue([, v]) {
10
+ return v;
11
+ }
8
12
  /** Yield the keys of an iterable set of entries. */
9
13
  export function* getEntryKeys(input) {
10
14
  for (const [k] of input)
package/util/equal.d.ts CHANGED
@@ -3,31 +3,31 @@ import type { ImmutableMap } from "./map.js";
3
3
  import type { Match } from "./match.js";
4
4
  import type { ImmutableObject } from "./object.js";
5
5
  /** Is unknown value `left` exactly equal to `right`? */
6
- export declare const isEqual: <T>(left: unknown, right: T) => left is T;
6
+ export declare function isEqual<T>(left: unknown, right: T): left is T;
7
7
  /** Is unknown value `left` not exactly equal to `right`? */
8
- export declare const notEqual: <T, N>(left: T | N, right: N) => left is T;
8
+ export declare function notEqual<T, N>(left: T | N, right: N): left is T;
9
9
  /** Is unknown value `left` less than `right`? */
10
- export declare const isLess: (left: unknown, right: unknown) => boolean;
10
+ export declare function isLess(left: unknown, right: unknown): boolean;
11
11
  /** Is unknown value `left` less than or equal to `right`? */
12
- export declare const isEqualLess: (left: unknown, right: unknown) => boolean;
12
+ export declare function isEqualLess(left: unknown, right: unknown): boolean;
13
13
  /** Is unknown value `left` greater than `right`? */
14
- export declare const isGreater: (left: unknown, right: unknown) => boolean;
14
+ export declare function isGreater(left: unknown, right: unknown): boolean;
15
15
  /** Is unknown value `left` greater than or equal to `right`? */
16
- export declare const isEqualGreater: (left: unknown, right: unknown) => boolean;
16
+ export declare function isEqualGreater(left: unknown, right: unknown): boolean;
17
17
  /**
18
18
  * Are two unknown values shallowly equal?
19
19
  * - If the values are both arrays/objects, see if the items/properties are **shallowly** equal with each other.
20
20
  */
21
- export declare const isShallowEqual: <T extends unknown>(left: unknown, right: T) => left is T;
21
+ export declare function isShallowEqual<T extends unknown>(left: unknown, right: T): left is T;
22
22
  /** Are two unknown values not shallowly equal? */
23
- export declare const notShallowEqual: <T extends unknown>(left: unknown, right: T) => left is T;
23
+ export declare function notShallowEqual<T extends unknown>(left: unknown, right: T): left is T;
24
24
  /**
25
25
  * Are two unknown values deeply equal?
26
26
  * - If the values are both arrays/objects, see if the items/properties are **deeply** equal with each other.
27
27
  */
28
- export declare const isDeepEqual: <T extends unknown>(left: unknown, right: T) => left is T;
28
+ export declare function isDeepEqual<T extends unknown>(left: unknown, right: T): left is T;
29
29
  /** Are two unknown values not deeply equal? */
30
- export declare const notDeepEqual: <T extends unknown>(left: unknown, right: T) => left is T;
30
+ export declare function notDeepEqual<T extends unknown>(left: unknown, right: T): left is T;
31
31
  /**
32
32
  * Are two maps equal (based on their items).
33
33
  */
@@ -41,13 +41,13 @@ export declare function isMapEqual<T extends ImmutableMap>(left: ImmutableMap, r
41
41
  */
42
42
  export declare function isArrayEqual<T extends ImmutableArray>(left: ImmutableArray, right: T, recursor?: Match): left is T;
43
43
  /** Is unknown value `left` in array `right`? */
44
- export declare const isInArray: <R>(left: unknown, right: ImmutableArray<R>) => left is R;
44
+ export declare function isInArray<R>(left: unknown, right: ImmutableArray<R>): left is R;
45
45
  /** Is unknown value `left` not in array `right`? */
46
- export declare const notInArray: (left: unknown, right: ImmutableArray) => boolean;
46
+ export declare function notInArray(left: unknown, right: ImmutableArray): boolean;
47
47
  /** Is unknown value `left` an array including `right`? */
48
- export declare const isArrayWith: <T>(left: unknown, right: T) => left is ImmutableArray<T>;
48
+ export declare function isArrayWith<T>(left: unknown, right: T): left is ImmutableArray<T>;
49
49
  /** Is unknown value `left` not an array or does not include `right`? */
50
- export declare const notArrayWith: (left: unknown, right: unknown) => boolean;
50
+ export declare function notArrayWith(left: unknown, right: unknown): boolean;
51
51
  /**
52
52
  * Are two objects equal based on their own props?
53
53
  * - `left` must have every property present in `right`
@@ -69,6 +69,6 @@ export declare function isObjectEqual<T extends ImmutableObject>(left: Immutable
69
69
  */
70
70
  export declare function isObjectMatch<L extends ImmutableObject, R extends ImmutableObject>(left: L | R, right: R, recursor?: Match): left is L & R;
71
71
  /** Is unknown value `left` an object with every prop from `right`? */
72
- export declare const isObjectWith: (left: unknown, right: ImmutableObject) => boolean;
72
+ export declare function isObjectWith(left: unknown, right: ImmutableObject): boolean;
73
73
  /** Is unknown value `left` not an object or missing one or more props from `right`? */
74
- export declare const notObjectWith: (left: unknown, right: ImmutableObject) => boolean;
74
+ export declare function notObjectWith(left: unknown, right: ImmutableObject): boolean;