shelving 1.109.2 → 1.109.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.
@@ -11,8 +11,6 @@ export interface Change {
11
11
  /** A change to a database collection. */
12
12
  export interface CollectionChange<T extends Database, K extends DataKey<T>> extends Change {
13
13
  readonly collection: K;
14
- readonly id?: string | never;
15
- readonly query?: ItemQuery<T[K]> | never;
16
14
  }
17
15
  /** Add an item to a database collection. */
18
16
  export interface ItemAddChange<T extends Database, K extends DataKey<T>> extends CollectionChange<T, K> {
package/db/ItemStore.js CHANGED
@@ -27,13 +27,14 @@ export class ItemStore extends Store {
27
27
  }
28
28
  constructor(provider, collection, id) {
29
29
  const memory = getOptionalSource(CacheProvider, provider)?.memory;
30
- const time = memory ? memory.getItemTime(collection, id) : undefined;
31
- super(memory && typeof time === "number" ? memory.getItem(collection, id) : NONE, time);
30
+ const time = memory?.getItemTime(collection, id);
31
+ const value = memory && typeof time === "number" ? memory.getItem(collection, id) : NONE; // Use the value in the memory provider if it's cached, or use mark this store as loading otherwise (which will trigger `refresh()` below.
32
+ super(value, time);
32
33
  this.provider = provider;
33
34
  this.collection = collection;
34
35
  this.id = id;
35
36
  // Queue a request to refresh the value if it doesn't exist.
36
- if (this.loading)
37
+ if (typeof time !== "number")
37
38
  this.refresh();
38
39
  }
39
40
  /** Refresh this store from the source provider. */
package/db/QueryStore.js CHANGED
@@ -45,13 +45,15 @@ export class QueryStore extends Store {
45
45
  }
46
46
  constructor(provider, collection, query) {
47
47
  const memory = getOptionalSource(CacheProvider, provider)?.memory;
48
- super(memory?.getQuery(collection, query) || NONE, memory?.getQueryTime(collection, query));
48
+ const time = memory?.getQueryTime(collection, query);
49
+ const value = memory?.getQuery(collection, query) || NONE; // Always use any matching items currently in the memory store (this might update when we call `refresh()` below).
50
+ super(value, time);
49
51
  this.provider = provider;
50
52
  this.collection = collection;
51
53
  this.query = query;
52
54
  this.limit = getLimit(query) ?? Infinity;
53
55
  // Queue a request to refresh the value if it doesn't exist.
54
- if (this.loading)
56
+ if (typeof time !== "number")
55
57
  this.refresh();
56
58
  }
57
59
  /** Refresh this store from the source provider. */
@@ -3,5 +3,5 @@
3
3
  * - Merges the message and stack of the previous message.
4
4
  */
5
5
  export declare class ThroughError extends Error {
6
- constructor(message: string, cause: Error | unknown);
6
+ constructor(message: string, cause: unknown);
7
7
  }
@@ -2,7 +2,7 @@
2
2
  export declare abstract class AbstractGenerator<T, R, N> implements Generator<T, R, N> {
3
3
  readonly [Symbol.toStringTag] = "Generator";
4
4
  abstract next(value: N): IteratorResult<T, R>;
5
- throw(thrown: Error | unknown): IteratorResult<T, R>;
5
+ throw(thrown: unknown): IteratorResult<T, R>;
6
6
  return(value: R): IteratorResult<T, R>;
7
7
  [Symbol.iterator](): Generator<T, R, N>;
8
8
  }
@@ -24,7 +24,7 @@ export declare class InspectGenerator<T, R, N> extends ThroughGenerator<T, R, N>
24
24
  get returned(): R;
25
25
  private _returned;
26
26
  next(value: N): IteratorResult<T, R>;
27
- throw(thrown: Error | unknown): IteratorResult<T, R>;
27
+ throw(thrown: unknown): IteratorResult<T, R>;
28
28
  return(value: R): IteratorResult<T, R>;
29
29
  /** Capture a result. */
30
30
  private _inspect;
@@ -4,6 +4,6 @@ export declare class ThroughGenerator<T, R, N> extends AbstractGenerator<T, R, N
4
4
  private readonly _source;
5
5
  constructor(iterator: Iterator<T, R, N>);
6
6
  next(value: N): IteratorResult<T, R>;
7
- throw(thrown: Error | unknown): IteratorResult<T, R>;
7
+ throw(thrown: unknown): IteratorResult<T, R>;
8
8
  return(value: R): IteratorResult<T, R>;
9
9
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.109.2",
14
+ "version": "1.109.4",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -66,19 +66,19 @@
66
66
  "@types/jest": "^29.4.0",
67
67
  "@types/react": "^18.0.27",
68
68
  "@types/react-dom": "^18.0.10",
69
- "@typescript-eslint/eslint-plugin": "^5.49.0",
70
- "@typescript-eslint/parser": "^5.49.0",
71
- "esbuild": "^0.17.12",
69
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
70
+ "@typescript-eslint/parser": "^6.7.0",
71
+ "esbuild": "^0.19.2",
72
72
  "esbuild-jest": "^0.5.0",
73
73
  "eslint": "^8.33.0",
74
- "eslint-config-prettier": "^8.6.0",
74
+ "eslint-config-prettier": "^9.0.0",
75
75
  "eslint-import-resolver-typescript": "^3.5.5",
76
76
  "eslint-plugin-import": "^2.27.5",
77
- "eslint-plugin-prettier": "^4.0.0",
78
- "firebase": "^9.16.0",
77
+ "eslint-plugin-prettier": "^5.0.0",
78
+ "firebase": "^10.3.1",
79
79
  "jest": "^29.4.1",
80
80
  "jest-ts-webcompat-resolver": "^1.0.0",
81
- "prettier": "^2.8.3",
81
+ "prettier": "^3.0.3",
82
82
  "react": "^18.1.0",
83
83
  "react-dom": "^18.1.0",
84
84
  "typescript": "^5.0.2"
@@ -3,6 +3,6 @@ export declare abstract class AbstractSequence<T, R, N> implements AsyncGenerato
3
3
  readonly [Symbol.toStringTag] = "Sequence";
4
4
  abstract next(value: N): Promise<IteratorResult<T, R>>;
5
5
  return(returnValue: R | PromiseLike<R>): Promise<IteratorResult<T, R>>;
6
- throw(reason: Error | unknown): Promise<IteratorResult<T, R>>;
6
+ throw(reason: unknown): Promise<IteratorResult<T, R>>;
7
7
  [Symbol.asyncIterator](): AsyncGenerator<T, R>;
8
8
  }
@@ -24,7 +24,7 @@ export declare class InspectSequence<T, R, N> extends ThroughSequence<T, R, N> {
24
24
  get returned(): R;
25
25
  private _returned;
26
26
  next(): Promise<IteratorResult<T, R>>;
27
- throw(thrown: Error | unknown): Promise<IteratorResult<T, R>>;
27
+ throw(thrown: unknown): Promise<IteratorResult<T, R>>;
28
28
  return(value: R): Promise<IteratorResult<T, R>>;
29
29
  /** Capture a result. */
30
30
  private _inspect;
@@ -4,6 +4,6 @@ export declare class ThroughSequence<T, R, N> extends AbstractSequence<T, R, N>
4
4
  private readonly _source;
5
5
  constructor(source: AsyncIterator<T, R, N>);
6
6
  next(next: N): Promise<IteratorResult<T, R>>;
7
- throw(thrown: Error | unknown): Promise<IteratorResult<T, R>>;
7
+ throw(thrown: unknown): Promise<IteratorResult<T, R>>;
8
8
  return(value: R | PromiseLike<R>): Promise<IteratorResult<T, R>>;
9
9
  }
package/store/Store.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare class Store<T> implements AsyncIterable<T> {
28
28
  get age(): number;
29
29
  /** Current error of this store (or `undefined` if there is no reason). */
30
30
  get reason(): unknown;
31
- set reason(reason: Error | unknown);
31
+ set reason(reason: unknown);
32
32
  private _reason;
33
33
  /** Store is initiated with an initial store. */
34
34
  constructor(value: T | typeof NONE, time?: number);
package/util/array.d.ts CHANGED
@@ -13,13 +13,13 @@ 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: <T extends ImmutableArray<unknown>>(value: unknown) => value is T;
16
+ export declare const isArray: (value: unknown) => value is ImmutableArray<unknown>;
17
17
  /** Assert that an unknown value is an array. */
18
- export declare function assertArray<T>(arr: ImmutableArray<T> | unknown): asserts arr is ImmutableArray<T>;
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
20
  export declare const 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
- export declare function assertArrayItem<T>(arr: ImmutableArray<T>, item: T | unknown): asserts item is T;
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). */
24
24
  export declare function getArray<T>(items: PossibleArray<T>): ImmutableArray<T>;
25
25
  /** Add multiple items to an array (immutably) and return a new array with those items (or the same array if no changes were made). */
@@ -77,25 +77,25 @@ export declare function isArrayLength<T>(arr: ImmutableArray<T>, min: 2, max?: n
77
77
  export declare function isArrayLength<T>(arr: ImmutableArray<T>, min: 3, max?: number): arr is readonly [T, T, T, ...T[]];
78
78
  export declare function isArrayLength<T>(arr: ImmutableArray<T>, min: 4, max?: number): arr is readonly [T, T, T, T, ...T[]];
79
79
  export declare function isArrayLength<T>(arr: ImmutableArray<T>, min?: number, max?: number): boolean;
80
- /** Assert that a value has a specific length (or length is in a specific range). */
80
+ /** Assert that an array has a specific length (or length is in a specific range). */
81
81
  export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 1, max: 1): asserts arr is [T];
82
82
  export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 2, max: 2): asserts arr is [T, T];
