brake - Throttle a stream with backpressure.
Throttle a stream with backpressure.
$ sbt clean publish-local
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
import io.scalajs.nodejs.buffer.Buffer
import io.scalajs.nodejs.process
import io.scalajs.npm.brake.Brake
import io.scalajs.npm.readablestream.Readable
val bulk = new Readable()
bulk._read = () => {}
('A' to 'F') foreach { ch =>
bulk.push(Buffer.from(String.valueOf(ch)))
}
bulk.push(null)
bulk.pipe(Brake(10)).pipe(process.stdout)
ABCDEF
To add the Brake
binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs.npm" %%% "brake" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")