Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/node/_stream.d.ts>Readable#wrap

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
method Readable.prototype.wrap
import { Readable } from "https://deno.land/std@0.146.0/node/_stream.d.ts";

Prior to Node.js 0.10, streams did not implement the entire stream module API as it is currently defined. (See Compatibility for more information.)

When using an older Node.js library that emits 'data' events and has a pause method that is advisory only, thereadable.wrap() method can be used to create a Readable stream that uses the old stream as its data source.

It will rarely be necessary to use readable.wrap() but the method has been provided as a convenience for interacting with older Node.js applications and libraries.

const { OldReader } = require('./old-api-module.js');
const { Readable } = require('stream');
const oreader = new OldReader();
const myReader = new Readable().wrap(oreader);

myReader.on('readable', () => {
  myReader.read(); // etc.
});

Parameters

An "old style" readable stream