stream-throttle - A rate limiter for Node.js streams.
A rate limiter for Node.js streams.
$ sbt clean publish-localBefore running the tests the first time, you must ensure the npm packages are installed:
$ npm installThen you can run the tests:
$ sbt testimport io.scalajs.nodejs._
import io.scalajs.npm.streamthrottle._
process.stdin.pipe(new Throttle(new ThrottleOptions(rate = 10))).pipe(process.stdout)import io.scalajs.nodejs._
import io.scalajs.nodejs.net._
import io.scalajs.npm.streamthrottle._
import scalajs.js
val tg = new ThrottleGroup(new ThrottleOptions(rate = 10240))
val conn1 = Net.createConnection(host = "www.google.com", port = 80)
val conn2 = Net.createConnection(host = "www.google.com", port = 80)
val thr1 = conn1.pipe(tg.throttle())
val thr2 = conn2.pipe(tg.throttle())
// Reads from thr1 and thr2 are throttled to 10 KB/s in aggregateTo add the stream-throttle binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs.npm" %%% "stream-throttle" % "0.5.0"Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")