shelving 1.32.0 → 1.33.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.
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.32.0",
14
+ "version": "1.33.0",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
package/util/filter.d.ts CHANGED
@@ -12,32 +12,28 @@ export declare type Matcher<L, R> = Matchable<L, R> | ((item: L, target: R) => b
12
12
  /** Match two values using a `Matcher`. */
13
13
  export declare function match<L>(item: L, matcher: Matcher<L, void>): boolean;
14
14
  export declare function match<L, R>(item: L, matcher: Matcher<L, R>, target: R): boolean;
15
- /** Match whether an item is equal to a target. */
16
15
  export declare const IS: (item: unknown, target: unknown) => boolean;
17
- /** Match whether an item is not equal to match a target. */
18
16
  export declare const NOT: (item: unknown, target: unknown) => boolean;
19
- /** Match whether an item exists in an array of targets. */
20
17
  export declare const IN: (item: unknown, targets: ImmutableArray<unknown>) => boolean;
21
- /** Match whether an array of items contains a target. */
22
18
  export declare const CONTAINS: (items: unknown, target: unknown) => boolean;
23
- /** Match whether an item is less than a target. */
24
19
  export declare const LT: (item: unknown, target: unknown) => boolean;
25
- /** Match whether an item is less than or equal to a target. */
26
20
  export declare const LTE: (item: unknown, target: unknown) => boolean;
27
- /** Match whether an item is greater than a target. */
28
21
  export declare const GT: (item: unknown, target: unknown) => boolean;
29
- /** Match whether an item is greater than or equal to a target. */
30
22
  export declare const GTE: (item: unknown, target: unknown) => boolean;
31
- /** Match whether the key of an entry is equal to a target. */
32
- export declare const KEY_IS: ([item]: Entry<unknown>, target: string) => boolean;
33
- /** Match whether the key of an entry is in an array of targets. */
34
- export declare const KEY_IN: ([item]: Entry<unknown>, targets: ImmutableArray<string>) => boolean;
35
- /** Match whether the value of an entry is equal to a target. */
36
- export declare const VALUE_IS: ([, item]: Entry<unknown>, target: unknown) => boolean;
37
- /** Match whether the value of an entry is in an array of targets. */
38
- export declare const VALUE_IN: ([, item]: Entry<unknown>, targets: ImmutableArray<unknown>) => boolean;
39
- /** Match whether the value of an entry is defined. */
40
- export declare const VALUE_DEFINED: ([, item]: Entry<unknown>) => boolean;
23
+ export declare const KEY_IS: ([key]: Entry<unknown>, target: string) => boolean;
24
+ export declare const KEY_NOT: ([key]: Entry<unknown>, targets: ImmutableArray<string>) => boolean;
25
+ export declare const KEY_IN: ([key]: Entry<unknown>, targets: ImmutableArray<string>) => boolean;
26
+ export declare const KEY_LT: ([key]: Entry<unknown>, target: unknown) => boolean;
27
+ export declare const KEY_LTE: ([key]: Entry<unknown>, target: unknown) => boolean;
28
+ export declare const KEY_GT: ([key]: Entry<unknown>, target: unknown) => boolean;
29
+ export declare const KEY_GTE: ([key]: Entry<unknown>, target: unknown) => boolean;
30
+ export declare const VALUE_IS: ([, value]: Entry<unknown>, target: unknown) => boolean;
31
+ export declare const VALUE_NOT: ([, value]: Entry<unknown>, target: unknown) => boolean;
32
+ export declare const VALUE_IN: ([, value]: Entry<unknown>, targets: ImmutableArray<unknown>) => boolean;
33
+ export declare const VALUE_LT: ([, value]: Entry<unknown>, target: unknown) => boolean;
34
+ export declare const VALUE_LTE: ([, value]: Entry<unknown>, target: unknown) => boolean;
35
+ export declare const VALUE_GT: ([, value]: Entry<unknown>, target: unknown) => boolean;
36
+ export declare const VALUE_GTE: ([, value]: Entry<unknown>, target: unknown) => boolean;
41
37
  /** Filter an iterable set of items using a matcher (and optionally a target value). */
42
38
  export declare function yieldFiltered<L>(input: Iterable<L>, matcher: Matcher<L, void>): Iterable<L>;
43
39
  export declare function yieldFiltered<L, R>(input: Iterable<L>, matcher: Matcher<L, R>, target: R): Iterable<L>;
package/util/filter.js CHANGED
@@ -3,32 +3,31 @@ import { transform } from "./transform.js";
3
3
  export function match(item, matcher, target) {
4
4
  return typeof matcher === "function" ? matcher(item, target) : matcher.match(item, target);
5
5
  }
6
- /** Match whether an item is equal to a target. */
6
+ // Regular matchers.
7
7
  export const IS = (item, target) => item === target;
8
- /** Match whether an item is not equal to match a target. */
9
8
  export const NOT = (item, target) => item !== target;
10
- /** Match whether an item exists in an array of targets. */
11
9
  export const IN = (item, targets) => targets.includes(item);
12
- /** Match whether an array of items contains a target. */
13
10
  export const CONTAINS = (items, target) => items instanceof Array && items.includes(target);
14
- /** Match whether an item is less than a target. */
15
11
  export const LT = (item, target) => ASC(item, target) < 0;
16
- /** Match whether an item is less than or equal to a target. */
17
12
  export const LTE = (item, target) => ASC(item, target) <= 0;
18
- /** Match whether an item is greater than a target. */
19
13
  export const GT = (item, target) => ASC(item, target) > 0;
20
- /** Match whether an item is greater than or equal to a target. */
21
14
  export const GTE = (item, target) => ASC(item, target) >= 0;
22
- /** Match whether the key of an entry is equal to a target. */
23
- export const KEY_IS = ([item], target) => item === target;
24
- /** Match whether the key of an entry is in an array of targets. */
25
- export const KEY_IN = ([item], targets) => targets.includes(item);
26
- /** Match whether the value of an entry is equal to a target. */
27
- export const VALUE_IS = ([, item], target) => item === target;
28
- /** Match whether the value of an entry is in an array of targets. */
29
- export const VALUE_IN = ([, item], targets) => targets.includes(item);
30
- /** Match whether the value of an entry is defined. */
31
- export const VALUE_DEFINED = ([, item]) => item !== undefined;
15
+ // Entry key matchers.
16
+ export const KEY_IS = ([key], target) => IS(key, target);
17
+ export const KEY_NOT = ([key], targets) => IN(key, targets);
18
+ export const KEY_IN = ([key], targets) => IN(key, targets);
19
+ export const KEY_LT = ([key], target) => LT(key, target);
20
+ export const KEY_LTE = ([key], target) => LTE(key, target);
21
+ export const KEY_GT = ([key], target) => GT(key, target);
22
+ export const KEY_GTE = ([key], target) => GTE(key, target);
23
+ // Entry value matchers.
24
+ export const VALUE_IS = ([, value], target) => IS(value, target);
25
+ export const VALUE_NOT = ([, value], target) => NOT(value, target);
26
+ export const VALUE_IN = ([, value], targets) => IN(value, targets);
27
+ export const VALUE_LT = ([, value], target) => LT(value, target);
28
+ export const VALUE_LTE = ([, value], target) => LTE(value, target);
29
+ export const VALUE_GT = ([, value], target) => GT(value, target);
30
+ export const VALUE_GTE = ([, value], target) => GTE(value, target);
32
31
  export function* yieldFiltered(input, matcher, target) {
33
32
  for (const item of input)
34
33
  if (match(item, matcher, target))