83
83
  export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 3, max: 3): asserts arr is [T, T, T];
84
84
  export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 4, max: 4): asserts arr is [T, T, T, T];
85
- export declare function assertArrayLength<T>(arr: MutableArray<T> | unknown, min?: 1, max?: number): asserts arr is [T, ...T[]];
86
- export declare function assertArrayLength<T>(arr: MutableArray<T> | unknown, min: 2, max?: number): asserts arr is [T, T, ...T[]];
87
- export declare function assertArrayLength<T>(arr: MutableArray<T> | unknown, min: 3, max?: number): asserts arr is [T, T, T, ...T[]];
88
- export declare function assertArrayLength<T>(arr: MutableArray<T> | unknown, min: 4, max?: number): asserts arr is [T, T, T, T, ...T[]];
89
- export declare function assertArrayLength<T>(arr: MutableArray<T> | unknown, min: number, max?: number): asserts arr is MutableArray<T>;
85
+ export declare function assertArrayLength<T>(arr: MutableArray<T>, min?: 1, max?: number): asserts arr is [T, ...T[]];
86
+ export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 2, max?: number): asserts arr is [T, T, ...T[]];
87
+ export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 3, max?: number): asserts arr is [T, T, T, ...T[]];
88
+ export declare function assertArrayLength<T>(arr: MutableArray<T>, min: 4, max?: number): asserts arr is [T, T, T, T, ...T[]];
89
+ export declare function assertArrayLength<T>(arr: MutableArray<T>, min: number, max?: number): asserts arr is MutableArray<T>;
90
90
  export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 1, max: 1): asserts arr is readonly [T];
