Skip to content

Commit f723335

Browse files
lpincaBethGriggs
authored andcommitted
doc: remove documentation for stream._construct()
The feature was added in Node.js v15.0.0. Fixes: nodejs#36058 PR-URL: nodejs#36119 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
1 parent fb14acb commit f723335

File tree

1 file changed

+0
-107
lines changed

1 file changed

+0
-107
lines changed

doc/api/stream.md

-107
Original file line numberDiff line numberDiff line change
@@ -1953,56 +1953,6 @@ const myWritable = new Writable({
19531953
});
19541954
```
19551955

1956-
#### `writable._construct(callback)`
1957-
<!-- YAML
1958-
added: v14.13.1
1959-
-->
1960-
1961-
* `callback` {Function} Call this function (optionally with an error
1962-
argument) when the stream has finished initializing.
1963-
1964-
The `_construct()` method MUST NOT be called directly. It may be implemented
1965-
by child classes, and if so, will be called by the internal `Writable`
1966-
class methods only.
1967-
1968-
This optional function will be called in a tick after the stream constructor
1969-
has returned, delaying any `_write()`, `_final()` and `_destroy()` calls until
1970-
`callback` is called. This is useful to initialize state or asynchronously
1971-
initialize resources before the stream can be used.
1972-
1973-
```js
1974-
const { Writable } = require('stream');
1975-
const fs = require('fs');
1976-
1977-
class WriteStream extends Writable {
1978-
constructor(filename) {
1979-
super();
1980-
this.filename = filename;
1981-
this.fd = fd;
1982-
}
1983-
_construct(callback) {
1984-
fs.open(this.filename, (fd, err) => {
1985-
if (err) {
1986-
callback(err);
1987-
} else {
1988-
this.fd = fd;
1989-
callback();
1990-
}
1991-
});
1992-
}
1993-
_write(chunk, encoding, callback) {
1994-
fs.write(this.fd, chunk, callback);
1995-
}
1996-
_destroy(err, callback) {
1997-
if (this.fd) {
1998-
fs.close(this.fd, (er) => callback(er || err));
1999-
} else {
2000-
callback(err);
2001-
}
2002-
}
2003-
}
2004-
```
2005-
20061956
#### `writable._write(chunk, encoding, callback)`
20071957
<!-- YAML
20081958
changes:
@@ -2269,63 +2219,6 @@ const myReadable = new Readable({
22692219
});
22702220
```
22712221

2272-
#### `readable._construct(callback)`
2273-
<!-- YAML
2274-
added: v14.13.1
2275-
-->
2276-
2277-
* `callback` {Function} Call this function (optionally with an error
2278-
argument) when the stream has finished initializing.
2279-
2280-
The `_construct()` method MUST NOT be called directly. It may be implemented
2281-
by child classes, and if so, will be called by the internal `Readable`
2282-
class methods only.
2283-
2284-
This optional function will be scheduled in the next tick by the stream
2285-
constructor, delaying any `_read()` and `_destroy()` calls until `callback` is
2286-
called. This is useful to initialize state or asynchronously initialize
2287-
resources before the stream can be used.
2288-
2289-
```js
2290-
const { Readable } = require('stream');
2291-
const fs = require('fs');
2292-
2293-
class ReadStream extends Readable {
2294-
constructor(filename) {
2295-
super();
2296-
this.filename = filename;
2297-
this.fd = null;
2298-
}
2299-
_construct(callback) {
2300-
fs.open(this.filename, (fd, err) => {
2301-
if (err) {
2302-
callback(err);
2303-
} else {
2304-
this.fd = fd;
2305-
callback();
2306-
}
2307-
});
2308-
}
2309-
_read(n) {
2310-
const buf = Buffer.alloc(n);
2311-
fs.read(this.fd, buf, 0, n, null, (err, bytesRead) => {
2312-
if (err) {
2313-
this.destroy(err);
2314-
} else {
2315-
this.push(bytesRead > 0 ? buf.slice(0, bytesRead) : null);
2316-
}
2317-
});
2318-
}
2319-
_destroy(err, callback) {
2320-
if (this.fd) {
2321-
fs.close(this.fd, (er) => callback(er || err));
2322-
} else {
2323-
callback(err);
2324-
}
2325-
}
2326-
}
2327-
```
2328-
23292222
#### `readable._read(size)`
23302223
<!-- YAML
23312224
added: v0.9.4

0 commit comments

Comments
 (0)