effect 3.13.10 → 3.13.12
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 +38 -22
- package/dist/cjs/Arbitrary.js.map +1 -1
- package/dist/cjs/Array.js +50 -50
- package/dist/cjs/Array.js.map +1 -1
- package/dist/cjs/Brand.js +9 -4
- package/dist/cjs/Brand.js.map +1 -1
- package/dist/cjs/Cause.js +1 -0
- package/dist/cjs/Cause.js.map +1 -1
- package/dist/cjs/Chunk.js +25 -23
- package/dist/cjs/Chunk.js.map +1 -1
- package/dist/cjs/Config.js +2 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +4 -4
- package/dist/cjs/Effect.js +823 -632
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Either.js +12 -12
- package/dist/cjs/Either.js.map +1 -1
- package/dist/cjs/JSONSchema.js +6 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/LogLevel.js +1 -1
- package/dist/cjs/Logger.js +12 -12
- package/dist/cjs/Match.js +26 -26
- package/dist/cjs/Option.js +43 -43
- package/dist/cjs/Predicate.js +6 -2
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Schema.js +21 -18
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/SchemaAST.js +85 -57
- package/dist/cjs/SchemaAST.js.map +1 -1
- package/dist/cjs/Scope.js +2 -0
- package/dist/cjs/Scope.js.map +1 -1
- package/dist/cjs/Stream.js +93 -93
- package/dist/cjs/internal/core.js +1 -1
- package/dist/cjs/internal/core.js.map +1 -1
- package/dist/cjs/internal/schema/errors.js +1 -4
- package/dist/cjs/internal/schema/errors.js.map +1 -1
- package/dist/cjs/internal/schema/util.js +23 -14
- package/dist/cjs/internal/schema/util.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Array.d.ts +47 -47
- package/dist/dts/Array.d.ts.map +1 -1
- package/dist/dts/Brand.d.ts +14 -6
- package/dist/dts/Brand.d.ts.map +1 -1
- package/dist/dts/Cause.d.ts +1 -0
- package/dist/dts/Cause.d.ts.map +1 -1
- package/dist/dts/Chunk.d.ts +91 -89
- package/dist/dts/Chunk.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +2 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +4 -4
- package/dist/dts/Effect.d.ts +2107 -1621
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Either.d.ts +33 -33
- package/dist/dts/LogLevel.d.ts +3 -3
- package/dist/dts/Logger.d.ts +16 -16
- package/dist/dts/Match.d.ts +26 -26
- package/dist/dts/Option.d.ts +84 -84
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +53 -21
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/SchemaAST.d.ts +1 -1
- package/dist/dts/SchemaAST.d.ts.map +1 -1
- package/dist/dts/Scope.d.ts +2 -0
- package/dist/dts/Scope.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +229 -229
- package/dist/esm/Arbitrary.js +38 -22
- package/dist/esm/Arbitrary.js.map +1 -1
- package/dist/esm/Array.js +50 -50
- package/dist/esm/Array.js.map +1 -1
- package/dist/esm/Brand.js +9 -4
- package/dist/esm/Brand.js.map +1 -1
- package/dist/esm/Cause.js +1 -0
- package/dist/esm/Cause.js.map +1 -1
- package/dist/esm/Chunk.js +25 -23
- package/dist/esm/Chunk.js.map +1 -1
- package/dist/esm/Config.js +2 -1
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +4 -4
- package/dist/esm/Effect.js +845 -648
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Either.js +17 -17
- package/dist/esm/Either.js.map +1 -1
- package/dist/esm/JSONSchema.js +6 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/LogLevel.js +1 -1
- package/dist/esm/Logger.js +12 -12
- package/dist/esm/Match.js +26 -26
- package/dist/esm/Option.js +48 -48
- package/dist/esm/Predicate.js +3 -0
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Schema.js +21 -18
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/SchemaAST.js +77 -49
- package/dist/esm/SchemaAST.js.map +1 -1
- package/dist/esm/Scope.js +2 -0
- package/dist/esm/Scope.js.map +1 -1
- package/dist/esm/Stream.js +101 -101
- package/dist/esm/internal/core.js +1 -1
- package/dist/esm/internal/core.js.map +1 -1
- package/dist/esm/internal/schema/errors.js +0 -2
- package/dist/esm/internal/schema/errors.js.map +1 -1
- package/dist/esm/internal/schema/util.js +23 -14
- package/dist/esm/internal/schema/util.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Arbitrary.ts +39 -24
- package/src/Array.ts +116 -113
- package/src/Brand.ts +14 -6
- package/src/Cause.ts +1 -0
- package/src/Chunk.ts +97 -95
- package/src/Config.ts +2 -1
- package/src/Context.ts +4 -4
- package/src/Effect.ts +2107 -1621
- package/src/Either.ts +34 -34
- package/src/JSONSchema.ts +6 -2
- package/src/LogLevel.ts +3 -3
- package/src/Logger.ts +16 -16
- package/src/Match.ts +26 -26
- package/src/Option.ts +84 -84
- package/src/Predicate.ts +4 -0
- package/src/Schema.ts +87 -42
- package/src/SchemaAST.ts +92 -52
- package/src/Scope.ts +2 -0
- package/src/Stream.ts +229 -229
- package/src/internal/core.ts +2 -1
- package/src/internal/schema/errors.ts +0 -6
- package/src/internal/schema/util.ts +34 -25
- package/src/internal/version.ts +1 -1
package/src/Either.ts
CHANGED
|
@@ -190,7 +190,7 @@ export const fromNullable: {
|
|
|
190
190
|
} = dual(
|
|
191
191
|
2,
|
|
192
192
|
<R, L>(self: R, onNullable: (right: R) => L): Either<NonNullable<R>, L> =>
|
|
193
|
-
self == null ? left(onNullable(self)) : right(self
|
|
193
|
+
self == null ? left(onNullable(self)) : right(self)
|
|
194
194
|
)
|
|
195
195
|
|
|
196
196
|
/**
|
|
@@ -1338,10 +1338,6 @@ export const gen: Gen.Gen<EitherTypeLambda, Gen.Adapter<EitherTypeLambda>> = (..
|
|
|
1338
1338
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1339
1339
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1340
1340
|
*
|
|
1341
|
-
* @see {@link bind}
|
|
1342
|
-
* @see {@link bindTo}
|
|
1343
|
-
* @see {@link let_ let}
|
|
1344
|
-
*
|
|
1345
1341
|
* @example
|
|
1346
1342
|
* ```ts
|
|
1347
1343
|
* import * as assert from "node:assert"
|
|
@@ -1356,6 +1352,10 @@ export const gen: Gen.Gen<EitherTypeLambda, Gen.Adapter<EitherTypeLambda>> = (..
|
|
|
1356
1352
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1357
1353
|
* ```
|
|
1358
1354
|
*
|
|
1355
|
+
* @see {@link bind}
|
|
1356
|
+
* @see {@link bindTo}
|
|
1357
|
+
* @see {@link let_ let}
|
|
1358
|
+
*
|
|
1359
1359
|
* @category do notation
|
|
1360
1360
|
* @since 2.0.0
|
|
1361
1361
|
*/
|
|
@@ -1371,10 +1371,6 @@ export const Do: Either<{}> = right({})
|
|
|
1371
1371
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1372
1372
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1373
1373
|
*
|
|
1374
|
-
* @see {@link Do}
|
|
1375
|
-
* @see {@link bindTo}
|
|
1376
|
-
* @see {@link let_ let}
|
|
1377
|
-
*
|
|
1378
1374
|
* @example
|
|
1379
1375
|
* ```ts
|
|
1380
1376
|
* import * as assert from "node:assert"
|
|
@@ -1389,6 +1385,10 @@ export const Do: Either<{}> = right({})
|
|
|
1389
1385
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1390
1386
|
* ```
|
|
1391
1387
|
*
|
|
1388
|
+
* @see {@link Do}
|
|
1389
|
+
* @see {@link bindTo}
|
|
1390
|
+
* @see {@link let_ let}
|
|
1391
|
+
*
|
|
1392
1392
|
* @category do notation
|
|
1393
1393
|
* @since 2.0.0
|
|
1394
1394
|
*/
|
|
@@ -1403,10 +1403,6 @@ export const bind: {
|
|
|
1403
1403
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1404
1404
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1405
1405
|
*
|
|
1406
|
-
* @see {@link Do}
|
|
1407
|
-
* @see {@link bindTo}
|
|
1408
|
-
* @see {@link let_ let}
|
|
1409
|
-
*
|
|
1410
1406
|
* @example
|
|
1411
1407
|
* ```ts
|
|
1412
1408
|
* import * as assert from "node:assert"
|
|
@@ -1421,6 +1417,10 @@ export const bind: {
|
|
|
1421
1417
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1422
1418
|
* ```
|
|
1423
1419
|
*
|
|
1420
|
+
* @see {@link Do}
|
|
1421
|
+
* @see {@link bindTo}
|
|
1422
|
+
* @see {@link let_ let}
|
|
1423
|
+
*
|
|
1424
1424
|
* @category do notation
|
|
1425
1425
|
* @since 2.0.0
|
|
1426
1426
|
*/
|
|
@@ -1435,10 +1435,6 @@ export const bind: {
|
|
|
1435
1435
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1436
1436
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1437
1437
|
*
|
|
1438
|
-
* @see {@link Do}
|
|
1439
|
-
* @see {@link bindTo}
|
|
1440
|
-
* @see {@link let_ let}
|
|
1441
|
-
*
|
|
1442
1438
|
* @example
|
|
1443
1439
|
* ```ts
|
|
1444
1440
|
* import * as assert from "node:assert"
|
|
@@ -1453,6 +1449,10 @@ export const bind: {
|
|
|
1453
1449
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1454
1450
|
* ```
|
|
1455
1451
|
*
|
|
1452
|
+
* @see {@link Do}
|
|
1453
|
+
* @see {@link bindTo}
|
|
1454
|
+
* @see {@link let_ let}
|
|
1455
|
+
*
|
|
1456
1456
|
* @category do notation
|
|
1457
1457
|
* @since 2.0.0
|
|
1458
1458
|
*/
|
|
@@ -1473,10 +1473,6 @@ export const bind: {
|
|
|
1473
1473
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1474
1474
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1475
1475
|
*
|
|
1476
|
-
* @see {@link Do}
|
|
1477
|
-
* @see {@link bind}
|
|
1478
|
-
* @see {@link let_ let}
|
|
1479
|
-
*
|
|
1480
1476
|
* @example
|
|
1481
1477
|
* ```ts
|
|
1482
1478
|
* import * as assert from "node:assert"
|
|
@@ -1491,6 +1487,10 @@ export const bind: {
|
|
|
1491
1487
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1492
1488
|
* ```
|
|
1493
1489
|
*
|
|
1490
|
+
* @see {@link Do}
|
|
1491
|
+
* @see {@link bind}
|
|
1492
|
+
* @see {@link let_ let}
|
|
1493
|
+
*
|
|
1494
1494
|
* @category do notation
|
|
1495
1495
|
* @since 2.0.0
|
|
1496
1496
|
*/
|
|
@@ -1505,10 +1505,6 @@ export const bindTo: {
|
|
|
1505
1505
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1506
1506
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1507
1507
|
*
|
|
1508
|
-
* @see {@link Do}
|
|
1509
|
-
* @see {@link bind}
|
|
1510
|
-
* @see {@link let_ let}
|
|
1511
|
-
*
|
|
1512
1508
|
* @example
|
|
1513
1509
|
* ```ts
|
|
1514
1510
|
* import * as assert from "node:assert"
|
|
@@ -1523,6 +1519,10 @@ export const bindTo: {
|
|
|
1523
1519
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1524
1520
|
* ```
|
|
1525
1521
|
*
|
|
1522
|
+
* @see {@link Do}
|
|
1523
|
+
* @see {@link bind}
|
|
1524
|
+
* @see {@link let_ let}
|
|
1525
|
+
*
|
|
1526
1526
|
* @category do notation
|
|
1527
1527
|
* @since 2.0.0
|
|
1528
1528
|
*/
|
|
@@ -1537,10 +1537,6 @@ export const bindTo: {
|
|
|
1537
1537
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1538
1538
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1539
1539
|
*
|
|
1540
|
-
* @see {@link Do}
|
|
1541
|
-
* @see {@link bind}
|
|
1542
|
-
* @see {@link let_ let}
|
|
1543
|
-
*
|
|
1544
1540
|
* @example
|
|
1545
1541
|
* ```ts
|
|
1546
1542
|
* import * as assert from "node:assert"
|
|
@@ -1555,6 +1551,10 @@ export const bindTo: {
|
|
|
1555
1551
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1556
1552
|
* ```
|
|
1557
1553
|
*
|
|
1554
|
+
* @see {@link Do}
|
|
1555
|
+
* @see {@link bind}
|
|
1556
|
+
* @see {@link let_ let}
|
|
1557
|
+
*
|
|
1558
1558
|
* @category do notation
|
|
1559
1559
|
* @since 2.0.0
|
|
1560
1560
|
*/
|
|
@@ -1584,10 +1584,6 @@ export {
|
|
|
1584
1584
|
* 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
|
|
1585
1585
|
* 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
|
|
1586
1586
|
*
|
|
1587
|
-
* @see {@link Do}
|
|
1588
|
-
* @see {@link bindTo}
|
|
1589
|
-
* @see {@link bind}
|
|
1590
|
-
*
|
|
1591
1587
|
* @example
|
|
1592
1588
|
* ```ts
|
|
1593
1589
|
* import * as assert from "node:assert"
|
|
@@ -1600,8 +1596,12 @@ export {
|
|
|
1600
1596
|
* Either.let("sum", ({ x, y }) => x + y)
|
|
1601
1597
|
* )
|
|
1602
1598
|
* assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
|
|
1603
|
-
*
|
|
1604
1599
|
* ```
|
|
1600
|
+
*
|
|
1601
|
+
* @see {@link Do}
|
|
1602
|
+
* @see {@link bindTo}
|
|
1603
|
+
* @see {@link bind}
|
|
1604
|
+
*
|
|
1605
1605
|
* @category do notation
|
|
1606
1606
|
* @since 2.0.0
|
|
1607
1607
|
*/
|
package/src/JSONSchema.ts
CHANGED
|
@@ -703,8 +703,12 @@ const go = (
|
|
|
703
703
|
propertyNames = go(parameter, $defs, true, path, options)
|
|
704
704
|
break
|
|
705
705
|
}
|
|
706
|
-
case "SymbolKeyword":
|
|
707
|
-
|
|
706
|
+
case "SymbolKeyword": {
|
|
707
|
+
const indexSignaturePath = path.concat("[symbol]")
|
|
708
|
+
output.additionalProperties = go(is.type, $defs, true, indexSignaturePath, options)
|
|
709
|
+
propertyNames = go(parameter, $defs, true, indexSignaturePath, options)
|
|
710
|
+
break
|
|
711
|
+
}
|
|
708
712
|
}
|
|
709
713
|
}
|
|
710
714
|
// ---------------------------------------------
|
package/src/LogLevel.ts
CHANGED
|
@@ -196,7 +196,7 @@ export const allLevels = core.allLogLevels
|
|
|
196
196
|
* }).pipe(LogLevel.locally(LogLevel.Warning))
|
|
197
197
|
* })
|
|
198
198
|
*
|
|
199
|
-
*
|
|
199
|
+
* Effect.runFork(program)
|
|
200
200
|
* // timestamp=... level=INFO fiber=#0 message=message1
|
|
201
201
|
* // timestamp=... level=WARN fiber=#0 message=message2
|
|
202
202
|
* // timestamp=... level=WARN fiber=#0 message=message3
|
|
@@ -232,7 +232,7 @@ export const locally: {
|
|
|
232
232
|
* }).pipe(LogLevel.locally(LogLevel.Warning))
|
|
233
233
|
* })
|
|
234
234
|
*
|
|
235
|
-
*
|
|
235
|
+
* Effect.runFork(program)
|
|
236
236
|
* // timestamp=... level=INFO fiber=#0 message=message1
|
|
237
237
|
* // timestamp=... level=WARN fiber=#0 message=message2
|
|
238
238
|
* // timestamp=... level=WARN fiber=#0 message=message3
|
|
@@ -268,7 +268,7 @@ export const locally: {
|
|
|
268
268
|
* }).pipe(LogLevel.locally(LogLevel.Warning))
|
|
269
269
|
* })
|
|
270
270
|
*
|
|
271
|
-
*
|
|
271
|
+
* Effect.runFork(program)
|
|
272
272
|
* // timestamp=... level=INFO fiber=#0 message=message1
|
|
273
273
|
* // timestamp=... level=WARN fiber=#0 message=message2
|
|
274
274
|
* // timestamp=... level=WARN fiber=#0 message=message3
|
package/src/Logger.ts
CHANGED
|
@@ -97,7 +97,7 @@ export declare namespace Logger {
|
|
|
97
97
|
* Effect.provide(Logger.replace(Logger.defaultLogger, logger))
|
|
98
98
|
* )
|
|
99
99
|
*
|
|
100
|
-
*
|
|
100
|
+
* Effect.runFork(program)
|
|
101
101
|
* // [INFO] start
|
|
102
102
|
* // [DEBUG] task1 done
|
|
103
103
|
* // [DEBUG] task2 done
|
|
@@ -232,7 +232,7 @@ export const map: {
|
|
|
232
232
|
* yield* Effect.log("three")
|
|
233
233
|
* }).pipe(Effect.provide(LoggerLive))
|
|
234
234
|
*
|
|
235
|
-
*
|
|
235
|
+
* Effect.runFork(program)
|
|
236
236
|
* // BATCH [
|
|
237
237
|
* // timestamp=... level=INFO fiber=#0 message=one
|
|
238
238
|
* // timestamp=... level=INFO fiber=#0 message=two
|
|
@@ -265,7 +265,7 @@ export const batched: {
|
|
|
265
265
|
* yield* Effect.log("three")
|
|
266
266
|
* }).pipe(Effect.provide(LoggerLive))
|
|
267
267
|
*
|
|
268
|
-
*
|
|
268
|
+
* Effect.runFork(program)
|
|
269
269
|
* // BATCH [
|
|
270
270
|
* // timestamp=... level=INFO fiber=#0 message=one
|
|
271
271
|
* // timestamp=... level=INFO fiber=#0 message=two
|
|
@@ -301,7 +301,7 @@ export const batched: {
|
|
|
301
301
|
* yield* Effect.log("three")
|
|
302
302
|
* }).pipe(Effect.provide(LoggerLive))
|
|
303
303
|
*
|
|
304
|
-
*
|
|
304
|
+
* Effect.runFork(program)
|
|
305
305
|
* // BATCH [
|
|
306
306
|
* // timestamp=... level=INFO fiber=#0 message=one
|
|
307
307
|
* // timestamp=... level=INFO fiber=#0 message=two
|
|
@@ -465,7 +465,7 @@ export const test: {
|
|
|
465
465
|
*
|
|
466
466
|
* const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
|
|
467
467
|
*
|
|
468
|
-
*
|
|
468
|
+
* Effect.runFork(program)
|
|
469
469
|
* // timestamp=... level=DEBUG fiber=#0 message=message1
|
|
470
470
|
* ```
|
|
471
471
|
*
|
|
@@ -483,7 +483,7 @@ export const withMinimumLogLevel: {
|
|
|
483
483
|
*
|
|
484
484
|
* const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
|
|
485
485
|
*
|
|
486
|
-
*
|
|
486
|
+
* Effect.runFork(program)
|
|
487
487
|
* // timestamp=... level=DEBUG fiber=#0 message=message1
|
|
488
488
|
* ```
|
|
489
489
|
*
|
|
@@ -501,7 +501,7 @@ export const withMinimumLogLevel: {
|
|
|
501
501
|
*
|
|
502
502
|
* const program = Effect.logDebug("message1").pipe(Logger.withMinimumLogLevel(LogLevel.Debug))
|
|
503
503
|
*
|
|
504
|
-
*
|
|
504
|
+
* Effect.runFork(program)
|
|
505
505
|
* // timestamp=... level=DEBUG fiber=#0 message=message1
|
|
506
506
|
* ```
|
|
507
507
|
*
|
|
@@ -597,7 +597,7 @@ export const defaultLogger: Logger<unknown, void> = fiberRuntime.defaultLogger
|
|
|
597
597
|
* Effect.withLogSpan("myspan")
|
|
598
598
|
* )
|
|
599
599
|
*
|
|
600
|
-
*
|
|
600
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.json)))
|
|
601
601
|
* // {"message":["message1","message2"],"logLevel":"INFO","timestamp":"...","annotations":{"key2":"value2","key1":"value1"},"spans":{"myspan":0},"fiberId":"#0"}
|
|
602
602
|
* ```
|
|
603
603
|
*
|
|
@@ -619,7 +619,7 @@ export const jsonLogger: Logger<unknown, string> = internal.jsonLogger
|
|
|
619
619
|
* Effect.withLogSpan("myspan")
|
|
620
620
|
* )
|
|
621
621
|
*
|
|
622
|
-
*
|
|
622
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.logFmt)))
|
|
623
623
|
* // timestamp=... level=INFO fiber=#0 message=message1 message=message2 myspan=0ms key2=value2 key1=value1
|
|
624
624
|
* ```
|
|
625
625
|
*
|
|
@@ -649,7 +649,7 @@ export const stringLogger: Logger<unknown, string> = internal.stringLogger
|
|
|
649
649
|
* Effect.withLogSpan("myspan")
|
|
650
650
|
* )
|
|
651
651
|
*
|
|
652
|
-
*
|
|
652
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.pretty)))
|
|
653
653
|
* // green --v v-- bold and cyan
|
|
654
654
|
* // [07:51:54.434] INFO (#0) myspan=1ms: message1
|
|
655
655
|
* // message2
|
|
@@ -692,7 +692,7 @@ export const prettyLoggerDefault: Logger<unknown, void> = internal.prettyLoggerD
|
|
|
692
692
|
* Effect.withLogSpan("myspan")
|
|
693
693
|
* )
|
|
694
694
|
*
|
|
695
|
-
*
|
|
695
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.structured)))
|
|
696
696
|
* // {
|
|
697
697
|
* // message: [ 'message1', 'message2' ],
|
|
698
698
|
* // logLevel: 'INFO',
|
|
@@ -739,7 +739,7 @@ export const tracerLogger: Logger<unknown, void> = fiberRuntime.tracerLogger
|
|
|
739
739
|
* Effect.withLogSpan("myspan")
|
|
740
740
|
* )
|
|
741
741
|
*
|
|
742
|
-
*
|
|
742
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.json)))
|
|
743
743
|
* // {"message":["message1","message2"],"logLevel":"INFO","timestamp":"...","annotations":{"key2":"value2","key1":"value1"},"spans":{"myspan":0},"fiberId":"#0"}
|
|
744
744
|
* ```
|
|
745
745
|
*
|
|
@@ -761,7 +761,7 @@ export const json: Layer.Layer<never> = replace(fiberRuntime.defaultLogger, fibe
|
|
|
761
761
|
* Effect.withLogSpan("myspan")
|
|
762
762
|
* )
|
|
763
763
|
*
|
|
764
|
-
*
|
|
764
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.logFmt)))
|
|
765
765
|
* // timestamp=... level=INFO fiber=#0 message=message1 message=message2 myspan=0ms key2=value2 key1=value1
|
|
766
766
|
* ```
|
|
767
767
|
*
|
|
@@ -785,7 +785,7 @@ export const logFmt: Layer.Layer<never> = replace(fiberRuntime.defaultLogger, fi
|
|
|
785
785
|
* Effect.withLogSpan("myspan")
|
|
786
786
|
* )
|
|
787
787
|
*
|
|
788
|
-
*
|
|
788
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.pretty)))
|
|
789
789
|
* // green --v v-- bold and cyan
|
|
790
790
|
* // [07:51:54.434] INFO (#0) myspan=1ms: message1
|
|
791
791
|
* // message2
|
|
@@ -813,7 +813,7 @@ export const pretty: Layer.Layer<never> = replace(fiberRuntime.defaultLogger, fi
|
|
|
813
813
|
* Effect.withLogSpan("myspan")
|
|
814
814
|
* )
|
|
815
815
|
*
|
|
816
|
-
*
|
|
816
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.structured)))
|
|
817
817
|
* // {
|
|
818
818
|
* // message: [ 'message1', 'message2' ],
|
|
819
819
|
* // logLevel: 'INFO',
|
|
@@ -845,7 +845,7 @@ export const structured: Layer.Layer<never> = replace(fiberRuntime.defaultLogger
|
|
|
845
845
|
* })
|
|
846
846
|
*
|
|
847
847
|
* // Logging disabled using a layer
|
|
848
|
-
*
|
|
848
|
+
* Effect.runFork(program.pipe(Effect.provide(Logger.minimumLogLevel(LogLevel.None))))
|
|
849
849
|
* // task done
|
|
850
850
|
* ```
|
|
851
851
|
*
|
package/src/Match.ts
CHANGED
|
@@ -160,11 +160,9 @@ export interface Not {
|
|
|
160
160
|
* created, you can use pattern-matching functions like {@link when} to define
|
|
161
161
|
* how different values should be processed.
|
|
162
162
|
*
|
|
163
|
-
*
|
|
163
|
+
* **Example** (Matching Numbers and Strings)
|
|
164
164
|
*
|
|
165
|
-
* @example
|
|
166
165
|
* ```ts
|
|
167
|
-
* // Title: Matching Numbers and Strings
|
|
168
166
|
* import { Match } from "effect"
|
|
169
167
|
*
|
|
170
168
|
* // Create a matcher for values that are either strings or numbers
|
|
@@ -187,6 +185,8 @@ export interface Not {
|
|
|
187
185
|
* // Output: "string: hello"
|
|
188
186
|
* ```
|
|
189
187
|
*
|
|
188
|
+
* @see {@link value} for creating a matcher from a specific value.
|
|
189
|
+
*
|
|
190
190
|
* @category Creating a matcher
|
|
191
191
|
* @since 1.0.0
|
|
192
192
|
*/
|
|
@@ -205,11 +205,9 @@ export const type: <I>() => Matcher<I, Types.Without<never>, I, never, never> =
|
|
|
205
205
|
* Once the matcher is created, you can use pattern-matching functions like
|
|
206
206
|
* {@link when} to define how different cases should be handled.
|
|
207
207
|
*
|
|
208
|
-
*
|
|
208
|
+
* **Example** (Matching an Object by Property)
|
|
209
209
|
*
|
|
210
|
-
* @example
|
|
211
210
|
* ```ts
|
|
212
|
-
* // Title: Matching an Object by Property
|
|
213
211
|
* import { Match } from "effect"
|
|
214
212
|
*
|
|
215
213
|
* const input = { name: "John", age: 30 }
|
|
@@ -229,6 +227,8 @@ export const type: <I>() => Matcher<I, Types.Without<never>, I, never, never> =
|
|
|
229
227
|
* // Output: "John is 30 years old"
|
|
230
228
|
* ```
|
|
231
229
|
*
|
|
230
|
+
* @see {@link type} for creating a matcher from a specific type.
|
|
231
|
+
*
|
|
232
232
|
* @category Creating a matcher
|
|
233
233
|
* @since 1.0.0
|
|
234
234
|
*/
|
|
@@ -277,9 +277,9 @@ export const typeTags: <I>() => <
|
|
|
277
277
|
* **Important:** This function must be the first step in the matcher pipeline.
|
|
278
278
|
* If used later, TypeScript will not enforce type consistency correctly.
|
|
279
279
|
*
|
|
280
|
-
*
|
|
280
|
+
* **Example** (Validating Return Type Consistency)
|
|
281
|
+
*
|
|
281
282
|
* ```ts
|
|
282
|
-
* // Title: Validating Return Type Consistency
|
|
283
283
|
* import { Match } from "effect"
|
|
284
284
|
*
|
|
285
285
|
* const match = Match.type<{ a: number } | { b: string }>().pipe(
|
|
@@ -315,14 +315,9 @@ export const withReturnType: <Ret>() => <I, F, R, A, Pr, _>(
|
|
|
315
315
|
* specific values or apply logical conditions to determine a match. It works
|
|
316
316
|
* well with structured objects and primitive types.
|
|
317
317
|
*
|
|
318
|
-
*
|
|
319
|
-
* condition.
|
|
320
|
-
* @see {@link whenAnd} Use this when a value must match all provided patterns.
|
|
321
|
-
* @see {@link orElse} Provides a fallback when no patterns match.
|
|
318
|
+
* **Example** (Matching with Values and Predicates)
|
|
322
319
|
*
|
|
323
|
-
* @example
|
|
324
320
|
* ```ts
|
|
325
|
-
* // Title: Matching with Values and Predicates
|
|
326
321
|
* import { Match } from "effect"
|
|
327
322
|
*
|
|
328
323
|
* // Create a matcher for objects with an "age" property
|
|
@@ -345,6 +340,11 @@ export const withReturnType: <Ret>() => <I, F, R, A, Pr, _>(
|
|
|
345
340
|
* // Output: "4 is too young"
|
|
346
341
|
* ```
|
|
347
342
|
*
|
|
343
|
+
* @see {@link whenOr} Use this when multiple patterns should match in a single
|
|
344
|
+
* condition.
|
|
345
|
+
* @see {@link whenAnd} Use this when a value must match all provided patterns.
|
|
346
|
+
* @see {@link orElse} Provides a fallback when no patterns match.
|
|
347
|
+
*
|
|
348
348
|
* @category Defining patterns
|
|
349
349
|
* @since 1.0.0
|
|
350
350
|
*/
|
|
@@ -684,9 +684,9 @@ export const discriminatorsExhaustive: <D extends string>(
|
|
|
684
684
|
* of naming the tag field as `"_tag"`. Ensure that your discriminated unions
|
|
685
685
|
* follow this naming convention for proper functionality.
|
|
686
686
|
*
|
|
687
|
-
*
|
|
687
|
+
* **Example** (Matching a Discriminated Union by Tag)
|
|
688
|
+
*
|
|
688
689
|
* ```ts
|
|
689
|
-
* // Title: Matching a Discriminated Union by Tag
|
|
690
690
|
* import { Match } from "effect"
|
|
691
691
|
*
|
|
692
692
|
* type Event =
|
|
@@ -883,9 +883,9 @@ export const tagsExhaustive: <
|
|
|
883
883
|
* Any excluded value will bypass the provided function and continue matching
|
|
884
884
|
* through other cases.
|
|
885
885
|
*
|
|
886
|
-
*
|
|
886
|
+
* **Example** (Ignoring a Specific Value)
|
|
887
|
+
*
|
|
887
888
|
* ```ts
|
|
888
|
-
* // Title: Ignoring a Specific Value
|
|
889
889
|
* import { Match } from "effect"
|
|
890
890
|
*
|
|
891
891
|
* // Create a matcher for string or number values
|
|
@@ -1065,9 +1065,9 @@ export const instanceOfUnsafe: <A extends abstract new(...args: any) => any>(
|
|
|
1065
1065
|
* `default` clause in a `switch` statement or the final `else` in an `if-else`
|
|
1066
1066
|
* chain.
|
|
1067
1067
|
*
|
|
1068
|
-
*
|
|
1068
|
+
* **Example** (Providing a Default Value When No Patterns Match)
|
|
1069
|
+
*
|
|
1069
1070
|
* ```ts
|
|
1070
|
-
* // Title: Providing a Default Value When No Patterns Match
|
|
1071
1071
|
* import { Match } from "effect"
|
|
1072
1072
|
*
|
|
1073
1073
|
* // Create a matcher for string or number values
|
|
@@ -1130,9 +1130,9 @@ export const orElseAbsurd: <I, R, RA, A, Pr, Ret>(
|
|
|
1130
1130
|
* unmatched case should be explicitly handled rather than returning a default
|
|
1131
1131
|
* value or throwing an error.
|
|
1132
1132
|
*
|
|
1133
|
-
*
|
|
1133
|
+
* **Example** (Extracting a User Role with `Match.either`)
|
|
1134
|
+
*
|
|
1134
1135
|
* ```ts
|
|
1135
|
-
* // Title: Extracting a User Role with Either
|
|
1136
1136
|
* import { Match } from "effect"
|
|
1137
1137
|
*
|
|
1138
1138
|
* type User = { readonly role: "admin" | "editor" | "viewer" }
|
|
@@ -1171,9 +1171,9 @@ export const either: <I, F, R, A, Pr, Ret>(
|
|
|
1171
1171
|
* handled explicitly rather than throwing an error or returning a default
|
|
1172
1172
|
* value.
|
|
1173
1173
|
*
|
|
1174
|
-
*
|
|
1174
|
+
* **Example** (Extracting a User Role with `Match.option`)
|
|
1175
|
+
*
|
|
1175
1176
|
* ```ts
|
|
1176
|
-
* // Title: Extracting a User Role with Option
|
|
1177
1177
|
* import { Match } from "effect"
|
|
1178
1178
|
*
|
|
1179
1179
|
* type User = { readonly role: "admin" | "editor" | "viewer" }
|
|
@@ -1205,9 +1205,9 @@ export const option: <I, F, R, A, Pr, Ret>(
|
|
|
1205
1205
|
* TypeScript will produce a type error. This is particularly useful when
|
|
1206
1206
|
* working with unions, as it helps prevent unintended gaps in pattern matching.
|
|
1207
1207
|
*
|
|
1208
|
-
*
|
|
1208
|
+
* **Example** (Ensuring All Cases Are Covered)
|
|
1209
|
+
*
|
|
1209
1210
|
* ```ts
|
|
1210
|
-
* // Title: Ensuring All Cases Are Covered
|
|
1211
1211
|
* import { Match } from "effect"
|
|
1212
1212
|
*
|
|
1213
1213
|
* // Create a matcher for string or number values
|