91
91
  export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 2, max: 2): asserts arr is readonly [T, T];
92
92
  export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 3, max: 3): asserts arr is readonly [T, T, T];
93
93
  export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 4, max: 4): asserts arr is readonly [T, T, T, T];
94
- export declare function assertArrayLength<T>(arr: ImmutableArray<T> | unknown, min?: 1, max?: number): asserts arr is readonly [T, ...T[]];
95
- export declare function assertArrayLength<T>(arr: ImmutableArray<T> | unknown, min: 2, max?: number): asserts arr is readonly [T, T, ...T[]];
96
- export declare function assertArrayLength<T>(arr: ImmutableArray<T> | unknown, min: 3, max?: number): asserts arr is readonly [T, T, T, ...T[]];
97
- export declare function assertArrayLength<T>(arr: ImmutableArray<T> | unknown, min: 4, max?: number): asserts arr is readonly [T, T, T, T, ...T[]];
98
- export declare function assertArrayLength<T>(arr: ImmutableArray<T> | unknown, min: number, max?: number): asserts arr is ImmutableArray<T>;
94
+ export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min?: 1, max?: number): asserts arr is readonly [T, ...T[]];
95
+ export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 2, max?: number): asserts arr is readonly [T, T, ...T[]];
96
+ export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 3, max?: number): asserts arr is readonly [T, T, T, ...T[]];
97
+ export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: 4, max?: number): asserts arr is readonly [T, T, T, T, ...T[]];
98
+ export declare function assertArrayLength<T>(arr: ImmutableArray<T>, min: number, max?: number): asserts arr is ImmutableArray<T>;
99
99
  /** Get an array if it has the specified minimum length. */
