<
Arg extends
| Stream<Uint8Array, any, any>
| { readonly encoding?: string | undefined }
| undefined = { readonly encoding?: string | undefined }
>(
streamOrOptions?: Arg,
options?: { readonly encoding?: string | undefined } | undefined
): [Arg] extends [Stream<Uint8Array, infer _E, infer _R>]
? Stream<string, _E, _R>
: <E, R>(self: Stream<Uint8Array, E, R>) => Stream<string, E, R>Decodes Uint8Array chunks into strings using TextDecoder with an optional encoding.
Example (Decoding Uint8Array chunks into strings using TextDecoder with an optional encoding)
import { Console, Effect, Stream } from "effect"
const encoder = new TextEncoder()
const stream = Stream.make(
encoder.encode("Hello"),
encoder.encode(" World")
)
const program = Effect.gen(function*() {
const decoded = yield* stream.pipe(
Stream.decodeText,
Stream.runCollect
)
yield* Console.log(decoded)
})
Effect.runPromise(program)
// ["Hello", " World"]export const const decodeText: <
Arg extends
| Stream<Uint8Array, any, any>
| { readonly encoding?: string | undefined }
| undefined = {
readonly encoding?: string | undefined
}
>(
streamOrOptions?: Arg,
options?:
| { readonly encoding?: string | undefined }
| undefined
) => [Arg] extends [
Stream<Uint8Array, infer _E, infer _R>
]
? Stream<string, _E, _R>
: <E, R>(
self: Stream<Uint8Array, E, R>
) => Stream<string, E, R>
Decodes Uint8Array chunks into strings using TextDecoder with an optional encoding.
Example (Decoding Uint8Array chunks into strings using TextDecoder with an optional encoding)
import { Console, Effect, Stream } from "effect"
const encoder = new TextEncoder()
const stream = Stream.make(
encoder.encode("Hello"),
encoder.encode(" World")
)
const program = Effect.gen(function*() {
const decoded = yield* stream.pipe(
Stream.decodeText,
Stream.runCollect
)
yield* Console.log(decoded)
})
Effect.runPromise(program)
// ["Hello", " World"]
decodeText: <
function (type parameter) Arg in <Arg extends Stream<Uint8Array, any, any> | {
readonly encoding?: string | undefined;
} | undefined = {
readonly encoding?: string | undefined;
}>(streamOrOptions?: Arg, options?: {
readonly encoding?: string | undefined;
} | undefined): [Arg] extends [Stream<Uint8Array, infer _E, infer _R>] ? Stream<string, _E, _R> : <E, R>(self: Stream<Uint8Array, E, R>) => Stream<string, E, R>
Arg extends interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, any, any> | {
readonly encoding?: string | undefinedencoding?: string | undefined
} | undefined = {
readonly encoding?: string | undefinedencoding?: string | undefined
}
>(
streamOrOptions: Arg | undefinedstreamOrOptions?: function (type parameter) Arg in <Arg extends Stream<Uint8Array, any, any> | {
readonly encoding?: string | undefined;
} | undefined = {
readonly encoding?: string | undefined;
}>(streamOrOptions?: Arg, options?: {
readonly encoding?: string | undefined;
} | undefined): [Arg] extends [Stream<Uint8Array, infer _E, infer _R>] ? Stream<string, _E, _R> : <E, R>(self: Stream<Uint8Array, E, R>) => Stream<string, E, R>
Arg,
options: | {
readonly encoding?: string | undefined
}
| undefined
options?: {
readonly encoding?: string | undefinedencoding?: string | undefined
} | undefined
) => [function (type parameter) Arg in <Arg extends Stream<Uint8Array, any, any> | {
readonly encoding?: string | undefined;
} | undefined = {
readonly encoding?: string | undefined;
}>(streamOrOptions?: Arg, options?: {
readonly encoding?: string | undefined;
} | undefined): [Arg] extends [Stream<Uint8Array, infer _E, infer _R>] ? Stream<string, _E, _R> : <E, R>(self: Stream<Uint8Array, E, R>) => Stream<string, E, R>
Arg] extends [interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, infer function (type parameter) _E_E, infer function (type parameter) _R_R>] ? interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<string, function (type parameter) _E_E, function (type parameter) _R_R>
: <function (type parameter) E in <E, R>(self: Stream<Uint8Array, E, R>): Stream<string, E, R>E, function (type parameter) R in <E, R>(self: Stream<Uint8Array, E, R>): Stream<string, E, R>R>(self: Stream<Uint8Array, E, R>(parameter) self: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, function (type parameter) E in <E, R>(self: Stream<Uint8Array, E, R>): Stream<string, E, R>E, function (type parameter) R in <E, R>(self: Stream<Uint8Array, E, R>): Stream<string, E, R>R>) => interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<string, function (type parameter) E in <E, R>(self: Stream<Uint8Array, E, R>): Stream<string, E, R>E, function (type parameter) R in <E, R>(self: Stream<Uint8Array, E, R>): Stream<string, E, R>R> = import dualdual(
(args: anyargs) => const isStream: (
u: unknown
) => u is Stream<unknown, unknown, unknown>
Checks whether a value is a Stream.
Example (Checking whether a value is a Stream)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
const stream = Stream.make(1, 2, 3)
const notStream = { data: [1, 2, 3] }
yield* Console.log(Stream.isStream(stream))
// true
yield* Console.log(Stream.isStream(notStream))
// false
})
Effect.runPromise(program)
isStream(args: anyargs[0]),
<function (type parameter) E in <E, R>(self: Stream<Uint8Array, E, R>, options?: {
readonly encoding?: string | undefined;
}): Stream<string, E, R>
E, function (type parameter) R in <E, R>(self: Stream<Uint8Array, E, R>, options?: {
readonly encoding?: string | undefined;
}): Stream<string, E, R>
R>(self: Stream<Uint8Array, E, R>(parameter) self: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array, function (type parameter) E in <E, R>(self: Stream<Uint8Array, E, R>, options?: {
readonly encoding?: string | undefined;
}): Stream<string, E, R>
E, function (type parameter) R in <E, R>(self: Stream<Uint8Array, E, R>, options?: {
readonly encoding?: string | undefined;
}): Stream<string, E, R>
R>, options: | {
readonly encoding?: string | undefined
}
| undefined
options?: {
readonly encoding?: string | undefinedencoding?: string | undefined
}): interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<string, function (type parameter) E in <E, R>(self: Stream<Uint8Array, E, R>, options?: {
readonly encoding?: string | undefined;
}): Stream<string, E, R>
E, function (type parameter) R in <E, R>(self: Stream<Uint8Array, E, R>, options?: {
readonly encoding?: string | undefined;
}): Stream<string, E, R>
R> =>
const suspend: <A, E, R>(
stream: LazyArg<Stream<A, E, R>>
) => Stream<A, E, R>
Creates a lazily constructed stream.
Details
The stream factory is evaluated each time the stream is run.
Example (Creating a lazily constructed stream)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
const values = yield* Stream.suspend(() => Stream.make(1, 2, 3)).pipe(Stream.runCollect)
yield* Console.log(values)
})
Effect.runPromise(program)
// Output: [ 1, 2, 3 ]
suspend(() => {
const const decoder: TextDecoderdecoder = new var TextDecoder: new (
label?: string,
options?: TextDecoderOptions
) => TextDecoder
The TextDecoder interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, KOI8-R, GBK, etc.
TextDecoder(options: | {
readonly encoding?: string | undefined
}
| undefined
options?.encoding?: string | undefinedencoding)
return const map: {
<A, B>(f: (a: A, i: number) => B): <E, R>(
self: Stream<A, E, R>
) => Stream<B, E, R>
<A, E, R, B>(
self: Stream<A, E, R>,
f: (a: A, i: number) => B
): Stream<B, E, R>
}
map(self: Stream<Uint8Array, E, R>(parameter) self: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self, (chunk: Uint8Array<ArrayBufferLike>chunk) => const decoder: TextDecoderdecoder.TextDecoder.decode(input?: AllowSharedBufferSource, options?: TextDecodeOptions): stringThe TextDecoder.decode() method returns a string containing text decoded from the buffer passed as a parameter.
decode(chunk: Uint8Array<ArrayBufferLike>chunk, { TextDecodeOptions.stream?: boolean | undefinedstream: true }))
})
)