shelving 1.176.2 → 1.177.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.176.2",
14
+ "version": "1.177.0",
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "git+https://github.com/dhoulb/shelving.git"
package/util/error.d.ts CHANGED
@@ -21,6 +21,13 @@ 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
+ * Join a dictionary of named messages back into a single string.
26
+ * - The `""` (empty string) key is emitted as unnamed lines.
27
+ * - Named messages are emitted as `name: message`, one line per message line.
28
+ * - Empty lines are skipped and each emitted line is trimmed to match `splitMessage()` semantics.
29
+ */
30
+ export declare function joinMessage(input: ImmutableDictionary<string>): string;
24
31
  /**
25
32
  * Name a message by applying a `name: ` prefix to it.
26
33
  * - Assumes each line in the message is a separate error, so each line has the same prefix applied.
package/util/error.js CHANGED
@@ -52,6 +52,24 @@ export function splitMessage(input) {
52
52
  }
53
53
  return output;
54
54
  }
55
+ /**
56
+ * Join a dictionary of named messages back into a single string.
57
+ * - The `""` (empty string) key is emitted as unnamed lines.
58
+ * - Named messages are emitted as `name: message`, one line per message line.
59
+ * - Empty lines are skipped and each emitted line is trimmed to match `splitMessage()` semantics.
60
+ */
61
+ export function joinMessage(input) {
62
+ const output = [];
63
+ for (const [name, message] of Object.entries(input)) {
64
+ for (const line of message.split("\n")) {
65
+ const value = line.trim();
66
+ if (!value.length)
67
+ continue;
68
+ output.push(name ? `${name}: ${value}` : value);
69
+ }
70
+ }
71
+ return output.join("\n");
72
+ }
55
73
  /**
56
74
  * Name a message by applying a `name: ` prefix to it.
57
75
  * - Assumes each line in the message is a separate error, so each line has the same prefix applied.