Skip to content

Stream migration

Stream was removed in @stopcock/fp 2.0. Iter is the only lazy synchronous-sequence abstraction; it is a real replacement, not a compatibility alias.

import { pipe, Stream } from '@stopcock/fp'
import { pipe } from '@stopcock/fp'
import * as Iter from '@stopcock/fp/iter'
const values = pipe(
Stream.range(0, 100),
Stream.map((value) => value * 2),
Stream.take(5),
Stream.toArray,
Iter.range(0, 100),
Iter.map((value) => value * 2),
Iter.take(5),
Iter.toArray,
)

The migration codemod can split old root imports and rewrite the common Stream.* vocabulary:

Terminal window
bunx stopcock-fp-codemod --write src

Read the Iter API for constructors, transformations, terminals, iterator-closing semantics, and mutable *Into escape hatches.