@effected/images 0.6.1 → 0.6.2

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.
@@ -3,10 +3,25 @@ import { Predicate } from "effect";
3
3
  // src/internal/causeMessage.ts
4
4
  /** How many nodes of a cause chain the walk reads before stopping, so a cyclic chain cannot spin. */
5
5
  const CAUSE_DEPTH = 8;
6
- /** The message a single node carries: a thrown string, or a non-empty string `message` property. */
6
+ /**
7
+ * The message a single node carries: a thrown string, or a non-empty string `message` property. A getter or
8
+ * proxy trap that throws is a node with no message.
9
+ */
7
10
  const messageAt = (node) => {
8
- const text = Predicate.isString(node) ? node : Predicate.hasProperty(node, "message") && Predicate.isString(node.message) ? node.message : void 0;
9
- return text === void 0 || text.trim() === "" ? void 0 : text;
11
+ try {
12
+ const text = Predicate.isString(node) ? node : Predicate.hasProperty(node, "message") && Predicate.isString(node.message) ? node.message : void 0;
13
+ return text === void 0 || text.trim() === "" ? void 0 : text;
14
+ } catch {
15
+ return;
16
+ }
17
+ };
18
+ /** The next link of the chain: a node's `cause`, or `undefined` when it has none or reading it throws. */
19
+ const causeAt = (node) => {
20
+ try {
21
+ return Predicate.hasProperty(node, "cause") ? node.cause : void 0;
22
+ } catch {
23
+ return;
24
+ }
10
25
  };
11
26
  /**
12
27
  * Every distinct non-empty message a preserved cause chain carries, nearest
@@ -21,6 +36,9 @@ const messageAt = (node) => {
21
36
  * actionable detail, yet a wrapper that composes its own context must not
22
37
  * lose it either; so nothing is dropped, and a deeper text the nearer one
23
38
  * already contains is not repeated. The walk is bounded, so a cycle terminates.
39
+ *
40
+ * It never throws: every property read is guarded, so a `message` getter that throws leaves that link
41
+ * without text, and a `cause` getter that throws ends the walk with what was found so far.
24
42
  */
25
43
  const causeMessage = (cause) => {
26
44
  let message;
@@ -31,7 +49,7 @@ const causeMessage = (cause) => {
31
49
  if (message === void 0 || text.includes(message)) message = text;
32
50
  else if (!message.includes(text)) message = `${message}: ${text}`;
33
51
  }
34
- node = Predicate.hasProperty(node, "cause") ? node.cause : void 0;
52
+ node = causeAt(node);
35
53
  }
36
54
  return message;
37
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/images",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "description": "Image facts (format, MIME type, dimensions) from bytes, and a generated-image cache, for Effect.",
6
6
  "keywords": [
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.1"
8
+ "packageVersion": "7.59.4"
9
9
  }
10
10
  ]
11
11
  }