Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 471 Bytes

File metadata and controls

21 lines (17 loc) · 471 Bytes
description Modern alternatives to the through package

Replacements for through

stream.Writable (native, Node.js)

import through from 'through' // [!code --]
import { Writable } from 'node:stream' // [!code ++]

through(fn) // [!code --]
new Writable({ // [!code ++]
  write: (chunk, encoding, callback) => { // [!code ++]
    fn(chunk) // [!code ++]
    callback() // [!code ++]
  } // [!code ++]
}) // [!code ++]