shelving 1.86.7 → 1.87.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 (79) hide show
  1. package/constraint/FilterConstraint.d.ts +8 -7
  2. package/constraint/FilterConstraint.js +34 -27
  3. package/constraint/QueryConstraints.js +6 -6
  4. package/constraint/SortConstraint.d.ts +4 -3
  5. package/constraint/SortConstraint.js +8 -3
  6. package/db/Change.d.ts +1 -3
  7. package/db/Change.js +3 -6
  8. package/db/Item.d.ts +3 -0
  9. package/db/Item.js +8 -3
  10. package/feedback/Feedback.d.ts +1 -1
  11. package/feedback/Feedback.js +1 -1
  12. package/firestore/client/FirestoreClientProvider.d.ts +1 -1
  13. package/firestore/client/FirestoreClientProvider.js +2 -2
  14. package/firestore/lite/FirestoreLiteProvider.js +1 -3
  15. package/firestore/server/FirestoreServerProvider.js +1 -1
  16. package/package.json +3 -3
  17. package/schema/Schema.d.ts +1 -1
  18. package/schema/Schema.js +1 -1
  19. package/state/State.d.ts +1 -1
  20. package/state/State.js +3 -2
  21. package/test/basics.d.ts +9 -0
  22. package/test/basics.js +14 -9
  23. package/test/index.d.ts +8 -0
  24. package/util/array.d.ts +5 -6
  25. package/util/array.js +5 -6
  26. package/util/assert.d.ts +2 -2
  27. package/util/assert.js +6 -6
  28. package/util/async.d.ts +2 -2
  29. package/util/async.js +4 -3
  30. package/util/boolean.d.ts +10 -10
  31. package/util/boolean.js +20 -20
  32. package/util/class.d.ts +3 -3
  33. package/util/class.js +5 -5
  34. package/util/clone.d.ts +1 -1
  35. package/util/clone.js +1 -1
  36. package/util/color.d.ts +2 -2
  37. package/util/color.js +4 -4
  38. package/util/data.d.ts +16 -3
  39. package/util/data.js +1 -1
  40. package/util/date.d.ts +2 -2
  41. package/util/date.js +4 -4
  42. package/util/duration.d.ts +2 -2
  43. package/util/duration.js +16 -17
  44. package/util/entry.d.ts +4 -0
  45. package/util/equal.d.ts +53 -16
  46. package/util/equal.js +81 -44
  47. package/util/function.d.ts +2 -2
  48. package/util/function.js +4 -4
  49. package/util/hydrate.js +1 -1
  50. package/util/iterate.d.ts +10 -7
  51. package/util/iterate.js +12 -4
  52. package/util/jsx.d.ts +2 -2
  53. package/util/jsx.js +2 -2
  54. package/util/map.d.ts +2 -2
  55. package/util/map.js +4 -4
  56. package/util/match.d.ts +0 -9
  57. package/util/match.js +0 -12
  58. package/util/null.d.ts +8 -8
  59. package/util/null.js +16 -16
  60. package/util/number.d.ts +6 -6
  61. package/util/number.js +16 -16
  62. package/util/object.d.ts +2 -1
  63. package/util/object.js +4 -2
  64. package/util/regexp.d.ts +2 -2
  65. package/util/regexp.js +4 -4
  66. package/util/set.d.ts +2 -2
  67. package/util/set.js +4 -4
  68. package/util/string.d.ts +2 -2
  69. package/util/string.js +1 -1
  70. package/util/time.d.ts +1 -1
  71. package/util/time.js +1 -1
  72. package/util/transform.d.ts +1 -1
  73. package/util/transform.js +1 -1
  74. package/util/undefined.d.ts +3 -3
  75. package/util/undefined.js +5 -5
  76. package/util/units.d.ts +7 -0
  77. package/util/units.js +17 -6
  78. package/util/url.d.ts +2 -2
  79. package/util/url.js +4 -4
package/util/assert.js CHANGED
@@ -5,12 +5,12 @@ export function assert(condition, ...received) {
5
5
  throw new AssertionError(`Must assert`, ...received);
6
6
  }
7
7
  /** Assert two values are equal. */