100
100
  export declare function getArrayLength<T>(arr: MutableArray<T>, min: 1, max: 1): [T];
101
101
  export declare function getArrayLength<T>(arr: MutableArray<T>, min: 2, max: 2): [T, T];
package/util/assert.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Assert a boolean condition is true. */
2
2
  export declare function assert(condition: unknown, ...receivedExpected: [received?: unknown, expected?: unknown]): asserts condition;
3
3
  /** Assert two values are equal. */
4
- export declare function assertEqual<T>(left: T | unknown, right: T): asserts left is T;
4
+ export declare function assertEqual<T>(left: unknown, right: T): asserts left is T;
5
5
  /** Assert two values are equal. */
6
6
  export declare function assertNot<T, N>(left: T | N, right: N): asserts left is T;
@@ -12,7 +12,7 @@ export type ValuesCallback<T extends Arguments = []> = (...values: T) => void;
12
12
  /** Callback function that receives multiple values and possibly returns a promise that must be handled. */
13
13
  export type AsyncValuesCallback<T extends Arguments = []> = (...values: T) => void | PromiseLike<void>;
14
14
  /** Callback function that handles an error. */
15
- export type ErrorCallback = (reason: Error | unknown) => void;
15
+ export type ErrorCallback = (reason: unknown) => void;
16
16
  /** Callback function that starts something (and returns an optional stop callback). */
17
17
  export type StartCallback<T> = (value: T) => StopCallback;
18
18
  /** Callback function that stops something. */
package/util/class.d.ts CHANGED
@@ -3,11 +3,11 @@ import type { Arguments } from "./function.js";
3
3
  export type Constructor<T, A extends Arguments> = new (...args: A) => T;
4
4
  /** Any function arguments (designed for use with `extends Arguments` guards). */
5
5
  export type AnyConstructor = new (...args: any) => any;
6
- /** Class prototype that can be used with `instanceof` (string name, as per `Function`, and a prototype field matching the object). */
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: <T extends AnyConstructor>(value: unknown) => value is T;
9
+ export declare const isConstructor: (value: unknown) => value is AnyConstructor;
10
10
  /** Is a value an instance of a class? */
11
11
  export declare const isInstance: <T>(value: unknown, type: Class<T>) => value is T;
12
12
  /** Assert that a value is an instance of something. */
13
- export declare function assertInstance<T>(value: T | unknown, type: Class<T>): asserts value is T;
13
+ export declare function assertInstance<T>(value: unknown, type: Class<T>): asserts value is T;
package/util/color.d.ts CHANGED
@@ -27,9 +27,9 @@ export declare class Color {
27
27
  toString(): string;
28
28
  }
29
29
  /** Is an unknown value a `Color` instance. */
30
- export declare const isColor: (value: Color | unknown) => value is Color;
30
+ export declare const isColor: (value: unknown) => value is Color;
31
31
  /** Assert that an unknown value is a `Color` instance. */
32
- export declare function assertColor(value: Color | unknown): asserts value is Color;
32
+ export declare function assertColor(value: unknown): asserts value is Color;
33
33
  /** Convert a possible color to a `Color` instance or `null` */
34
34
  export declare function getOptionalColor(possible: unknown): Color | null;
35
35
  /** Convert a possible color to a `Color` instance */
package/util/data.d.ts CHANGED
@@ -44,9 +44,9 @@ 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: <T extends Data>(value: unknown) => value is T;
47
+ export declare const isData: (value: unknown) => value is Data;
48
48
  /** Assert that an unknown value is a data object. */
49
- export declare function assertData<T extends Data>(value: T | unknown): asserts value is T;
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. */
51
51
  export declare const isDataProp: <T extends Data>(data: T, key: unknown) => key is DataKey<T>;
52
52
  /** Assert that an unknown value is the key for an own prop of a data object. */
