diff --git a/docs/modules/README.md b/docs/modules/README.md index 7bf185b1..8ea0d8c2 100644 --- a/docs/modules/README.md +++ b/docs/modules/README.md @@ -82,6 +82,7 @@ ESLint plugin. - [`string-width`](./string-width.md) - [`strip-ansi`](./strip-ansi.md) - [`tempy`](./tempy.md) +- [`through`](./through.md) - [`toml`](./toml.md) - [`traverse`](./traverse.md) - [`uri-js`](./uri-js.md) diff --git a/docs/modules/through.md b/docs/modules/through.md new file mode 100644 index 00000000..53365ec4 --- /dev/null +++ b/docs/modules/through.md @@ -0,0 +1,21 @@ +--- +description: Modern alternatives to the through package +--- + +# Replacements for `through` + +## `stream.Writable` (native, Node.js) + + +```ts +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 ++] +``` diff --git a/manifests/preferred.json b/manifests/preferred.json index 021b2250..a523657e 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -12,6 +12,12 @@ "replacements": ["tinyexec"], "url": {"type": "e18e", "id": "ez-spawn"} }, + "@ljharb/through": { + "type": "module", + "moduleName": "@ljharb/through", + "replacements": ["node:stream"], + "url": {"type": "e18e", "id": "through"} + }, "axios": { "type": "module", "moduleName": "axios", @@ -2423,6 +2429,12 @@ "replacements": ["fs.mkdtemp", "Deno.makeTempDir"], "url": {"type": "e18e", "id": "tempy"} }, + "through": { + "type": "module", + "moduleName": "through", + "replacements": ["node:stream"], + "url": {"type": "e18e", "id": "through"} + }, "toml": { "type": "module", "moduleName": "toml",