@typed/guard 1.0.0-beta.0 → 1.0.0-beta.2
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/README.md +10 -6
- package/dist/index.js +1 -1
- package/package.json +10 -6
- package/src/index.ts +2 -2
- package/tsconfig.json +0 -5
package/README.md
CHANGED
|
@@ -85,12 +85,16 @@ const Positive = Schema.Number.pipe(Schema.positive());
|
|
|
85
85
|
const guardDecode = Guard.fromSchemaDecode(Positive);
|
|
86
86
|
|
|
87
87
|
// Inside Effect.gen(function* () { ... })
|
|
88
|
-
const result =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
88
|
+
const result =
|
|
89
|
+
yield *
|
|
90
|
+
guardDecode(42).pipe(
|
|
91
|
+
Effect.map(
|
|
92
|
+
Option.match({
|
|
93
|
+
onNone: () => "invalid",
|
|
94
|
+
onSome: (n) => `ok: ${n}`,
|
|
95
|
+
}),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
94
98
|
// result === "ok: 42"
|
|
95
99
|
|
|
96
100
|
const even = Guard.liftPredicate((n: number) => n % 2 === 0);
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export const tap = dual(2, function tap(guard, f) {
|
|
|
49
49
|
*/
|
|
50
50
|
export const filterMap = dual(2, (guard, f) => {
|
|
51
51
|
const g = getGuard(guard);
|
|
52
|
-
return (i) => Effect.mapEager(g(i), Option.
|
|
52
|
+
return (i) => Effect.mapEager(g(i), Option.flatMap(f));
|
|
53
53
|
});
|
|
54
54
|
/**
|
|
55
55
|
* @since 1.0.0
|
package/package.json
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed/guard",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
6
|
-
},
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
7
4
|
"type": "module",
|
|
8
5
|
"exports": {
|
|
9
6
|
".": {
|
|
@@ -15,15 +12,22 @@
|
|
|
15
12
|
"import": "./dist/*.js"
|
|
16
13
|
}
|
|
17
14
|
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"effect": "4.0.0-beta.
|
|
19
|
+
"effect": "4.0.0-beta.21"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"typescript": "5.9.3",
|
|
23
23
|
"vitest": "4.0.18"
|
|
24
24
|
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"src"
|
|
28
|
+
],
|
|
25
29
|
"scripts": {
|
|
26
|
-
"build": "tsc",
|
|
30
|
+
"build": "[ -d dist ] || rm -f tsconfig.tsbuildinfo; tsc",
|
|
27
31
|
"test": "vitest run --passWithNoTests"
|
|
28
32
|
}
|
|
29
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -202,7 +202,7 @@ export const filterMap: {
|
|
|
202
202
|
f: (o: O) => Option.Option<B>,
|
|
203
203
|
): Guard<I, B, E, R> => {
|
|
204
204
|
const g = getGuard(guard);
|
|
205
|
-
return (i) => Effect.mapEager(g(i), Option.
|
|
205
|
+
return (i) => Effect.mapEager(g(i), Option.flatMap(f));
|
|
206
206
|
},
|
|
207
207
|
);
|
|
208
208
|
|
|
@@ -368,7 +368,7 @@ export const catchTag: {
|
|
|
368
368
|
R | R2
|
|
369
369
|
> {
|
|
370
370
|
const g = getGuard(guard);
|
|
371
|
-
return (i: I) => Effect.catchTag(g(i), tag as any, (e) => Effect.asSome(f(e)));
|
|
371
|
+
return (i: I) => Effect.catchTag(g(i), tag as any, (e) => Effect.asSome(f(e as any)));
|
|
372
372
|
});
|
|
373
373
|
|
|
374
374
|
/**
|