@devvit/shared-types 0.10.15-next-2024-01-29-f0627888e.0 → 0.10.15-next-2024-01-29-adfc024ef.0

Sign up to get free protection for your applications and to get access to all the features.
package/inspect.d.ts CHANGED
@@ -4,8 +4,11 @@ export type Options = {
4
4
  /**
5
5
  * Similar to node's standard util.inspect, with the following differences:
6
6
  * - Strings are not escaped (for example, when they have quote marks in them)
7
+ * and not enclosed in quotes
7
8
  * - Symbol keys in objects are dropped and not printed
8
9
  * - Prints arrays with more items per line sometimes
10
+ * - Errors may include a stacktrace
11
+ * - Promises are terse
9
12
  * - There's no color output
10
13
  */
11
14
  export declare function inspect(val: unknown, options?: Partial<Options>): string;
package/inspect.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAkBF;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAiBxE"}
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../src/inspect.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAkBF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAaxE"}
package/inspect.js CHANGED
@@ -1,19 +1,19 @@
1
1
  const indentPerLevel = ' '; // 2 spaces
2
- const smallThreashold = 55;
2
+ const smallThreshold = 55;
3
3
  const defaultOptions = {
4
4
  depth: 2,
5
5
  };
6
6
  /**
7
7
  * Similar to node's standard util.inspect, with the following differences:
8
8
  * - Strings are not escaped (for example, when they have quote marks in them)
9
+ * and not enclosed in quotes
9
10
  * - Symbol keys in objects are dropped and not printed
10
11
  * - Prints arrays with more items per line sometimes
12
+ * - Errors may include a stacktrace
13
+ * - Promises are terse
11
14
  * - There's no color output
12
15
  */
13
16
  export function inspect(val, options) {
14
- if (val instanceof Error) {
15
- return `${val.name}: ${val.message}`;
16
- }
17
17
  const indent = '';
18
18
  const refs = {
19
19
  visited: new Map(),
@@ -31,13 +31,21 @@ function inspectRoot(val, args, refs, indent) {
31
31
  if (val === null) {
32
32
  return 'null';
33
33
  }
34
+ if (val instanceof Date) {
35
+ return val.toISOString();
36
+ }
37
+ if (val instanceof Error) {
38
+ return val.stack || `${val.name}: ${val.message}`;
39
+ }
40
+ if (val instanceof Promise) {
41
+ return `[Promise]`;
42
+ }
34
43
  return inspectObject(val, args, refs, indent);
35
44
  case 'undefined':
36
45
  return 'undefined';
37
46
  case 'function':
38
47
  return `[Function: ${val.name}]`;
39
- case 'string':
40
- return `'${val}'`;
48
+ case 'string': // fallthrough
41
49
  case 'number': // fallthrough
42
50
  case 'bigint': // fallthrough
43
51
  case 'boolean': // fallthrough
@@ -96,13 +104,11 @@ function inspectObject(obj, args, refs, indent) {
96
104
  // if any children referenced this node, we've got to add a ref label
97
105
  const refLabel = refConfig.refNumber ? `⟨ref *${refConfig.refNumber}⟩ ` : '';
98
106
  // handle small objects in a single line
99
- if (totalLength < smallThreashold) {
107
+ if (totalLength < smallThreshold) {
100
108
  if (Array.isArray(obj)) {
101
109
  return `${refLabel}[ ${entries.join(', ')} ]`;
102
110
  }
103
- else {
104
- return `${refLabel}{${entries.map(([key, val]) => `${key}: ${val}`).join(', ')}}`;
105
- }
111
+ return `${refLabel}{${entries.map(([key, val]) => `${key}: ${val}`).join(', ')}}`;
106
112
  }
107
113
  // handle large objects by indenting/formatting
108
114
  let result = `${refLabel}${Array.isArray(obj) ? '[' : '{'}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devvit/shared-types",
3
- "version": "0.10.15-next-2024-01-29-f0627888e.0",
3
+ "version": "0.10.15-next-2024-01-29-adfc024ef.0",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "types": "./index.d.ts",
25
25
  "dependencies": {
26
- "@devvit/protos": "0.10.15-next-2024-01-29-f0627888e.0"
26
+ "@devvit/protos": "0.10.15-next-2024-01-29-adfc024ef.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@devvit/eslint-config": "0.10.14",
30
30
  "@devvit/repo-tools": "0.10.14",
31
- "@devvit/tsconfig": "0.10.15-next-2024-01-29-f0627888e.0",
31
+ "@devvit/tsconfig": "0.10.15-next-2024-01-29-adfc024ef.0",
32
32
  "eslint": "8.9.0",
33
33
  "typescript": "5.3.2",
34
34
  "vitest": "0.31.0"
@@ -37,5 +37,5 @@
37
37
  "directory": "dist"
38
38
  },
39
39
  "source": "./src/index.ts",
40
- "gitHead": "73866255fcb6d6d6355c7dc774131c5e3e9b3385"
40
+ "gitHead": "5193c583e2099f5831b67f392508c326fa8e9527"
41
41
  }