mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-02 03:15:52 +08:00
* add missing SchemaToParser APIs * chore * uniform bundles * fix benchmarks
22 lines
646 B
TypeScript
22 lines
646 B
TypeScript
import * as Duration from "#dist/effect/Duration"
|
|
import * as Effect from "#dist/effect/Effect"
|
|
import * as Result from "#dist/effect/Result"
|
|
import * as Schema from "#dist/effect/Schema"
|
|
import * as SchemaTransformation from "#dist/effect/SchemaTransformation"
|
|
|
|
const schema = Schema.String.pipe(Schema.decodeTo(
|
|
Schema.String,
|
|
SchemaTransformation.transformOrFail({
|
|
decode: (s) =>
|
|
Effect.gen(function*() {
|
|
yield* Effect.clockWith((clock) => clock.sleep(Duration.millis(300)))
|
|
return s
|
|
}),
|
|
encode: Result.ok
|
|
})
|
|
))
|
|
|
|
Schema.decodeUnknownEffect(schema)({ a: "a", b: 1, c: ["c"] }).pipe(
|
|
Effect.runFork
|
|
)
|