effect 3.19.2 → 3.19.3

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 (48) hide show
  1. package/dist/cjs/Inspectable.js +86 -4
  2. package/dist/cjs/Inspectable.js.map +1 -1
  3. package/dist/cjs/ParseResult.js +1 -1
  4. package/dist/cjs/ParseResult.js.map +1 -1
  5. package/dist/cjs/Pretty.js +4 -3
  6. package/dist/cjs/Pretty.js.map +1 -1
  7. package/dist/cjs/Schema.js +15 -14
  8. package/dist/cjs/Schema.js.map +1 -1
  9. package/dist/cjs/SchemaAST.js +4 -3
  10. package/dist/cjs/SchemaAST.js.map +1 -1
  11. package/dist/cjs/internal/config.js +10 -9
  12. package/dist/cjs/internal/config.js.map +1 -1
  13. package/dist/cjs/internal/schema/errors.js +6 -5
  14. package/dist/cjs/internal/schema/errors.js.map +1 -1
  15. package/dist/cjs/internal/schema/util.js +3 -77
  16. package/dist/cjs/internal/schema/util.js.map +1 -1
  17. package/dist/cjs/internal/version.js +1 -1
  18. package/dist/dts/Inspectable.d.ts.map +1 -1
  19. package/dist/dts/Pretty.d.ts.map +1 -1
  20. package/dist/dts/Schema.d.ts.map +1 -1
  21. package/dist/dts/SchemaAST.d.ts.map +1 -1
  22. package/dist/esm/Inspectable.js +79 -2
  23. package/dist/esm/Inspectable.js.map +1 -1
  24. package/dist/esm/ParseResult.js +1 -1
  25. package/dist/esm/ParseResult.js.map +1 -1
  26. package/dist/esm/Pretty.js +4 -3
  27. package/dist/esm/Pretty.js.map +1 -1
  28. package/dist/esm/Schema.js +15 -14
  29. package/dist/esm/Schema.js.map +1 -1
  30. package/dist/esm/SchemaAST.js +4 -3
  31. package/dist/esm/SchemaAST.js.map +1 -1
  32. package/dist/esm/internal/config.js +10 -9
  33. package/dist/esm/internal/config.js.map +1 -1
  34. package/dist/esm/internal/schema/errors.js +6 -5
  35. package/dist/esm/internal/schema/errors.js.map +1 -1
  36. package/dist/esm/internal/schema/util.js +2 -72
  37. package/dist/esm/internal/schema/util.js.map +1 -1
  38. package/dist/esm/internal/version.js +1 -1
  39. package/package.json +1 -1
  40. package/src/Inspectable.ts +115 -2
  41. package/src/ParseResult.ts +1 -1
  42. package/src/Pretty.ts +4 -3
  43. package/src/Schema.ts +18 -14
  44. package/src/SchemaAST.ts +4 -3
  45. package/src/internal/config.ts +15 -9
  46. package/src/internal/schema/errors.ts +12 -5
  47. package/src/internal/schema/util.ts +2 -100
  48. package/src/internal/version.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { NonEmptyReadonlyArray } from "../../Array.js"
2
+ import * as Inspectable from "../../Inspectable.js"
2
3
  import type * as ParseResult from "../../ParseResult.js"
3
- import * as Predicate from "../../Predicate.js"
4
4
  import type * as AST from "../../SchemaAST.js"
5
5
 
6
6
  /** @internal */
@@ -33,104 +33,6 @@ export const memoizeThunk = <A>(f: () => A): () => A => {
33
33
  }
34
34
  }
35
35
 