package/util/date.d.ts CHANGED
@@ -3,9 +3,9 @@ export type PossibleDate = Date | number | string;
3
3
  /** Things that converted to dates or `null` */
4
4
  export type PossibleOptionalDate = Date | number | string | null;
5
5
  /** Is a value a date? */
6
- export declare function isDate(value: Date | unknown): value is Date;
6
+ export declare function isDate(value: unknown): value is Date;
7
7
  /** Assert that a value is a `Date` instance. */
8
- export declare function assertDate(value: Date | unknown): asserts value is Date;
8
+ export declare function assertDate(value: unknown): asserts value is Date;
9
9
  /**
10
10
  * Convert an unknown value to a valid `Date` instance, or `null` if it couldn't be converted.
11
11
  * - Note: `Date` instances can be invalid (e.g. `new Date("blah blah").getTime()` returns `NaN`). These are detected and will always return `null`
@@ -13,9 +13,9 @@ 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: <T extends ImmutableDictionary<T>>(value: unknown) => value is T;
16
+ export declare const isDictionary: (value: unknown) => value is ImmutableDictionary<unknown>;
17
17
  /** Assert that an unknown value is a dictionary object */
18
- export declare function assertDictionary<T>(value: ImmutableDictionary<T> | unknown): asserts value is ImmutableDictionary<T>;
18
+ export declare function assertDictionary(value: unknown): asserts value is ImmutableDictionary;
19
19
  /** Is an unknown value the key for an own prop of a dictionary. */
20
20
  export declare const isDictionaryItem: <T>(obj: ImmutableDictionary<T>, key: unknown) => key is string;
21
21
  /** Assert that an unknown value is the key for an own prop of a dictionary. */
@@ -1,11 +1,11 @@
1
1
  /** Unknown function. */
2
2
  export type UnknownFunction = (...args: unknown[]) => unknown;
3
- /** Any function (designed for use with `extends AnyFunction` guards). */
3
+ /** Any function (purposefully as wide as possible for use with `extends X` or `is X` statements). */
4
4
  export type AnyFunction = (...args: any) => any;
5
5
  /** Is a value a function? */
6
- export declare const isFunction: <T extends AnyFunction>(value: unknown) => value is T;
6
+ export declare const isFunction: (value: unknown) => value is AnyFunction;
7
7
  /** Assert that a value is a function. */
8
- export declare function assertFunction<T extends AnyFunction>(value: T | unknown): asserts value is T;
8
+ export declare function assertFunction(value: unknown): asserts value is AnyFunction;
9
9
  /** Readonly unknown array that is being used as a set of arguments to a function. */
10
10
  export type Arguments = readonly unknown[];
11
11
  /** Function that just passes through the first argument. */
package/util/iterate.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- /**
2
- * Is a value an iterable object?
3
- * - Any object with a `Symbol.iterator` property is iterable.
4
- * - Note: Array and Map instances etc will return true because they implement `Symbol.iterator`
5
- */
6
1
  /** Is an unknown value an iterable? */
7
- export declare const isIterable: <T extends Iterable<unknown>>(value: unknown) => value is T;
2
+ export declare const isIterable: (value: unknown) => value is Iterable<unknown>;
8
3
  /** An iterable containing items or nested iterables of items. */
9
4
  export type DeepIterable<T> = T | Iterable<DeepIterable<T>>;
10
5
  /** Flatten one or more iterables. */
@@ -15,7 +10,7 @@ export declare function flattenItems<T>(items: DeepIterable<T>): Iterable<T>;
15
10
  */
16
11
  export declare function hasItems(items: Iterable<unknown>): boolean;
17
12
  /** Is an unknown value one of the values of an iterable? */
18
- export declare function isItem<T>(items: Iterable<T>, value: T | unknown): value is T;
13
+ export declare function isItem<T>(items: Iterable<T>, value: unknown): value is T;
19
14
  /** Count the number of items in an iterable. */
20
15
  export declare function countItems(items: Iterable<unknown>): number;
21
16
  /**
package/util/iterate.js CHANGED
@@ -1,8 +1,3 @@
1
- /**
2
- * Is a value an iterable object?
3
- * - Any object with a `Symbol.iterator` property is iterable.
4
- * - Note: Array and Map instances etc will return true because they implement `Symbol.iterator`
5
- */
6
1
  /** Is an unknown value an iterable? */
