shelving 1.150.10 → 1.150.12

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.150.10",
14
+ "version": "1.150.12",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
package/store/Store.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DeferredSequence } from "../sequence/DeferredSequence.js";
2
2
  import { NONE } from "../util/constants.js";
3
+ import { isDeepEqual } from "../util/equal.js";
3
4
  import { getStarter } from "../util/start.js";
4
5
  /**
5
6
  * Store that retains its most recent value and is async-iterable to allow values to be observed.
@@ -25,7 +26,7 @@ export class Store {
25
26
  set value(value) {
26
27
  this._reason = undefined;
27
28
  this._time = Date.now();
28
- if (value !== this._value) {
29
+ if (!isDeepEqual(value, this._value)) {
29
30
  this._value = value;
30
31
  this.next.resolve(value);
31
32
  }
package/util/error.d.ts CHANGED
@@ -21,3 +21,8 @@ export declare function requireMessage(input: PossibleMessage, caller?: AnyCalle
21
21
  * - Unnamed messages are combined into a single entry with the key `""` (empty string).
22
22
  */
23
23
  export declare function splitMessage(input: PossibleMessage): ImmutableDictionary<string>;
24
+ /**
25
+ * Name a message by applying a `name: ` prefix to it.
26
+ * - Assumes each line in the message is a separate error, so each line has the same prefix applied.
27
+ */
28
+ export declare function getNamedMessage(name: string, message: string): string;
package/util/error.js CHANGED
@@ -48,3 +48,10 @@ export function splitMessage(input) {
48
48
  }
49
49
  return output;
50
50
  }
51
+ /**
52
+ * Name a message by applying a `name: ` prefix to it.
53
+ * - Assumes each line in the message is a separate error, so each line has the same prefix applied.
54
+ */
55
+ export function getNamedMessage(name, message) {
56
+ return `${name}: ${message.split("\n").join(`\n${name}: `)}`;
57
+ }
@@ -36,7 +36,6 @@ export declare function getValid<T>(value: unknown, validator: Validator<T>, Err
36
36
  *
37
37
  * @yield Valid items.
38
38
  * @throw Feedback if one or more items did not validate.
39
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
40
39
  */
41
40
  export declare function validateItems<T>(unsafeItems: PossibleArray<unknown>, validator: Validator<T>): Iterable<T>;
42
41
  /**
@@ -44,14 +43,12 @@ export declare function validateItems<T>(unsafeItems: PossibleArray<unknown>, va
44
43
  *
45
44
  * @return Array with valid items.
46
45
  * @throw Feedback if one or more entry values did not validate.
47
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
48
46
  */
49
47
  export declare function validateArray<T>(unsafeArray: PossibleArray<unknown>, validator: Validator<T>): ImmutableArray<T>;
50
48
  /**
51
49
  * Validate the values of the entries in a dictionary object.
52
50
  *
53
51
  * @throw Feedback if one or more entry values did not validate.
54
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
55
52
  */
56
53
  export declare function validateDictionary<T>(unsafeDictionary: ImmutableDictionary<unknown>, validator: Validator<T>): ImmutableDictionary<T>;
57
54
  /**
@@ -64,7 +61,6 @@ export declare function validateDictionary<T>(unsafeDictionary: ImmutableDiction
64
61
  *
65
62
  * @return Valid object.
66
63
  * @throw Feedback if one or more props did not validate.
67
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
68
64
  */
69
65
  export declare function validateData<T extends Data>(unsafeData: Data, validators: Validators<T>, partial: true): DeepPartial<T>;
70
66
  export declare function validateData<T extends Data>(unsafeData: Data, validators: Validators<T>, partial?: false): T;
package/util/validate.js CHANGED
@@ -3,6 +3,7 @@ import { Feedback, ValueFeedback } from "../feedback/Feedback.js";
3
3
  import { isArray } from "./array.js";
4
4
  import { getDataKeys, getDataProps } from "./data.js";
5
5
  import { getDictionaryItems } from "./dictionary.js";
6
+ import { getNamedMessage } from "./error.js";
6
7
  import { PASSTHROUGH } from "./function.js";
7
8
  import { isIterable } from "./iterate.js";
8
9
  import { getNull } from "./null.js";
@@ -25,7 +26,6 @@ export function getValid(value, validator, ErrorConstructor = ValueError, caller
25
26
  *
26
27
  * @yield Valid items.
27
28
  * @throw Feedback if one or more items did not validate.
28
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
29
29
  */
30
30
  export function* validateItems(unsafeItems, validator) {
31
31
  let index = 0;
@@ -37,7 +37,7 @@ export function* validateItems(unsafeItems, validator) {
37
37
  catch (thrown) {
38
38
  if (!(thrown instanceof Feedback))
39
39
  throw thrown;
40
- messages.push(`${index}: ${thrown.message}`);
40
+ messages.push(getNamedMessage(index.toString(), thrown.message));
41
41
  }
42
42
  index++;
43
43
  }
@@ -49,7 +49,6 @@ export function* validateItems(unsafeItems, validator) {
49
49
  *
50
50
  * @return Array with valid items.
51
51
  * @throw Feedback if one or more entry values did not validate.
52
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
53
52
  */
54
53
  export function validateArray(unsafeArray, validator) {
55
54
  let index = 0;
@@ -66,7 +65,7 @@ export function validateArray(unsafeArray, validator) {
66
65
  catch (thrown) {
67
66
  if (!(thrown instanceof Feedback))
68
67
  throw thrown;
69
- messages.push(`${index}: ${thrown.message}`);
68
+ messages.push(getNamedMessage(index.toString(), thrown.message));
70
69
  }
71
70
  index++;
72
71
  }
@@ -78,7 +77,6 @@ export function validateArray(unsafeArray, validator) {
78
77
  * Validate the values of the entries in a dictionary object.
79
78
  *
80
79
  * @throw Feedback if one or more entry values did not validate.
81
- * - `feedback.details` will contain an entry for each invalid item (keyed by their count in the input iterable).
82
80
  */
83
81
  export function validateDictionary(unsafeDictionary, validator) {
84
82
  let changed = false;
@@ -94,7 +92,7 @@ export function validateDictionary(unsafeDictionary, validator) {
94
92
  catch (thrown) {
95
93
  if (!(thrown instanceof Feedback))
96
94
  throw thrown;
97
- messages.push(`${key}: ${thrown.message}`);
95
+ messages.push(getNamedMessage(key, thrown.message));
98
96
  }
99
97
  }
100
98
  if (messages.length)
@@ -124,7 +122,7 @@ export function validateData(unsafeData, validators, partial = isDeeplyPartial)
124
122
  catch (thrown) {
125
123
  if (!(thrown instanceof Feedback))
126
124
  throw thrown;
127
- messages.push(`${key}: ${thrown.message}`);
125
+ messages.push(getNamedMessage(key, thrown.message));
128
126
  }
129
127
  }
130
128
  if (messages.length)