36
- /** @internal */
37
- export const formatDate = (date: Date): string => {
38
- try {
39
- return date.toISOString()
40
- } catch {
41
- return String(date)
42
- }
43
- }
44
-
45
- const CIRCULAR = "[Circular]"
46
-
47
- /** @internal */
48
- export function formatUnknown(input: unknown, whitespace: number | string | undefined = 0): string {
49
- const seen = new WeakSet<object>()
50
- const gap = !whitespace ? "" : (typeof whitespace === "number" ? " ".repeat(whitespace) : whitespace)
51
- const ind = (d: number) => gap.repeat(d)
52
-
53
- const safeToString = (x: any): string => {
54
- try {
55
- const s = x.toString()
56
- return typeof s === "string" ? s : String(s)
57
- } catch {
58
- return "[toString threw]"
59
- }
60
- }
61
-
62
- const wrap = (v: unknown, body: string): string => {
63
- const ctor = (v as any)?.constructor
64
- return ctor && ctor !== Object.prototype.constructor && ctor.name ? `${ctor.name}(${body})` : body
65
- }
66
-
67
- const ownKeys = (o: object): Array<PropertyKey> => {
68
- try {
69
- return Reflect.ownKeys(o)
70
- } catch {
71
- return ["[ownKeys threw]"]
72
- }
73
- }
74
-
75
- function go(v: unknown, d = 0): string {
76
- if (Array.isArray(v)) {
77
- if (seen.has(v)) return CIRCULAR
78
- seen.add(v)
79
- if (!gap || v.length <= 1) return `[${v.map((x) => go(x, d)).join(",")}]`
80
- const inner = v.map((x) => go(x, d + 1)).join(",\n" + ind(d + 1))
81
- return `[\n${ind(d + 1)}${inner}\n${ind(d)}]`
82
- }
83
-
84
- if (Predicate.isDate(v)) return formatDate(v)
85
-
86
- if (
87
- Predicate.hasProperty(v, "toString") &&
88
- Predicate.isFunction((v as any)["toString"]) &&
89
- (v as any)["toString"] !== Object.prototype.toString
90
- ) return safeToString(v)
91
-
92
- if (Predicate.isString(v)) return JSON.stringify(v)
93
-
94
- if (
95
- Predicate.isNumber(v) ||
96
- v == null ||
97
- Predicate.isBoolean(v) ||
98
- Predicate.isSymbol(v)
99
- ) return String(v)
100
-
101
- if (Predicate.isBigInt(v)) return String(v) + "n"
102
-
103
- if (v instanceof Set || v instanceof Map) {
104
- if (seen.has(v)) return CIRCULAR
105
- seen.add(v)
106
- return `${v.constructor.name}(${go(Array.from(v), d)})`
107
- }
108
-
109
- if (Predicate.isObject(v)) {
110
- if (seen.has(v)) return CIRCULAR
111
- seen.add(v)
112
- const keys = ownKeys(v)
113
- if (!gap || keys.length <= 1) {
114
- const body = `{${keys.map((k) => `${formatPropertyKey(k)}:${go((v as any)[k], d)}`).join(",")}}`
115
- return wrap(v, body)
116
- }
117
- const body = `{\n${
118
- keys.map((k) => `${ind(d + 1)}${formatPropertyKey(k)}: ${go((v as any)[k], d + 1)}`).join(",\n")
119
- }\n${ind(d)}}`
120
- return wrap(v, body)
121
- }
122
-
123
- return String(v)
124
- }
125
-
126
- return go(input, 0)
127
- }
128
-
129
- /** @internal */
130
- export function formatPropertyKey(name: PropertyKey): string {
131
- return Predicate.isString(name) ? JSON.stringify(name) : String(name)
132
- }
133
-
134
36
  /** @internal */
135
37
  export type SingleOrArray<A> = A | ReadonlyArray<A>
136
38
 
@@ -141,7 +43,7 @@ export const isNonEmpty = <A>(x: ParseResult.SingleOrNonEmpty<A>): x is NonEmpty
141
43
  export const isSingle = <A>(x: A | ReadonlyArray<A>): x is A => !Array.isArray(x)
142
44
 
143
45
  /** @internal */
144
- export const formatPathKey = (key: PropertyKey): string => `[${formatPropertyKey(key)}]`
46
+ export const formatPathKey = (key: PropertyKey): string => `[${Inspectable.formatPropertyKey(key)}]`
145
47
 
146
48
  /** @internal */
147
49
  export const formatPath = (path: ParseResult.Path): string =>
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.19.2"
1
+ let moduleVersion = "3.19.3"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4