https://github.com/scalajs-io/brake
throttle a stream with backpressure
https://github.com/scalajs-io/brake
node nodejs npm npm-package scala scalajs
Last synced: 4 months ago
JSON representation
throttle a stream with backpressure
- Host: GitHub
- URL: https://github.com/scalajs-io/brake
- Owner: scalajs-io
- License: apache-2.0
- Created: 2017-02-09T00:48:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-17T23:07:23.000Z (over 6 years ago)
- Last Synced: 2025-07-04T04:39:34.150Z (6 months ago)
- Topics: node, nodejs, npm, npm-package, scala, scalajs
- Language: Scala
- Size: 15.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Brake API for Scala.js
================================
[brake](https://www.npmjs.com/package/brake) - Throttle a stream with backpressure.
### Description
Throttle a stream with backpressure.
### Build Dependencies
* [SBT v1.2.x](http://www.scala-sbt.org/download.html)
### Build/publish the SDK locally
```bash
$ sbt clean publish-local
```
### Running the tests
Before running the tests the first time, you must ensure the npm packages are installed:
```bash
$ npm install
```
Then you can run the tests:
```bash
$ sbt test
```
### Examples
```scala
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)
```
##### Output:
```text
ABCDEF
```
### Artifacts and Resolvers
To add the `Brake` binding to your project, add the following to your build.sbt:
```sbt
libraryDependencies += "io.scalajs.npm" %%% "brake" % "0.5.0"
```
Optionally, you may add the Sonatype Repository resolver:
```sbt
resolvers += Resolver.sonatypeRepo("releases")