Skip to content

Commit f5c7fb3

Browse files
committed
stream: Duplex re-use Writable properties
Instead of reimplementing Writable properties, fetch them from the Writable prototype.
1 parent ab7d9db commit f5c7fb3

File tree

1 file changed

+14
-37
lines changed

1 file changed

+14
-37
lines changed

lib/_stream_duplex.js

+14-37
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,20 @@ function Duplex(options) {
7171
}
7272

7373
ObjectDefineProperties(Duplex.prototype, {
74-
writable: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable'),
74+
writable:
75+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable'),
76+
writableHighWaterMark:
77+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark'),
78+
writableBuffer:
79+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer'),
80+
writableLength:
81+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableLength'),
82+
writableFinished:
83+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableFinished'),
84+
writableCorked:
85+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableCorked'),
86+
writableEnded:
87+
ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableEnded'),
7588

7689
destroyed: {
7790
get() {
@@ -89,41 +102,5 @@ ObjectDefineProperties(Duplex.prototype, {
89102
this._writableState.destroyed = value;
90103
}
91104
}
92-
},
93-
94-
writableHighWaterMark: {
95-
get() {
96-
return this._writableState && this._writableState.highWaterMark;
97-
}
98-
},
99-
100-
writableBuffer: {
101-
get() {
102-
return this._writableState && this._writableState.getBuffer();
103-
}
104-
},
105-
106-
writableLength: {
107-
get() {
108-
return this._writableState && this._writableState.length;
109-
}
110-
},
111-
112-
writableFinished: {
113-
get() {
114-
return this._writableState ? this._writableState.finished : false;
115-
}
116-
},
117-
118-
writableCorked: {
119-
get() {
120-
return this._writableState ? this._writableState.corked : 0;
121-
}
122-
},
123-
124-
writableEnded: {
125-
get() {
126-
return this._writableState ? this._writableState.ending : false;
127-
}
128105
}
129106
});

0 commit comments

Comments
 (0)