npm

[observablehq.com] @mbostock/package-dependencies

Typeorm + Postgres, naming strategies

Node

const {execSync} = require('child_process')
// handy replacement for awk scripts
// usage: transform(input, output, (line) => line)

const readline = require("readline")
const fs = require("fs")

const transform = (inputPath, outputPath, fn) => {
  const readInterface = readline.createInterface({
    input: fs.createReadStream(inputPath),
  })
  const writeStream = fs.createWriteStream(outputPath)

  readInterface.on("line", line => {
    const transformed = fn(line)
    if (transformed) {
      writeStream.write(transformed + "\n")
    }
  })
  readInterface.on("close", () => {
    writeStream.close()
  })
}

module.exports = transform