effect 3.12.4 → 3.12.6
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/dist/cjs/Arbitrary.js +72 -14
- package/dist/cjs/Arbitrary.js.map +1 -1
- package/dist/cjs/Array.js +11 -9
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/Cause.js +26 -2
- package/dist/cjs/Cause.js.map +1 -1
- package/dist/cjs/Cron.js +55 -23
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/Duration.js.map +1 -1
- package/dist/cjs/Effect.js +32 -23
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/FiberHandle.js +8 -8
- package/dist/cjs/FiberMap.js +8 -8
- package/dist/cjs/FiberSet.js +8 -8
- package/dist/cjs/Inspectable.js +0 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/LogLevel.js +30 -2
- package/dist/cjs/LogLevel.js.map +1 -1
- package/dist/cjs/ParseResult.js +38 -18
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +192 -118
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/cause.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +6 -5
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/core.js +6 -5
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +12 -3
- package/dist/cjs/internal/dateTime.js.map +1 -1
- package/dist/cjs/internal/effect/circular.js +15 -2
- package/dist/cjs/internal/effect/circular.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +7 -7
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/rateLimiter.js +8 -7
- package/dist/cjs/internal/rateLimiter.js.map +1 -1
- package/dist/cjs/internal/runtime.js +7 -11
- package/dist/cjs/internal/runtime.js.map +1 -1
- package/dist/cjs/internal/stream.js +5 -5
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Arbitrary.d.ts.map +1 -1
- package/dist/dts/Array.d.ts +62 -16
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +27 -3
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +10 -3
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/Duration.d.ts +5 -5
- package/dist/dts/Duration.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +31 -22
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts +8 -8
- package/dist/dts/FiberMap.d.ts +8 -8
- package/dist/dts/FiberSet.d.ts +8 -8
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/LogLevel.d.ts +90 -6
- package/dist/dts/LogLevel.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts +11 -0
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +53 -33
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/core.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Arbitrary.js +72 -14
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/Array.js +11 -9
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Cause.js +26 -2
- package/dist/esm/Cause.js.map +1 -1
- package/dist/esm/Cron.js +53 -22
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/Duration.js.map +1 -1
- package/dist/esm/Effect.js +32 -23
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/FiberHandle.js +8 -8
- package/dist/esm/FiberMap.js +8 -8
- package/dist/esm/FiberSet.js +8 -8
- package/dist/esm/Inspectable.js +0 -3
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/LogLevel.js +30 -2
- package/dist/esm/LogLevel.js.map +1 -1
- package/dist/esm/ParseResult.js +38 -18
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +186 -110
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/internal/cause.js.map +1 -1
- package/dist/esm/internal/core-effect.js +6 -5
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/core.js +6 -5
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/dateTime.js +11 -2
- package/dist/esm/internal/dateTime.js.map +1 -1
- package/dist/esm/internal/effect/circular.js +15 -2
- package/dist/esm/internal/effect/circular.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +7 -7
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/rateLimiter.js +8 -7
- package/dist/esm/internal/rateLimiter.js.map +1 -1
- package/dist/esm/internal/runtime.js +7 -11
- package/dist/esm/internal/runtime.js.map +1 -1
- package/dist/esm/internal/stream.js +5 -5
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +84 -14
- package/src/Array.ts +65 -19
- package/src/Cause.ts +27 -3
- package/src/Cron.ts +30 -27
- package/src/Duration.ts +11 -3
- package/src/Effect.ts +35 -23
- package/src/FiberHandle.ts +8 -8
- package/src/FiberMap.ts +8 -8
- package/src/FiberSet.ts +8 -8
- package/src/Inspectable.ts +0 -1
- package/src/LogLevel.ts +90 -6
- package/src/ParseResult.ts +52 -28
- package/src/Schema.ts +233 -124
- package/src/internal/cause.ts +1 -1
- package/src/internal/core-effect.ts +16 -9
- package/src/internal/core.ts +9 -4
- package/src/internal/dateTime.ts +12 -2
- package/src/internal/effect/circular.ts +19 -17
- package/src/internal/fiberRuntime.ts +2 -1
- package/src/internal/groupBy.ts +35 -39
- package/src/internal/rateLimiter.ts +8 -7
- package/src/internal/runtime.ts +6 -14
- package/src/internal/stream.ts +13 -15
- package/src/internal/version.ts +1 -1
package/src/FiberMap.ts
CHANGED
|
@@ -101,14 +101,14 @@ const unsafeMake = <K, A = unknown, E = unknown>(
|
|
|
101
101
|
* ```ts
|
|
102
102
|
* import { Effect, FiberMap } from "effect"
|
|
103
103
|
*
|
|
104
|
-
* Effect.gen(function*(
|
|
105
|
-
* const map = yield*
|
|
104
|
+
* Effect.gen(function*() {
|
|
105
|
+
* const map = yield* FiberMap.make<string>()
|
|
106
106
|
*
|
|
107
107
|
* // run some effects and add the fibers to the map
|
|
108
|
-
* yield*
|
|
109
|
-
* yield*
|
|
108
|
+
* yield* FiberMap.run(map, "fiber a", Effect.never)
|
|
109
|
+
* yield* FiberMap.run(map, "fiber b", Effect.never)
|
|
110
110
|
*
|
|
111
|
-
* yield*
|
|
111
|
+
* yield* Effect.sleep(1000)
|
|
112
112
|
* }).pipe(
|
|
113
113
|
* Effect.scoped // The fibers will be interrupted when the scope is closed
|
|
114
114
|
* )
|
|
@@ -619,9 +619,9 @@ export const run: {
|
|
|
619
619
|
* getAll: Effect.Effect<Array<unknown>>
|
|
620
620
|
* }>("Users")
|
|
621
621
|
*
|
|
622
|
-
* Effect.gen(function*(
|
|
623
|
-
* const map = yield*
|
|
624
|
-
* const run = yield*
|
|
622
|
+
* Effect.gen(function*() {
|
|
623
|
+
* const map = yield* FiberMap.make<string>()
|
|
624
|
+
* const run = yield* FiberMap.runtime(map)<Users>()
|
|
625
625
|
*
|
|
626
626
|
* // run some effects and add the fibers to the map
|
|
627
627
|
* run("effect-a", Effect.andThen(Users, _ => _.getAll))
|
package/src/FiberSet.ts
CHANGED
|
@@ -98,14 +98,14 @@ const unsafeMake = <A, E>(
|
|
|
98
98
|
* ```ts
|
|
99
99
|
* import { Effect, FiberSet } from "effect"
|
|
100
100
|
*
|
|
101
|
-
* Effect.gen(function*(
|
|
102
|
-
* const set = yield*
|
|
101
|
+
* Effect.gen(function*() {
|
|
102
|
+
* const set = yield* FiberSet.make()
|
|
103
103
|
*
|
|
104
104
|
* // run some effects and add the fibers to the set
|
|
105
|
-
* yield*
|
|
106
|
-
* yield*
|
|
105
|
+
* yield* FiberSet.run(set, Effect.never)
|
|
106
|
+
* yield* FiberSet.run(set, Effect.never)
|
|
107
107
|
*
|
|
108
|
-
* yield*
|
|
108
|
+
* yield* Effect.sleep(1000)
|
|
109
109
|
* }).pipe(
|
|
110
110
|
* Effect.scoped // The fibers will be interrupted when the scope is closed
|
|
111
111
|
* )
|
|
@@ -372,9 +372,9 @@ export const run: {
|
|
|
372
372
|
* getAll: Effect.Effect<Array<unknown>>
|
|
373
373
|
* }>("Users")
|
|
374
374
|
*
|
|
375
|
-
* Effect.gen(function*(
|
|
376
|
-
* const set = yield*
|
|
377
|
-
* const run = yield*
|
|
375
|
+
* Effect.gen(function*() {
|
|
376
|
+
* const set = yield* FiberSet.make()
|
|
377
|
+
* const run = yield* FiberSet.runtime(set)<Users>()
|
|
378
378
|
*
|
|
379
379
|
* // run some effects and add the fibers to the set
|
|
380
380
|
* run(Effect.andThen(Users, _ => _.getAll))
|
package/src/Inspectable.ts
CHANGED
package/src/LogLevel.ts
CHANGED
|
@@ -171,24 +171,108 @@ export const None: LogLevel = core.logLevelNone
|
|
|
171
171
|
export const allLevels = core.allLogLevels
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
174
|
+
* Temporarily sets a `LogLevel` for an `Effect` workflow.
|
|
175
|
+
*
|
|
176
|
+
* **Details**
|
|
177
|
+
*
|
|
178
|
+
* This function allows you to apply a specific `LogLevel` locally to an
|
|
179
|
+
* `Effect` workflow. Once the workflow completes, the `LogLevel` reverts to its
|
|
180
|
+
* previous state.
|
|
181
|
+
*
|
|
182
|
+
* **When to Use**
|
|
183
|
+
*
|
|
184
|
+
* This is particularly useful when you want to adjust the verbosity of logging
|
|
185
|
+
* for specific parts of your program without affecting the global log level.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* import { Effect, LogLevel } from "effect"
|
|
190
|
+
*
|
|
191
|
+
* const program = Effect.gen(function*() {
|
|
192
|
+
* yield* Effect.log("message1")
|
|
193
|
+
* yield* Effect.gen(function*() {
|
|
194
|
+
* yield* Effect.log("message2")
|
|
195
|
+
* yield* Effect.log("message3")
|
|
196
|
+
* }).pipe(LogLevel.locally(LogLevel.Warning))
|
|
197
|
+
* })
|
|
198
|
+
*
|
|
199
|
+
* // Effect.runFork(program)
|
|
200
|
+
* // timestamp=... level=INFO fiber=#0 message=message1
|
|
201
|
+
* // timestamp=... level=WARN fiber=#0 message=message2
|
|
202
|
+
* // timestamp=... level=WARN fiber=#0 message=message3
|
|
203
|
+
* ```
|
|
176
204
|
*
|
|
177
205
|
* @since 2.0.0
|
|
178
206
|
* @category utils
|
|
179
207
|
*/
|
|
180
208
|
export const locally: {
|
|
181
209
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
210
|
+
* Temporarily sets a `LogLevel` for an `Effect` workflow.
|
|
211
|
+
*
|
|
212
|
+
* **Details**
|
|
213
|
+
*
|
|
214
|
+
* This function allows you to apply a specific `LogLevel` locally to an
|
|
215
|
+
* `Effect` workflow. Once the workflow completes, the `LogLevel` reverts to its
|
|
216
|
+
* previous state.
|
|
217
|
+
*
|
|
218
|
+
* **When to Use**
|
|
219
|
+
*
|
|
220
|
+
* This is particularly useful when you want to adjust the verbosity of logging
|
|
221
|
+
* for specific parts of your program without affecting the global log level.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* import { Effect, LogLevel } from "effect"
|
|
226
|
+
*
|
|
227
|
+
* const program = Effect.gen(function*() {
|
|
228
|
+
* yield* Effect.log("message1")
|
|
229
|
+
* yield* Effect.gen(function*() {
|
|
230
|
+
* yield* Effect.log("message2")
|
|
231
|
+
* yield* Effect.log("message3")
|
|
232
|
+
* }).pipe(LogLevel.locally(LogLevel.Warning))
|
|
233
|
+
* })
|
|
234
|
+
*
|
|
235
|
+
* // Effect.runFork(program)
|
|
236
|
+
* // timestamp=... level=INFO fiber=#0 message=message1
|
|
237
|
+
* // timestamp=... level=WARN fiber=#0 message=message2
|
|
238
|
+
* // timestamp=... level=WARN fiber=#0 message=message3
|
|
239
|
+
* ```
|
|
184
240
|
*
|
|
185
241
|
* @since 2.0.0
|
|
186
242
|
* @category utils
|
|
187
243
|
*/
|
|
188
244
|
(self: LogLevel): <A, E, R>(use: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
|
|
189
245
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
246
|
+
* Temporarily sets a `LogLevel` for an `Effect` workflow.
|
|
247
|
+
*
|
|
248
|
+
* **Details**
|
|
249
|
+
*
|
|
250
|
+
* This function allows you to apply a specific `LogLevel` locally to an
|
|
251
|
+
* `Effect` workflow. Once the workflow completes, the `LogLevel` reverts to its
|
|
252
|
+
* previous state.
|
|
253
|
+
*
|
|
254
|
+
* **When to Use**
|
|
255
|
+
*
|
|
256
|
+
* This is particularly useful when you want to adjust the verbosity of logging
|
|
257
|
+
* for specific parts of your program without affecting the global log level.
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* import { Effect, LogLevel } from "effect"
|
|
262
|
+
*
|
|
263
|
+
* const program = Effect.gen(function*() {
|
|
264
|
+
* yield* Effect.log("message1")
|
|
265
|
+
* yield* Effect.gen(function*() {
|
|
266
|
+
* yield* Effect.log("message2")
|
|
267
|
+
* yield* Effect.log("message3")
|
|
268
|
+
* }).pipe(LogLevel.locally(LogLevel.Warning))
|
|
269
|
+
* })
|
|
270
|
+
*
|
|
271
|
+
* // Effect.runFork(program)
|
|
272
|
+
* // timestamp=... level=INFO fiber=#0 message=message1
|
|
273
|
+
* // timestamp=... level=WARN fiber=#0 message=message2
|
|
274
|
+
* // timestamp=... level=WARN fiber=#0 message=message3
|
|
275
|
+
* ```
|
|
192
276
|
*
|
|
193
277
|
* @since 2.0.0
|
|
194
278
|
* @category utils
|
package/src/ParseResult.ts
CHANGED
|
@@ -809,11 +809,11 @@ interface Parser {
|
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
const decodeMemoMap = globalValue(
|
|
812
|
-
Symbol.for("effect/
|
|
812
|
+
Symbol.for("effect/ParseResult/decodeMemoMap"),
|
|
813
813
|
() => new WeakMap<AST.AST, Parser>()
|
|
814
814
|
)
|
|
815
815
|
const encodeMemoMap = globalValue(
|
|
816
|
-
Symbol.for("effect/
|
|
816
|
+
Symbol.for("effect/ParseResult/encodeMemoMap"),
|
|
817
817
|
() => new WeakMap<AST.AST, Parser>()
|
|
818
818
|
)
|
|
819
819
|
|
|
@@ -1419,9 +1419,10 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => {
|
|
|
1419
1419
|
case "Union": {
|
|
1420
1420
|
const searchTree = getSearchTree(ast.types, isDecoding)
|
|
1421
1421
|
const ownKeys = util_.ownKeys(searchTree.keys)
|
|
1422
|
-
const
|
|
1422
|
+
const ownKeysLen = ownKeys.length
|
|
1423
|
+
const astTypesLen = ast.types.length
|
|
1423
1424
|
const map = new Map<any, Parser>()
|
|
1424
|
-
for (let i = 0; i <
|
|
1425
|
+
for (let i = 0; i < astTypesLen; i++) {
|
|
1425
1426
|
map.set(ast.types[i], goMemo(ast.types[i], isDecoding))
|
|
1426
1427
|
}
|
|
1427
1428
|
const concurrency = getConcurrency(ast) ?? 1
|
|
@@ -1430,9 +1431,9 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => {
|
|
|
1430
1431
|
const es: Array<[number, ParseIssue]> = []
|
|
1431
1432
|
let stepKey = 0
|
|
1432
1433
|
let candidates: Array<AST.AST> = []
|
|
1433
|
-
if (
|
|
1434
|
+
if (ownKeysLen > 0) {
|
|
1434
1435
|
if (Predicate.isRecordOrArray(input)) {
|
|
1435
|
-
for (let i = 0; i <
|
|
1436
|
+
for (let i = 0; i < ownKeysLen; i++) {
|
|
1436
1437
|
const name = ownKeys[i]
|
|
1437
1438
|
const buckets = searchTree.keys[name].buckets
|
|
1438
1439
|
// for each property that should contain a literal, check if the input contains that property
|
|
@@ -1443,33 +1444,33 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => {
|
|
|
1443
1444
|
// retrive the minimal set of candidates for decoding
|
|
1444
1445
|
candidates = candidates.concat(buckets[literal])
|
|
1445
1446
|
} else {
|
|
1446
|
-
const literals =
|
|
1447
|
+
const { candidates, literals } = searchTree.keys[name]
|
|
1448
|
+
const literalsUnion = AST.Union.make(literals)
|
|
1449
|
+
const errorAst = candidates.length === astTypesLen
|
|
1450
|
+
? new AST.TypeLiteral([new AST.PropertySignature(name, literalsUnion, false, true)], [])
|
|
1451
|
+
: AST.Union.make(candidates)
|
|
1447
1452
|
es.push([
|
|
1448
1453
|
stepKey++,
|
|
1449
|
-
new Composite(
|
|
1450
|
-
new AST.TypeLiteral([
|
|
1451
|
-
new AST.PropertySignature(name, literals, false, true)
|
|
1452
|
-
], []),
|
|
1453
|
-
input,
|
|
1454
|
-
new Pointer(name, input, new Type(literals, input[name]))
|
|
1455
|
-
)
|
|
1454
|
+
new Composite(errorAst, input, new Pointer(name, input, new Type(literalsUnion, input[name])))
|
|
1456
1455
|
])
|
|
1457
1456
|
}
|
|
1458
1457
|
} else {
|
|
1459
|
-
const literals =
|
|
1460
|
-
const
|
|
1458
|
+
const { candidates, literals } = searchTree.keys[name]
|
|
1459
|
+
const fakePropertySignature = new AST.PropertySignature(name, AST.Union.make(literals), false, true)
|
|
1460
|
+
const errorAst = candidates.length === astTypesLen
|
|
1461
|
+
? new AST.TypeLiteral([fakePropertySignature], [])
|
|
1462
|
+
: AST.Union.make(candidates)
|
|
1461
1463
|
es.push([
|
|
1462
1464
|
stepKey++,
|
|
1463
|
-
new Composite(
|
|
1464
|
-
new AST.TypeLiteral([fakeps], []),
|
|
1465
|
-
input,
|
|
1466
|
-
new Pointer(name, input, new Missing(fakeps))
|
|
1467
|
-
)
|
|
1465
|
+
new Composite(errorAst, input, new Pointer(name, input, new Missing(fakePropertySignature)))
|
|
1468
1466
|
])
|
|
1469
1467
|
}
|
|
1470
1468
|
}
|
|
1471
1469
|
} else {
|
|
1472
|
-
|
|
1470
|
+
const errorAst = searchTree.candidates.length === astTypesLen
|
|
1471
|
+
? ast
|
|
1472
|
+
: AST.Union.make(searchTree.candidates)
|
|
1473
|
+
es.push([stepKey++, new Type(errorAst, input)])
|
|
1473
1474
|
}
|
|
1474
1475
|
}
|
|
1475
1476
|
if (searchTree.otherwise.length > 0) {
|
|
@@ -1608,16 +1609,19 @@ export const getLiterals = (
|
|
|
1608
1609
|
}
|
|
1609
1610
|
|
|
1610
1611
|
/**
|
|
1611
|
-
* The purpose of the algorithm is to narrow down the pool of possible
|
|
1612
|
+
* The purpose of the algorithm is to narrow down the pool of possible
|
|
1613
|
+
* candidates for decoding as much as possible.
|
|
1612
1614
|
*
|
|
1613
1615
|
* This function separates the schemas into two groups, `keys` and `otherwise`:
|
|
1614
1616
|
*
|
|
1615
1617
|
* - `keys`: the schema has at least one property with a literal value
|
|
1616
1618
|
* - `otherwise`: the schema has no properties with a literal value
|
|
1617
1619
|
*
|
|
1618
|
-
* If a schema has at least one property with a literal value, so it ends up in
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1620
|
+
* If a schema has at least one property with a literal value, so it ends up in
|
|
1621
|
+
* `keys`, first a namespace is created for the name of the property containing
|
|
1622
|
+
* the literal, and then within this namespace a "bucket" is created for the
|
|
1623
|
+
* literal value in which to store all the schemas that have the same property
|
|
1624
|
+
* and literal value.
|
|
1621
1625
|
*
|
|
1622
1626
|
* @internal
|
|
1623
1627
|
*/
|
|
@@ -1629,25 +1633,30 @@ export const getSearchTree = (
|
|
|
1629
1633
|
readonly [key: PropertyKey]: {
|
|
1630
1634
|
buckets: { [literal: string]: ReadonlyArray<AST.AST> }
|
|
1631
1635
|
literals: ReadonlyArray<AST.Literal> // this is for error messages
|
|
1636
|
+
candidates: ReadonlyArray<AST.AST>
|
|
1632
1637
|
}
|
|
1633
1638
|
}
|
|
1634
1639
|
otherwise: ReadonlyArray<AST.AST>
|
|
1640
|
+
candidates: ReadonlyArray<AST.AST>
|
|
1635
1641
|
} => {
|
|
1636
1642
|
const keys: {
|
|
1637
1643
|
[key: PropertyKey]: {
|
|
1638
1644
|
buckets: { [literal: string]: Array<AST.AST> }
|
|
1639
1645
|
literals: Array<AST.Literal>
|
|
1646
|
+
candidates: Array<AST.AST>
|
|
1640
1647
|
}
|
|
1641
1648
|
} = {}
|
|
1642
1649
|
const otherwise: Array<AST.AST> = []
|
|
1650
|
+
const candidates: Array<AST.AST> = []
|
|
1643
1651
|
for (let i = 0; i < members.length; i++) {
|
|
1644
1652
|
const member = members[i]
|
|
1645
1653
|
const tags = getLiterals(member, isDecoding)
|
|
1646
1654
|
if (tags.length > 0) {
|
|
1655
|
+
candidates.push(member)
|
|
1647
1656
|
for (let j = 0; j < tags.length; j++) {
|
|
1648
1657
|
const [key, literal] = tags[j]
|
|
1649
1658
|
const hash = String(literal.literal)
|
|
1650
|
-
keys[key] = keys[key] || { buckets: {}, literals: [] }
|
|
1659
|
+
keys[key] = keys[key] || { buckets: {}, literals: [], candidates: [] }
|
|
1651
1660
|
const buckets = keys[key].buckets
|
|
1652
1661
|
if (Object.prototype.hasOwnProperty.call(buckets, hash)) {
|
|
1653
1662
|
if (j < tags.length - 1) {
|
|
@@ -1655,9 +1664,11 @@ export const getSearchTree = (
|
|
|
1655
1664
|
}
|
|
1656
1665
|
buckets[hash].push(member)
|
|
1657
1666
|
keys[key].literals.push(literal)
|
|
1667
|
+
keys[key].candidates.push(member)
|
|
1658
1668
|
} else {
|
|
1659
1669
|
buckets[hash] = [member]
|
|
1660
1670
|
keys[key].literals.push(literal)
|
|
1671
|
+
keys[key].candidates.push(member)
|
|
1661
1672
|
break
|
|
1662
1673
|
}
|
|
1663
1674
|
}
|
|
@@ -1665,7 +1676,7 @@ export const getSearchTree = (
|
|
|
1665
1676
|
otherwise.push(member)
|
|
1666
1677
|
}
|
|
1667
1678
|
}
|
|
1668
|
-
return { keys, otherwise }
|
|
1679
|
+
return { keys, otherwise, candidates }
|
|
1669
1680
|
}
|
|
1670
1681
|
|
|
1671
1682
|
const dropRightRefinement = (ast: AST.AST): AST.AST => AST.isRefinement(ast) ? dropRightRefinement(ast.from) : ast
|
|
@@ -1983,12 +1994,25 @@ const formatTree = (
|
|
|
1983
1994
|
}
|
|
1984
1995
|
|
|
1985
1996
|
/**
|
|
1997
|
+
* Represents an issue returned by the {@link ArrayFormatter} formatter.
|
|
1998
|
+
*
|
|
1986
1999
|
* @category model
|
|
1987
2000
|
* @since 3.10.0
|
|
1988
2001
|
*/
|
|
1989
2002
|
export interface ArrayFormatterIssue {
|
|
2003
|
+
/**
|
|
2004
|
+
* The tag identifying the type of parse issue.
|
|
2005
|
+
*/
|
|
1990
2006
|
readonly _tag: ParseIssue["_tag"]
|
|
2007
|
+
|
|
2008
|
+
/**
|
|
2009
|
+
* The path to the property where the issue occurred.
|
|
2010
|
+
*/
|
|
1991
2011
|
readonly path: ReadonlyArray<PropertyKey>
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* A descriptive message explaining the issue.
|
|
2015
|
+
*/
|
|
1992
2016
|
readonly message: string
|
|
1993
2017
|
}
|
|
1994
2018
|
|