mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-04 03:35:36 +08:00
20 lines
557 B
TypeScript
20 lines
557 B
TypeScript
import * as Duration from "effect/Duration"
|
|
import * as Effect from "effect/Effect"
|
|
import * as Schema from "effect/Schema"
|
|
import * as SchemaTransformation from "effect/SchemaTransformation"
|
|
|
|
const schema = Schema.String.pipe(Schema.decodeTo(
|
|
Schema.String,
|
|
SchemaTransformation.transformEffect({
|
|
decode: Effect.fnUntraced(function*(s) {
|
|
yield* Effect.clockWith((clock) => clock.sleep(Duration.millis(300)))
|
|
return s
|
|
}),
|
|
encode: (_) => Effect.succeed(_)
|
|
})
|
|
))
|
|
|
|
Schema.decodeUnknownEffect(schema)("a").pipe(
|
|
Effect.runFork
|
|
)
|