GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: make Duplex inherits from DuplexBase · nodejs/node@152c931

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _stream_duplex.js
    • internal/streams
      • duplex_base.js
  • node.gyp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/_stream_duplex.js‎

Copy file name to clipboardExpand all lines: lib/_stream_duplex.js
+4-22Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,15 @@
2929
module.exports = Duplex;
3030

3131
const util = require('util');
32-
const Readable = require('_stream_readable');
33-
const Writable = require('_stream_writable');
34-
35-
util.inherits(Duplex, Readable);
36-
37-
{
38-
// avoid scope creep, the keys array can then be collected
39-
const keys = Object.keys(Writable.prototype);
40-
for (var v = 0; v < keys.length; v++) {
41-
const method = keys[v];
42-
if (!Duplex.prototype[method])
43-
Duplex.prototype[method] = Writable.prototype[method];
44-
}
45-
}
32+
const DuplexBase = require('internal/streams/duplex_base');
33+
34+
util.inherits(Duplex, DuplexBase);
4635

4736
function Duplex(options) {
4837
if (!(this instanceof Duplex))
4938
return new Duplex(options);
5039

51-
Readable.call(this, options);
52-
Writable.call(this, options);
53-
54-
if (options && options.readable === false)
55-
this.readable = false;
56-
57-
if (options && options.writable === false)
58-
this.writable = false;
40+
DuplexBase.call(this, options);
5941

6042
this.allowHalfOpen = true;
6143
if (options && options.allowHalfOpen === false) {
Collapse file

‎lib/internal/streams/duplex_base.js‎

Copy file name to clipboard
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
const util = require('util');
4+
const Readable = require('_stream_readable');
5+
const Writable = require('_stream_writable');
6+
7+
function DuplexBase(options) {
8+
Readable.call(this, options);
9+
Writable.call(this, options);
10+
11+
if (options && options.readable === false)
12+
this.readable = false;
13+
14+
if (options && options.writable === false)
15+
this.writable = false;
16+
}
17+
18+
util.inherits(DuplexBase, Readable);
19+
20+
{
21+
// Avoid scope creep, the keys array can then be collected.
22+
const keys = Object.keys(Writable.prototype);
23+
for (var v = 0; v < keys.length; v++) {
24+
const method = keys[v];
25+
if (!DuplexBase.prototype[method])
26+
DuplexBase.prototype[method] = Writable.prototype[method];
27+
}
28+
}
29+
30+
module.exports = DuplexBase;
Collapse file

‎node.gyp‎

Copy file name to clipboardExpand all lines: node.gyp
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
'lib/internal/vm/Module.js',
143143
'lib/internal/streams/lazy_transform.js',
144144
'lib/internal/streams/BufferList.js',
145+
'lib/internal/streams/duplex_base.js',
145146
'lib/internal/streams/legacy.js',
146147
'lib/internal/streams/destroy.js',
147148
'lib/internal/wrap_js_stream.js',

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.