UNPKG

492 BPlain TextView Raw
1import { Transform } from 'stream'
2import { TransformTyped } from '../stream.model'
3
4/**
5 * Transform that does nothing (pass the data through).
6 * Can be used e.g to convert "not-valid" stream (e.g one that `transformMap` is producing)
7 * into a "valid" stream (that implements async-iteration interface).
8 */
9export function transformNoOp<T = any>(): TransformTyped<T, T> {
10 return new Transform({
11 objectMode: true,
12 transform(chunk: T, _, cb) {
13 cb(null, chunk)
14 },
15 })
16}