title: Node.js image download with bandwidth limit
body: <p>I'm currently testing out something at the reddit image download feature of my discord bot. The code below is just a scaffold for testing. I was wondering if there is a way of capping or throttling the bandwidth of an image download from a request response. The image is just downloaded once.</p>
  <p>I already used different request modules from npm like <a href="https://www.npmjs.com/package/superagent" rel="nofollow noreferrer">superagent</a> and their plugins but none of them worked. I also found the module <a href="https://www.npmjs.com/package/ratelimit" rel="nofollow noreferrer">ratelimit</a> but this is very old (last commit 2012) and only supports http-requests (no https).</p>
  <pre><code>var request = require('request')
  var fs = require('fs')
  
  request('https://upload.wikimedia.org/wikipedia/commons/6/60/Eol.jsc.nasa.gov_ESC_large_ISS005_ISS005-E-16279.JPG')
      .on('response', (response) =&gt; {
          // limitBandwidth()
      })
      .on('data', (data) =&gt; {
          
      })
      .pipe(fs.createWriteStream('test.jpg'))
  
  </code></pre>