8
- export function assertEqual(v, target) {
9
- if (v !== target)
10
- throw new AssertionError(`Must be equal`, v, target);
8
+ export function assertEqual(left, right) {
9
+ if (left !== right)
10
+ throw new AssertionError(`Must be equal`, left, right);
11
11
  }
12
12
  /** Assert two values are equal. */
13
- export function assertNot(v, target) {
14
- if (v === target)
15
- throw new AssertionError(`Must not be equal`, v, target);
13
+ export function assertNot(left, right) {
14
+ if (left === right)
15
+ throw new AssertionError(`Must not be equal`, left, right);
16
16
  }
package/util/async.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { SIGNAL } from "./constants.js";
2
2
  import type { Handler, Dispatch } from "./function.js";
3
3
  /** Is a value an asynchronous value implementing a `then()` function. */
4
- export declare const isAsync: <T>(v: T | PromiseLike<T>) => v is PromiseLike<T>;
4
+ export declare const isAsync: <T>(value: T | PromiseLike<T>) => value is PromiseLike<T>;
5
5
  /** Is a value a synchronous value. */
6
- export declare const notAsync: <T>(v: T | PromiseLike<T>) => v is T;
6
+ export declare const notAsync: <T>(value: T | PromiseLike<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,9 +1,9 @@
1
1
  import { AssertionError } from "../error/AssertionError.js";
2
2
  import { SIGNAL } from "./constants.js";
3
3
  /** Is a value an asynchronous value implementing a `then()` function. */
4
- export const isAsync = (v) => typeof v === "object" && v !== null && typeof v.then === "function";
4
+ export const isAsync = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
5
5
  /** Is a value a synchronous value. */
6
- export const notAsync = (v) => !isAsync(v);
6
+ export const notAsync = (value) => !isAsync(value);
7
7
  /**
8
8
  * Throw the value if it's an async (promised) value.
9
9
  * @returns Synchronous (not promised) value.
@@ -78,7 +78,7 @@ export class Delay extends AbstractPromise {
78
78
  }
79
79
  }
80
80
  /** Resolve to `SIGNAL` on a specific signal. */
81
- export class Signal extends AbstractPromise {
81
+ class Signal extends AbstractPromise {
82
82
  constructor() {
83
83
  super(...arguments);
84
84
  /** Send this signal now. */
@@ -87,3 +87,4 @@ export class Signal extends AbstractPromise {
87
87
  }
88
88
  /** The `SIGNAL` symbol indicates a signal. */
89
89
  Signal.SIGNAL = SIGNAL;
90
+ export { Signal };
package/util/boolean.d.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  /** Is a value a boolean? */
2
- export declare const isBoolean: (v: unknown) => v is boolean;
2
+ export declare const isBoolean: (value: unknown) => value is boolean;
3
3
  /** Is a value true? */
4
- export declare const isTrue: (v: unknown) => v is true;
4
+ export declare const isTrue: (value: unknown) => value is true;
5
5
  /** Is a value false? */
6
- export declare const isFalse: (v: unknown) => v is false;
6
+ export declare const isFalse: (value: unknown) => value is false;
7
7
  /** Is a value truthy? */
8
- export declare const isTruthy: (v: unknown) => boolean;
8
+ export declare const isTruthy: (value: unknown) => boolean;
9
9
  /** Is a value falsey? */
10
- export declare const isFalsey: (v: unknown) => boolean;
10
+ export declare const isFalsey: (value: unknown) => boolean;
11
11
  /** Assert that a value is a boolean. */
12
- export declare function assertBoolean(v: unknown): asserts v is boolean;
12
+ export declare function assertBoolean(value: unknown): asserts value is boolean;
13
13
  /** Assert that a value is true. */
14
- export declare function assertTrue(v: unknown): asserts v is true;
14
+ export declare function assertTrue(value: unknown): asserts value is true;
15
15
  /** Assert that a value is false. */
16
- export declare function assertFalse(v: unknown): asserts v is false;
16
+ export declare function assertFalse(value: unknown): asserts value is false;
17
17
  /** Assert that a value is truthy. */
18
- export declare function assertTruthy(v: unknown): asserts v is true;
18
+ export declare function assertTruthy(value: unknown): asserts value is true;
19
19
  /** Assert that a value is falsy. */
20
- export declare function assertFalsy(v: unknown): asserts v is false;
20
+ export declare function assertFalsy(value: unknown): asserts value is false;
package/util/boolean.js CHANGED
@@ -1,36 +1,36 @@
1
1
  import { AssertionError } from "../error/AssertionError.js";
2
2
  /** Is a value a boolean? */
3
- export const isBoolean = (v) => typeof v === "boolean";
3
+ export const isBoolean = (value) => typeof value === "boolean";
4
4
  /** Is a value true? */
5
- export const isTrue = (v) => v === true;
5
+ export const isTrue = (value) => value === true;
6
6
  /** Is a value false? */
7
- export const isFalse = (v) => v === false;
7
+ export const isFalse = (value) => value === false;
8
8
  /** Is a value truthy? */
9
- export const isTruthy = (v) => !!v;
9
+ export const isTruthy = (value) => !!value;
10
10
  /** Is a value falsey? */
11
- export const isFalsey = (v) => !v;
11
+ export const isFalsey = (value) => !value;
12
12
  /** Assert that a value is a boolean. */
13
- export function assertBoolean(v) {
14
- if (typeof v !== "boolean")
15
- throw new AssertionError(`Must be boolean`, v);
13
+ export function assertBoolean(value) {
14
+ if (typeof value !== "boolean")
15
+ throw new AssertionError(`Must be boolean`, value);
16
16
  }
17
17
  /** Assert that a value is true. */
18
- export function assertTrue(v) {
19
- if (v !== true)
20
- throw new AssertionError(`Must be true`, v);
18
+ export function assertTrue(value) {
19
+ if (value !== true)
20
+ throw new AssertionError(`Must be true`, value);
21
21
  }
22
22
  /** Assert that a value is false. */
23
- export function assertFalse(v) {
24
- if (v !== false)
25
- throw new AssertionError(`Must be false`, v);
23
+ export function assertFalse(value) {
24
+ if (value !== false)
25
+ throw new AssertionError(`Must be false`, value);
26
26
  }
27
27
  /** Assert that a value is truthy. */
28
- export function assertTruthy(v) {
29
- if (!v)
30
- throw new AssertionError(`Must be truthy`, v);
28
+ export function assertTruthy(value) {
29
+ if (!value)
30
+ throw new AssertionError(`Must be truthy`, value);
31
31
  }
32
32
  /** Assert that a value is falsy. */
33
- export function assertFalsy(v) {
34
- if (v)
35
- throw new AssertionError(`Must be falsy`, v);
33
+ export function assertFalsy(value) {
34
+ if (value)
35
+ throw new AssertionError(`Must be falsy`, value);
36
36
  }
package/util/class.d.ts CHANGED
@@ -7,11 +7,11 @@ export type AnyConstructor = new (...args: any) => any;
7
7
  export type Class<T> = new (...args: any) => T;
8
8
  export declare const abc: Class<String>;
9
9
  /** Is a given value a class constructor? */
10
- export declare const isConstructor: <T extends AnyConstructor>(v: unknown) => v is T;
10
+ export declare const isConstructor: <T extends AnyConstructor>(value: unknown) => value is T;
11
11
  /** Is a value an instance of a class? */
12
- export declare const isInstance: <T>(v: unknown, type: Class<T>) => v is T;
12
+ export declare const isInstance: <T>(value: unknown, type: Class<T>) => value is T;
13
13
  /** Assert that a value is an instance of something. */
14
- export declare function assertInstance<T>(v: T | unknown, type: Class<T>): asserts v is T;
14
+ export declare function assertInstance<T>(value: T | unknown, type: Class<T>): asserts value is T;
15
15
  /** Decorator to bind a class method lazily on first access. */
16
16
  export declare function bindMethod<O, T, A>(target: O, key: string, { value: method }: TypedPropertyDescriptor<(...args: A[]) => T>): TypedPropertyDescriptor<(...args: A[]) => T>;
17
17
  /**
package/util/class.js CHANGED
@@ -4,13 +4,13 @@ import { assertFunction } from "./function.js";
4
4
  import { debug } from "./debug.js";
5
5
  export const abc = String;
6
6
  /** Is a given value a class constructor? */
7
- export const isConstructor = (v) => typeof v === "function" && v.toString().startsWith("class");
7
+ export const isConstructor = (value) => typeof value === "function" && value.toString().startsWith("class");
8
8
  /** Is a value an instance of a class? */
9
- export const isInstance = (v, type) => v instanceof type;
9
+ export const isInstance = (value, type) => value instanceof type;
10
10
  /** Assert that a value is an instance of something. */
11
- export function assertInstance(v, type) {
12
- if (!(v instanceof type))
13
- throw new AssertionError(`Must be instance of ${debug(type)}`, v);
11
+ export function assertInstance(value, type) {
12
+ if (!(value instanceof type))
13
+ throw new AssertionError(`Must be instance of ${debug(type)}`, value);
14
14
  }
15
15
  /** Decorator to bind a class method lazily on first access. */
16
16
  export function bindMethod(target, key, { value: method }) {
package/util/clone.d.ts CHANGED
@@ -5,7 +5,7 @@ export interface Cloneable {
5
5
  clone(): this;
6
6
  }
7
7
  /** Does an object implement `Cloneable` */
8
- export declare const isCloneable: <T extends Cloneable>(v: unknown) => v is T;
8
+ export declare const isCloneable: <T extends Cloneable>(value: unknown) => value is T;
9
9
  /** Shallow clone a value. */
10
10
  export declare const shallowClone: <T>(value: T) => T;
11
11
  /** Deep clone a value. */
package/util/clone.js CHANGED
@@ -3,7 +3,7 @@ import { isData } from "./data.js";
3
3
  import { mapArray, mapObject } from "./transform.js";
4
4
  import { getPrototype } from "./object.js";
5
5
  /** Does an object implement `Cloneable` */
6
- export const isCloneable = (v) => isData(v) && typeof v.clone === "function";
6
+ export const isCloneable = (value) => isData(value) && typeof value.clone === "function";
7
7
  /** Shallow clone a value. */
8
8
  export const shallowClone = (value) => value;
9
9
  /** Deep clone a value. */
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: (v: Color | unknown) => v is Color;
30
+ export declare const isColor: (value: Color | unknown) => value is Color;
31
31
  /** Assert that an unknown value is a `Color` instance. */
32
- export declare function assertColor(v: Color | unknown): asserts v is Color;
32
+ export declare function assertColor(value: Color | 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/color.js CHANGED
@@ -53,11 +53,11 @@ export class Color {
53
53
  const _parse = (hex) => parseInt(hex.padStart(2, "00"), 16);
54
54
  const _hex = (channel) => channel.toString(16).padStart(2, "00");
55
55
  /** Is an unknown value a `Color` instance. */
56
- export const isColor = (v) => v instanceof Color;
56
+ export const isColor = (value) => value instanceof Color;
57
57
  /** Assert that an unknown value is a `Color` instance. */
58
- export function assertColor(v) {
59
- if (!isColor(v))
60
- throw new AssertionError("Invalid color", v);
58
+ export function assertColor(value) {
59
+ if (!isColor(value))
60
+ throw new AssertionError("Invalid color", value);
61
61
  }
62
62
  /** Convert a possible color to a `Color` instance or `null` */
63
63
  export function getOptionalColor(possible) {
package/util/data.d.ts CHANGED
@@ -1,26 +1,39 @@
1
1
  import type { ImmutableArray } from "./array.js";
2
+ import type { EntryObject } from "./entry.js";
2
3
  /** Data object. */
3
4
  export type Data = {
4
5
  readonly [K in string]: unknown;
5
6
  };
6
- /** Prop for a data object. */
7
- export type DataProp<T extends Data> = readonly [keyof T & string, T[keyof T & string]];
8
7
  /** Key for a data object prop. */
9
8
  export type DataKey<T extends Data> = keyof T & string;
10
9
  /** Value for a data object prop. */
11
10
  export type DataValue<T extends Data> = T[keyof T & string];
11
+ /** Prop for a data object. */
12
+ export type DataProp<T extends Data> = {
13
+ readonly [K in DataKey<T>]: [K, T[K]];
14
+ }[DataKey<T>];
12
15
  /** Data or `null` to indicate the data doesn't exist. */
13
16
  export type OptionalData<T extends Data> = T | null;
14
17
  /** Set of named data objects. */
15
18
  export type Datas = {
16
19
  readonly [K in string]: Data;
17
20
  };
21
+ /** Flattened data object with deep keys flattened into `a.c.b` format. */
22
+ export type FlatData<T extends Data> = EntryObject<FlatDataProp<T>>;
23
+ /** Key for a flattened data object with deep keys flattened into `a.c.b` format. */
24
+ export type FlatDataKey<T extends Data> = FlatDataProp<T>[0];
25
+ /** Value for a flattened data object with deep keys flattened into `a.c.b` format. */
26
+ export type FlatDataValue<T extends Data> = FlatDataProp<T>[1];
27
+ /** Prop for a flattened data object with deep keys flattened into `a.c.b` format. */
28
+ export type FlatDataProp<T extends Data> = {
29
+ readonly [K in DataKey<T>]: (T[K] extends Data ? FlatDataProp<T[K]> : [null, T[K]]) extends infer E ? E extends [infer KK, infer VV] ? [KK extends string ? `${K}.${KK}` : K, VV] : never : never;
30
+ }[DataKey<T>];
18
31
  /** Is an unknown value a data object? */
19
32
  export declare const isData: <T extends Data>(value: unknown) => value is T;
20
33
  /** Assert that an unknown value is a data object. */
21
34
  export declare function assertData<T extends Data>(value: T | unknown): asserts value is T;
22
35
  /** Is an unknown value the key for an own prop of a data object. */
23
- export declare const isDataKey: <T extends Data>(obj: T, key: unknown) => key is DataKey<T>;
36
+ export declare const isDataProp: <T extends Data>(obj: T, key: unknown) => key is DataKey<T>;
24
37
  /** Get the data of a result (returns data or throws `RequiredError` if value is `null` or `undefined`). */
25
38
  export declare function getData<T extends Data>(result: OptionalData<T>): T;
26
39
  /** Get the props of a data object. */
package/util/data.js CHANGED
@@ -9,7 +9,7 @@ export function assertData(value) {
9
9
  throw new AssertionError("Must be data", value);
10
10
  }
11
11
  /** Is an unknown value the key for an own prop of a data object. */
12
- export const isDataKey = (obj, key) => typeof key === "string" && Object.prototype.hasOwnProperty.call(obj, key);
12
+ export const isDataProp = (obj, key) => typeof key === "string" && Object.prototype.hasOwnProperty.call(obj, key);
13
13
  /** Get the data of a result (returns data or throws `RequiredError` if value is `null` or `undefined`). */
14
14
  export function getData(result) {
15
15
  if (!result)
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 const isDate: (v: Date | unknown) => v is Date;
6
+ export declare const isDate: (value: Date | unknown) => value is Date;
7
7
  /** Assert that a value is a `Date` instance. */
8
- export declare function assertDate(v: Date | unknown): asserts v is Date;
8
+ export declare function assertDate(value: Date | 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`
package/util/date.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { AssertionError } from "../error/AssertionError.js";
2
2
  /** Is a value a date? */
3
- export const isDate = (v) => v instanceof Date;
3
+ export const isDate = (value) => value instanceof Date;
4
4
  /** Assert that a value is a `Date` instance. */
5
- export function assertDate(v) {
6
- if (!isDate(v))
7
- throw new AssertionError(`Must be date`, v);
5
+ export function assertDate(value) {
6
+ if (!isDate(value))
7
+ throw new AssertionError(`Must be date`, value);
8
8
  }
9
9
  /**
10
10
  * Convert an unknown value to a valid `Date` instance, or `null` if it couldn't be converted.
@@ -1,8 +1,8 @@
1
1
  import { PossibleDate } from "./date.js";
2
2
  /** Format a full format of a duration of time using the most reasonable units e.g. `5 years` or `1 week` or `4 minutes` or `12 milliseconds`. */
3
- export declare function formatFullDuration(ms: number, precision?: number): string;
3
+ export declare function formatFullDuration(ms: number): string;
4
4
  /** Format a description of a duration of time using the most reasonable units e.g. `5y` or `4m` or `12ms`. */
5
- export declare function formatDuration(ms: number, precision?: number): string;
5
+ export declare function formatDuration(ms: number): string;
6
6
  /** Full when a date happens/happened, e.g. `in 10 days` or `2 hours ago` */
7
7
  export declare const formatFullWhen: (target: PossibleDate, current?: PossibleDate) => string;
8
8
  /** Compact when a date happens/happened, e.g. `in 10d` or `2h ago` or `in 1w` */
package/util/duration.js CHANGED
@@ -1,35 +1,34 @@
1
1
  import { MONTH, WEEK, DAY, HOUR, SECOND } from "./constants.js";
2
2
  import { getDuration } from "./date.js";
3
- import { getMapItem } from "./map.js";
4
3
  import { TIME_UNITS } from "./units.js";
5
- /** Get the ID for a time unit based on the amount in milliseconds. */
6
- function _getTimeUnitKey(ms) {
4
+ /** Get an appropriate time unit based on an amount in milliseconds. */
5
+ function _getTimeUnit(ms) {
7
6
  const abs = Math.abs(ms);
8
7
  if (abs > 18 * MONTH)
9
- return "year";
8
+ return TIME_UNITS.unit("year");
10
9
  if (abs > 10 * WEEK)
11
- return "month";
10
+ return TIME_UNITS.unit("month");
12
11
  if (abs > 2 * WEEK)
13
- return "week";
12
+ return TIME_UNITS.unit("week");
14
13
  if (abs > DAY)
15
- return "day";
14
+ return TIME_UNITS.unit("day");
16
15
  if (abs > HOUR)
17
- return "hour";
16
+ return TIME_UNITS.unit("hour");
18
17
  if (abs > 9949)
19
- return "minute";
18
+ return TIME_UNITS.unit("minute");
20
19
  if (abs > SECOND)
21
- return "second";
22
- return "millisecond";
20
+ return TIME_UNITS.unit("second");
21
+ return TIME_UNITS.unit("millisecond");
23
22
  }
24
23
  /** Format a full format of a duration of time using the most reasonable units e.g. `5 years` or `1 week` or `4 minutes` or `12 milliseconds`. */
25
- export function formatFullDuration(ms, precision) {
26
- const unit = getMapItem(TIME_UNITS, _getTimeUnitKey(ms));
27
- return unit.formatFull(unit.from(ms), precision);
24
+ export function formatFullDuration(ms) {
25
+ const unit = _getTimeUnit(ms);
26
+ return unit.formatFull(unit.from(ms), 0);
28
27
  }
29
28
  /** Format a description of a duration of time using the most reasonable units e.g. `5y` or `4m` or `12ms`. */
30
- export function formatDuration(ms, precision) {
31
- const unit = getMapItem(TIME_UNITS, _getTimeUnitKey(ms));
32
- return unit.format(unit.from(ms), precision);
29
+ export function formatDuration(ms) {
30
+ const unit = _getTimeUnit(ms);
31
+ return unit.format(unit.from(ms), 0);
33
32
  }
34
33
  /** format when a data happens/happened. */
35
34
  function _formatWhen(formatter, target, current) {
package/util/entry.d.ts CHANGED
@@ -11,6 +11,10 @@ export type Entry<K = unknown, T = unknown> = readonly [K, T];
11
11
  export type EntryKey<X> = X extends Entry<infer Y, unknown> ? Y : never;
12
12
  /** Extract the type for the value of an entry. */
13
13
  export type EntryValue<X> = X extends Entry<unknown, infer Y> ? Y : never;
14
+ /** Convert an entry back into an object. */
15
+ export type EntryObject<T extends Entry<PropertyKey, unknown>> = {
16
+ readonly [E in T as E[0]]: E[1];
17
+ };
14
18
  /** Extract the key from an object entry. */
15
19
  export declare const getEntryKey: <K, T>([k]: Entry<K, T>) => K;
16
20
  /** Extract the value from an object entry. */
package/util/equal.d.ts CHANGED
@@ -2,36 +2,73 @@ import type { Match } from "./match.js";
2
2
  import { ImmutableArray } from "./array.js";
3
3
  import { ImmutableObject } from "./object.js";
4
4
  import { ImmutableMap } from "./map.js";
5
- /** Are two unknown values exactly equal? */
6
- export declare const isExactlyEqual: <L extends unknown>(left: L, right: unknown) => right is L;
5
+ /** Is unknown value `left` exactly equal to `right`? */
6
+ export declare const isEqual: <T>(left: unknown, right: T) => left is T;
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;
9
+ /** Is unknown value `left` less than `right`? */
10
+ export declare const isLess: (left: unknown, right: unknown) => boolean;
11
+ /** Is unknown value `left` less than or equal to `right`? */
12
+ export declare const isEqualLess: (left: unknown, right: unknown) => boolean;
13
+ /** Is unknown value `left` greater than `right`? */
14
+ export declare const isGreater: (left: unknown, right: unknown) => boolean;
15
+ /** Is unknown value `left` greater than or equal to `right`? */
16
+ export declare const isEqualGreater: (left: unknown, right: unknown) => boolean;
7
17
  /**
8
- * Are two unknown values shallow equal?
9
- * - If the values are both arrays/objects, see if the items/properties are **exactly** equal with each other.
18
+ * Are two unknown values shallowly equal?
19
+ * - If the values are both arrays/objects, see if the items/properties are **shallowly** equal with each other.
10
20
  */
11
- export declare const isShallowEqual: <L extends unknown>(left: L, right: unknown) => right is L;
21
+ export declare const isShallowEqual: <T extends unknown>(left: unknown, right: T) => left is T;
22
+ /** Are two unknown values not shallowly equal? */
23
+ export declare const notShallowEqual: <T extends unknown>(left: unknown, right: T) => left is T;
12
24
  /**
13
25
  * Are two unknown values deeply equal?
14
26
  * - If the values are both arrays/objects, see if the items/properties are **deeply** equal with each other.
15
27
  */
16
- export declare const isDeepEqual: <L extends unknown>(left: L, right: unknown) => right is L;
28
+ export declare const isDeepEqual: <T extends unknown>(left: unknown, right: T) => left is T;
29
+ /** Are two unknown values not deeply equal? */
30
+ export declare const notDeepEqual: <T extends unknown>(left: unknown, right: T) => left is T;
17
31
  /**
18
32
  * Are two maps equal (based on their items).
19
33
  */
20
- export declare function isMapEqual<L extends ImmutableMap>(left: L, right: ImmutableMap, recursor?: Match): right is L;
34
+ export declare function isMapEqual<T extends ImmutableMap>(left: ImmutableMap, right: T, recursor?: Match): left is T;
21
35
  /**
22
- * Are two arrays equal (based on their items)?
36
+ * Are two arrays equal based on their items?
23
37
  *
24
- * @param recursor Function that checks each property of the object.
25
- * - Defaults to `isExactlyEqual()` to check strict equality of the items.
38
+ * @param recursor Function that checks each item of the array.
39
+ * - Defaults to `isEqual()` to check strict equality of the items.
26
40
  * - Use `isDeepEqual()` as the recursor to check to check deep equality of the items.
27
41
  */
28
- export declare function isArrayEqual<L extends ImmutableArray>(left: L, right: ImmutableArray, recursor?: Match): right is L;
42
+ export declare function isArrayEqual<T extends ImmutableArray>(left: ImmutableArray, right: T, recursor?: Match): left is T;
43
+ /** Is unknown value `left` in array `right`? */
44
+ export declare const isInArray: <R>(left: unknown, right: ImmutableArray<R>) => left is R;
45
+ /** Is unknown value `left` not in array `right`? */
46
+ export declare const notInArray: (left: unknown, right: ImmutableArray) => boolean;
47
+ /** Is unknown value `left` an array including `right`? */
48
+ export declare const isArrayWith: <T>(left: unknown, right: T) => left is ImmutableArray<T>;
49
+ /** Is unknown value `left` not an array or does not include `right`? */
50
+ export declare const notArrayWith: (left: unknown, right: unknown) => boolean;
29
51
  /**
30
- * Are two objects equal?
31
- * - Only checks constructor and enumerable own keys (as returned by `Object.keys()`).
52
+ * Are two objects equal based on their own props?
53
+ * - `left` must have every property present in `right`
54
+ * - `left` must not have excess properties not present in `right`
32
55
  *
33
- * @param recursor Function that checks each property of the object.
34
- * - Defaults to `isExactlyEqual()` to check strict equality of the properties.
56
+ * @param recursor Function that checks each prop of the object.
57
+ * - Defaults to `isEqual()` to check strict equality of the properties.
35
58
  * - Use `isDeepEqual()` as the recursor to check to check deep equality of the properties.
36
59
  */
37
- export declare function isObjectEqual<L extends ImmutableObject>(left: L, right: ImmutableObject, recursor?: Match): right is L;
60
+ export declare function isObjectEqual<T extends ImmutableObject>(left: ImmutableObject, right: T, recursor?: Match): left is T;
61
+ /**
62
+ * Are two objects partially equal based on their own props?
63
+ * - `left` must have every property present in `right`
64
+ * - `left` may have have excess properties not present in `right`
65
+ *
66
+ * @param recursor Function that checks each prop of the object.
67
+ * - Defaults to `isEqual()` to check strict equality of the properties.
68
+ * - Use `isDeepEqual()` as the recursor to check to check deep equality of the properties.
69
+ */
70
+ export declare function isObjectMatch<L extends ImmutableObject, R extends ImmutableObject>(left: L | R, right: R, recursor?: Match): left is L & R;
71
+ /** Is unknown value `left` an object with every prop from `right`? */
72
+ export declare const isObjectWith: (left: unknown, right: ImmutableObject) => boolean;
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;