7
2
  export const isIterable = (value) => typeof value === "object" && !!value && Symbol.iterator in value;
8
3
  /** Flatten one or more iterables. */
package/util/jsx.d.ts CHANGED
@@ -14,9 +14,9 @@ export type JSXElement<P extends JSXProps = JSXProps> = {
14
14
  /** JSX node (similar to `React.ReactNode`) */
15
15
  export type JSXNode = undefined | null | string | JSXElement | JSXNode[];
16
16
  /** Is an unknown value a JSX element? */
17
- export declare const isJSXElement: <T extends JSXElement<JSXProps>>(value: unknown) => value is T;
17
+ export declare const isJSXElement: (value: unknown) => value is JSXElement<JSXProps>;
18
18
  /** Is an unknown value a JSX node? */
19
- export declare const isJSXNode: <T extends JSXNode>(value: unknown) => value is T;
19
+ export declare const isJSXNode: (value: unknown) => value is JSXNode;
20
20
  /**
21
21
  * Take a Markup JSX node and strip all tags from it to produce a plain text string.
22
22
  *
package/util/map.d.ts CHANGED
@@ -20,13 +20,13 @@ export type PossibleStringMap<K extends string, T> = PossibleMap<K, T> | {
20
20
  readonly [KK in K]: T;
21
21
  };
22
22
  /** Is an unknown value a map? */
23
- export declare const isMap: <T extends ImmutableMap<unknown, unknown>>(value: unknown) => value is T;
23
+ export declare const isMap: (value: unknown) => value is ImmutableMap<unknown, unknown>;
24
24
  /** Assert that a value is a `Map` instance. */
25
- export declare function assertMap<T extends ImmutableMap>(value: T | unknown): asserts value is T;
25
+ export declare function assertMap(value: unknown): asserts value is ImmutableMap;
26
26
  /** Is an unknown value a key for an item in a map? */
27
27
  export declare const isMapItem: <K, V>(map: ImmutableMap<K, V>, key: unknown) => key is K;
28
28
  /** Assert that an unknown value is a key for an item in a map. */
29
- export declare function assertMapItem<K, V>(map: ImmutableMap<K, V>, key: K | unknown): asserts key is K;
29
+ export declare function assertMapItem<K, V>(map: ImmutableMap<K, V>, key: unknown): asserts key is K;
30
30
  /** Convert an iterable to a `Map` (if it's already a `Map` it passes through unchanged). */
31
31
  export declare function getMap<K extends string, T>(input: PossibleStringMap<K, T>): ImmutableMap<K, T>;
32
32
  export declare function getMap<K, T>(input: PossibleMap<K, T>): ImmutableMap<K, T>;
package/util/number.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /** Is a value a number? */
2
2
  export declare const isNumber: (value: unknown) => value is number;
3
3
  /** Assert that a value is a number. */
4
- export declare function assertNumber(value: number | unknown): asserts value is number;
4
+ export declare function assertNumber(value: unknown): asserts value is number;
5
5
  /** Assert that a value is a number greater than. */
6
- export declare function assertFinite(value: number | unknown): asserts value is number;
6
+ export declare function assertFinite(value: unknown): asserts value is number;
7
7
  /**
8
8
  * Is a finite number within a specified range?
9
9
  *
@@ -13,11 +13,11 @@ export declare function assertFinite(value: number | unknown): asserts value is
13
13
  */
14
14
  export declare const isBetween: (num: number, min: number, max: number) => boolean;
15
15
  /** Assert that a value is a number greater than. */
16
- export declare function assertBetween(value: number | unknown, min: number, max: number): asserts value is number;
16
+ export declare function assertBetween(value: unknown, min: number, max: number): asserts value is number;
17
17
  /** Assert that a value is a number greater than. */
18
- export declare function assertMax(value: number | unknown, max: number): asserts value is number;
18
+ export declare function assertMax(value: unknown, max: number): asserts value is number;
19
19
  /** Assert that a value is a number less than. */
20
- export declare function assertMin(value: number | unknown, min: number): asserts value is number;
20
+ export declare function assertMin(value: unknown, min: number): asserts value is number;
21
21
  /**
22
22
  * Convert an unknown value to a finite number or `null`
23
23
  * - Note: numbers can be non-finite numbers like `NaN` or `Infinity`. These are detected and will always return `null`
package/util/object.d.ts CHANGED
@@ -16,13 +16,13 @@ export type Value<T> = T[keyof T];
16
16
  /** Something that can be converted to an object. */
17
17
  export type PossibleObject<T> = T | Iterable<Prop<T>>;
18
18
  /** Is an unknown value an unknown object? */
19
- export declare const isObject: <T extends ImmutableObject<PropertyKey, unknown>>(value: unknown) => value is T;
19
+ export declare const isObject: (value: unknown) => value is ImmutableObject<PropertyKey, unknown>;
20
20
  /** Assert that a value is an object */
21
- export declare function assertObject<T extends ImmutableObject>(value: T | unknown): asserts value is T;
21
+ export declare function assertObject(value: unknown): asserts value is ImmutableObject;
22
22
  /** Is an unknown value a plain object? */
23
- export declare function isPlainObject<T extends ImmutableObject>(value: T | unknown): value is T;
23
+ export declare function isPlainObject(value: unknown): value is ImmutableObject;
24
24
  /** Assert that an unknown value is a plain object */
25
- export declare function assertPlainObject<T extends ImmutableObject>(value: T | unknown): asserts value is T;
25
+ export declare function assertPlainObject(value: unknown): asserts value is ImmutableObject;
26
26
  /** Is an unknown value the key for an own prop of an object. */
27
27
  export declare const isProp: <T extends ImmutableObject<PropertyKey, unknown>>(obj: T, key: PropertyKey) => key is keyof T;
28
28
  /** Assert that an unknown value is the key for an own prop of an object. */
package/util/object.js CHANGED
@@ -93,7 +93,7 @@ export function deleteProps(obj, ...keys) {
93
93
  */
94
94
  export function formatObject(obj) {
95
95
  if (typeof obj.toString === "function" && obj.toString !== Object.prototype.toString)
96
- return obj.toString();
96
+ return obj.toString(); // eslint-disable-line @typescript-eslint/no-base-to-string
97
97
  const name = obj.name;
98
98
  if (typeof name === "string")
99
99
  return name;
package/util/regexp.d.ts CHANGED
@@ -19,9 +19,9 @@ export interface NamedRegExp<T extends NamedRegExpData = NamedRegExpData> extend
19
19
  exec(input: string): NamedRegExpArray<T> | null;
20
20
  }
21
21
  /** Is an unknown value a `RegExp` instance? */
22
- export declare const isRegExp: <T extends RegExp>(value: unknown) => value is T;
22
+ export declare const isRegExp: (value: unknown) => value is RegExp;
23
23
  /** Assert that an unknown value is a `RegExp` instance. */
24
- export declare function assertRegExp<T extends RegExp>(value: T | unknown): asserts value is T;
24
+ export declare function assertRegExp(value: unknown): asserts value is RegExp;
25
25
  /** Convert a string to a regular expression that matches that string. */
26
26
  export declare function getRegExp<T extends string>(pattern: `(?<${T}>${string})`, flags?: string): NamedRegExp<{
27
27
  [K in T]: string;
@@ -5,7 +5,7 @@ import { STOP } from "./constants.js";
5
5
  * - Any object with a `Symbol.iterator` property is iterable.
6
6
  * - Note: Array and Map instances etc will return true because they implement `Symbol.iterator`
7
7
  */
8
- export declare const isSequence: <T extends AsyncIterable<unknown>>(value: unknown) => value is T;
8
+ export declare const isSequence: (value: unknown) => value is AsyncIterable<unknown>;
9
9
  /** Infinite sequence that yields until a `SIGNAL` is received. */
10
10
  export declare function repeatUntil<T>(source: AsyncIterable<T>, ...signals: [Promise<typeof STOP>, ...Promise<typeof STOP>[]]): AsyncIterable<T>;
11
11
  /** Infinite sequence that yields every X milliseconds (yields a count of the number of iterations). */
package/util/serialise.js CHANGED
@@ -34,7 +34,7 @@ export function serialise(value) {
34
34
  const type = prototype !== Object.prototype && prototype !== null ? prototype?.constructor?.name : undefined;
35
35
  // Use custom `toString()` function if it's defined.
36
36
  if (type && value.toString !== Object.prototype.toString)
37
- return `{"$type":${escapeString(type)},"value":${escapeString(value.toString())}}`;
37
+ return `{"$type":${escapeString(type)},"value":${escapeString(value.toString())}}`; // eslint-disable-line @typescript-eslint/no-base-to-string
38
38
  // Otherwise crawl the object and sort the props ascendingly.
39
39
  const props = Object.entries(value).map(serialiseEntry).sort();
40
40
  return `{${type ? `"$type":${escapeString(type)}${props.length ? "," : ""}` : ""}${props.join(",")}}`;
package/util/set.d.ts CHANGED
@@ -7,13 +7,13 @@ export type PossibleSet<T> = ImmutableSet<T> | Iterable<T>;
7
7
  /** Get the type of the _items_ in a set. */
8
8
  export type SetItem<X> = X extends ReadonlySet<infer Y> ? Y : never;
9
9
  /** Is an unknown value a set? */
10
- export declare const isSet: <T extends ImmutableSet<unknown>>(value: unknown) => value is T;
10
+ export declare const isSet: (value: unknown) => value is ImmutableSet<unknown>;
11
11
  /** Assert that a value is a `Set` instance. */
12
- export declare function assertSet<T extends ImmutableSet>(value: T | unknown): asserts value is T;
12
+ export declare function assertSet(value: unknown): asserts value is ImmutableSet;
13
13
  /** Is an unknown value an item in a set? */
14
14
  export declare const isSetItem: <T>(set: ImmutableSet<T>, item: unknown) => item is T;
15
15
  /** Assert that an unknown value is an item in a set. */
16
- export declare function assertSetItem<T>(set: ImmutableSet<T>, item: T | unknown): asserts item is T;
16
+ export declare function assertSetItem<T>(set: ImmutableSet<T>, item: unknown): asserts item is T;
17
17
  /** Convert an iterable to a `Set` (if it's already a `Set` it passes through unchanged). */
18
18
  export declare function getSet<T>(iterable: PossibleSet<T>): ImmutableSet<T>;
19
19
  /** Add an item to a set (by reference) and return the set item. */
package/util/string.d.ts CHANGED
@@ -30,7 +30,7 @@ export declare function getString(value: unknown): string;
30
30
  /** Does a string have the specified minimum length. */
31
31
  export declare const isStringLength: (str: string, min?: number, max?: number) => boolean;
32
32
  /** Assert that a value has a specific length (or length is in a specific range). */
33
- export declare function assertStringLength(str: string | unknown, min?: number, max?: number): asserts str is string;
33
+ export declare function assertStringLength(str: unknown, min?: number, max?: number): asserts str is string;
34
34
  /** Get a string if it has the specified minimum length. */
35
35
  export declare function getStringLength(str: string, min?: number, max?: number): string;
36
36
  /** Concatenate an iterable set of strings together. */
package/util/time.d.ts CHANGED
@@ -37,7 +37,7 @@ export type PossibleTime = Time | Date | number | string;
37
37
  /** Things that converted to times or `null` */
38
38
  export type PossibleOptionalTime = Time | Date | number | string | null;
39
39
  /** Is an unknown value a `Time` instance. */
40
- export declare const isTime: (value: Time | unknown) => value is Time;
40
+ export declare const isTime: (value: unknown) => value is Time;
41
41
  /**
42
42
  * Convert a value to a `Time` instance or `null`
43
43
  * - Works with possible dates, e.g. `now` or `Date` or `2022-09-12 18:32` or `19827263567`
package/util/url.d.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  export type PossibleURL = string | URL;
3
3
  export type PossibleOptionalURL = PossibleURL | null;
4
4
  /** Is an unknown value a URL? */
5
- export declare const isURL: (value: URL | unknown) => value is URL;
5
+ export declare const isURL: (value: unknown) => value is URL;
6
6
  /** Assert that an unknown value is a URL. */
7
- export declare function assertURL(value: URL | unknown): asserts value is URL;
7
+ export declare function assertURL(value: unknown): asserts value is URL;
8
8
  /** Convert a possible URL to a URL or return `null` if conversion fails. */
9
9
  export declare function getOptionalURL(url: PossibleOptionalURL, base?: PossibleOptionalURL): URL | null;
10
10
  /** Convert a possible URL to a URL but throw `AssertionError` if conversion fails. */