proby 0.2.2 → 0.2.4

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 (2) hide show
  1. package/lib/run.js +15 -5
  2. package/package.json +1 -1
package/lib/run.js CHANGED
@@ -4,27 +4,37 @@ import red from "@rcompat/cli/color/red";
4
4
  import print from "@rcompat/cli/print";
5
5
  import repository from "@rcompat/test/repository";
6
6
  const endings = [".spec.ts", ".spec.js"];
7
- const primitives = ["bigint", "boolean", "string", "number", "symbol"];
8
- function stringify(value) {
7
+ function stringify_scalar(value) {
9
8
  if (value === null)
10
9
  return "null";
11
10
  if (value === undefined)
12
11
  return "undefined";
13
- if (primitives.includes(typeof value)) {
12
+ if (["string", "number", "boolean", "symbol"].includes(typeof value)) {
14
13
  return value.toString();
15
14
  }
15
+ if (typeof value === "bigint") {
16
+ return value.toString() + "n";
17
+ }
16
18
  if (typeof value === "function") {
17
19
  return `[Function${value.name ? `: ${value.name}` : ""}]`;
18
20
  }
21
+ }
22
+ function stringify(value) {
23
+ const scalar = stringify_scalar(value);
24
+ if (scalar !== undefined) {
25
+ return scalar;
26
+ }
19
27
  if (typeof value === "object") {
20
28
  try {
21
- return JSON.stringify(value);
29
+ return JSON.stringify(value, (_, sub) => {
30
+ const s = stringify_scalar(sub);
31
+ return s !== undefined ? s : sub;
32
+ });
22
33
  }
23
34
  catch {
24
35
  return "[Object (circular or unserializable)]";
25
36
  }
26
37
  }
27
- // Fallback
28
38
  return String(value);
29
39
  }
30
40
  export default async (root, subrepo) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proby",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Standard library test runner",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",