Oct 2, 2020
Using Highland to Throttle
Usually when doing a command line tool you will like to throttle the handling speed, at least if this is a tool that is doing some kind of http request. Highland is a library that adds this kind of functionality to your toolkit by working with node streams.
Code of the Day
Here we throttle with allowing two operations in parallell.
const _ = require('highland');
const split = require('split');
const input = process.stdin.pipe(split());
_(input)
  .filter(item=>!!item)
  .map((line) => {
    return _(my_code(line))
  })
  .parallel(2)
  .toArray(function (res) {
    console.log('complete ');
  });
async function my_code(item) {
  console.log(item)
}