Remove null and undefined values from a stream
A TransformStream that filters out null and undefined values
const readable = new ReadableStream({ start(controller) { const items = [1, null, 2, undefined, 3] items.forEach(item => { controller.enqueue(item) }) }})const stream = readable.pipeThrough(compact());// If readable emits [1, null, 2, undefined, 3], the result will be [1, 2, 3] Copy
const readable = new ReadableStream({ start(controller) { const items = [1, null, 2, undefined, 3] items.forEach(item => { controller.enqueue(item) }) }})const stream = readable.pipeThrough(compact());// If readable emits [1, null, 2, undefined, 3], the result will be [1, 2, 3]
Remove null and undefined values from a stream