mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-01 03:05:36 +08:00
21 lines
616 B
TypeScript
21 lines
616 B
TypeScript
import * as Effect from "#dist/effect/Effect"
|
|
import * as Schema from "#dist/effect/schema/Schema"
|
|
import * as Transformation from "#dist/effect/schema/Transformation"
|
|
import * as Duration from "#dist/effect/time/Duration"
|
|
|
|
const schema = Schema.String.pipe(Schema.decodeTo(
|
|
Schema.String,
|
|
Transformation.transformOrFail({
|
|
decode: (s) =>
|
|
Effect.gen(function*() {
|
|
yield* Effect.clockWith((clock) => clock.sleep(Duration.millis(300)))
|
|
return s
|
|
}),
|
|
encode: (_) => Effect.succeed(_)
|
|
})
|
|
))
|
|
|
|
Schema.decodeUnknownEffect(schema)({ a: "a", b: 1, c: ["c"] }).pipe(
|
|
Effect.runFork
|
|
)
|