| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33352c2 commit 5bf2772
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ const { | |||
| 25 | 25 | ArrayIsArray, | |
| 26 | 26 | NumberIsInteger, | |
| 27 | 27 | NumberIsNaN, | |
| 28 | - ObjectDefineProperty, | ||
| 28 | + ObjectDefineProperties, | ||
| 29 | 29 | ObjectSetPrototypeOf, | |
| 30 | 30 | SymbolAsyncIterator, | |
| 31 | 31 | Symbol | |
@@ -166,22 +166,6 @@ function ReadableState(options, stream, isDuplex) { | |||
| 166 | 166 | } | |
| 167 | 167 | } | |
| 168 | 168 | ||
| 169 | - // Legacy getter for `pipesCount` | ||
| 170 | - ObjectDefineProperty(ReadableState.prototype, 'pipesCount', { | ||
| 171 | - get() { | ||
| 172 | - return this.pipes.length; | ||
| 173 | - } | ||
| 174 | - }); | ||
| 175 | - | ||
| 176 | - // Legacy property for `paused` | ||
| 177 | - ObjectDefineProperty(ReadableState.prototype, 'paused', { | ||
| 178 | - get() { | ||
| 179 | - return this[kPaused] !== false; | ||
| 180 | - }, | ||
| 181 | - set(value) { | ||
| 182 | - this[kPaused] = !!value; | ||
| 183 | - } | ||
| 184 | - }); | ||
| 185 | 169 | ||
| 186 | 170 | function Readable(options) { | |
| 187 | 171 | if (!(this instanceof Readable)) | |
@@ -207,40 +191,6 @@ function Readable(options) { | |||
| 207 | 191 | Stream.call(this, options); | |
| 208 | 192 | } | |
| 209 | 193 | ||
| 210 | - ObjectDefineProperty(Readable.prototype, 'destroyed', { | ||
| 211 | - // Making it explicit this property is not enumerable | ||
| 212 | - // because otherwise some prototype manipulation in | ||
| 213 | - // userland will fail | ||
| 214 | - enumerable: false, | ||
| 215 | - get() { | ||
| 216 | - if (this._readableState === undefined) { | ||
| 217 | - return false; | ||
| 218 | - } | ||
| 219 | - return this._readableState.destroyed; | ||
| 220 | - }, | ||
| 221 | - set(value) { | ||
| 222 | - // We ignore the value if the stream | ||
| 223 | - // has not been initialized yet | ||
| 224 | - if (!this._readableState) { | ||
| 225 | - return; | ||
| 226 | - } | ||
| 227 | - | ||
| 228 | - // Backward compatibility, the user is explicitly | ||
| 229 | - // managing destroyed | ||
| 230 | - this._readableState.destroyed = value; | ||
| 231 | - } | ||
| 232 | - }); | ||
| 233 | - | ||
| 234 | - ObjectDefineProperty(Readable.prototype, 'readableEnded', { | ||
| 235 | - // Making it explicit this property is not enumerable | ||
| 236 | - // because otherwise some prototype manipulation in | ||
| 237 | - // userland will fail | ||
| 238 | - enumerable: false, | ||
| 239 | - get() { | ||
| 240 | - return this._readableState ? this._readableState.endEmitted : false; | ||
| 241 | - } | ||
| 242 | - }); | ||
| 243 | - | ||
| 244 | 194 | Readable.prototype.destroy = destroyImpl.destroy; | |
| 245 | 195 | Readable.prototype._undestroy = destroyImpl.undestroy; | |
| 246 | 196 | Readable.prototype._destroy = function(err, cb) { | |
@@ -1120,68 +1070,106 @@ Readable.prototype[SymbolAsyncIterator] = function() { | |||
| 1120 | 1070 | return createReadableStreamAsyncIterator(this); | |
| 1121 | 1071 | }; | |
| 1122 | 1072 | ||
| 1123 | - ObjectDefineProperty(Readable.prototype, 'readableHighWaterMark', { | ||
| 1124 | - // Making it explicit this property is not enumerable | ||
| 1125 | - // because otherwise some prototype manipulation in | ||
| 1126 | - // userland will fail | ||
| 1127 | - enumerable: false, | ||
| 1128 | - get: function() { | ||
| 1129 | - return this._readableState.highWaterMark; | ||
| 1130 | - } | ||
| 1131 | - }); | ||
| 1073 | + // Making it explicit these properties are not enumerable | ||
| 1074 | + // because otherwise some prototype manipulation in | ||
| 1075 | + // userland will fail | ||
| 1076 | + ObjectDefineProperties(Readable.prototype, { | ||
| 1132 | 1077 | ||
| 1133 | - ObjectDefineProperty(Readable.prototype, 'readableBuffer', { | ||
| 1134 | - // Making it explicit this property is not enumerable | ||
| 1135 | - // because otherwise some prototype manipulation in | ||
| 1136 | - // userland will fail | ||
| 1137 | - enumerable: false, | ||
| 1138 | - get: function() { | ||
| 1139 | - return this._readableState && this._readableState.buffer; | ||
| 1140 | - } | ||
| 1141 | - }); | ||
| 1078 | + readableHighWaterMark: { | ||
| 1079 | + enumerable: false, | ||
| 1080 | + get: function() { | ||
| 1081 | + return this._readableState.highWaterMark; | ||
| 1082 | + } | ||
| 1083 | + }, | ||
| 1142 | 1084 | ||
| 1143 | - ObjectDefineProperty(Readable.prototype, 'readableFlowing', { | ||
| 1144 | - // Making it explicit this property is not enumerable | ||
| 1145 | - // because otherwise some prototype manipulation in | ||
| 1146 | - // userland will fail | ||
| 1147 | - enumerable: false, | ||
| 1148 | - get: function() { | ||
| 1149 | - return this._readableState.flowing; | ||
| 1085 | + readableBuffer: { | ||
| 1086 | + enumerable: false, | ||
| 1087 | + get: function() { | ||
| 1088 | + return this._readableState && this._readableState.buffer; | ||
| 1089 | + } | ||
| 1150 | 1090 | }, | |
| 1151 | - set: function(state) { | ||
| 1152 | - if (this._readableState) { | ||
| 1153 | - this._readableState.flowing = state; | ||
| 1091 | + | ||
| 1092 | + readableFlowing: { | ||
| 1093 | + enumerable: false, | ||
| 1094 | + get: function() { | ||
| 1095 | + return this._readableState.flowing; | ||
| 1096 | + }, | ||
| 1097 | + set: function(state) { | ||
| 1098 | + if (this._readableState) { | ||
| 1099 | + this._readableState.flowing = state; | ||
| 1100 | + } | ||
| 1154 | 1101 | } | |
| 1155 | - } | ||
| 1156 | - }); | ||
| 1102 | + }, | ||
| 1157 | 1103 | ||
| 1158 | - // Exposed for testing purposes only. | ||
| 1159 | - Readable._fromList = fromList; | ||
| 1104 | + readableLength: { | ||
| 1105 | + enumerable: false, | ||
| 1106 | + get() { | ||
| 1107 | + return this._readableState.length; | ||
| 1108 | + } | ||
| 1109 | + }, | ||
| 1160 | 1110 | ||
| 1161 | - ObjectDefineProperty(Readable.prototype, 'readableLength', { | ||
| 1162 | - // Making it explicit this property is not enumerable | ||
| 1163 | - // because otherwise some prototype manipulation in | ||
| 1164 | - // userland will fail | ||
| 1165 | - enumerable: false, | ||
| 1166 | - get() { | ||
| 1167 | - return this._readableState.length; | ||
| 1168 | - } | ||
| 1169 | - }); | ||
| 1111 | + readableObjectMode: { | ||
| 1112 | + enumerable: false, | ||
| 1113 | + get() { | ||
| 1114 | + return this._readableState ? this._readableState.objectMode : false; | ||
| 1115 | + } | ||
| 1116 | + }, | ||
| 1170 | 1117 | ||
| 1171 | - ObjectDefineProperty(Readable.prototype, 'readableObjectMode', { | ||
| 1172 | - enumerable: false, | ||
| 1173 | - get() { | ||
| 1174 | - return this._readableState ? this._readableState.objectMode : false; | ||
| 1175 | - } | ||
| 1176 | - }); | ||
| 1118 | + readableEncoding: { | ||
| 1119 | + enumerable: false, | ||
| 1120 | + get() { | ||
| 1121 | + return this._readableState ? this._readableState.encoding : null; | ||
| 1122 | + } | ||
| 1123 | + }, | ||
| 1177 | 1124 | ||
| 1178 | - ObjectDefineProperty(Readable.prototype, 'readableEncoding', { | ||
| 1179 | - enumerable: false, | ||
| 1180 | - get() { | ||
| 1181 | - return this._readableState ? this._readableState.encoding : null; | ||
| 1125 | + destroyed: { | ||
| 1126 | + enumerable: false, | ||
| 1127 | + get() { | ||
| 1128 | + if (this._readableState === undefined) { | ||
| 1129 | + return false; | ||
| 1130 | + } | ||
| 1131 | + return this._readableState.destroyed; | ||
| 1132 | + }, | ||
| 1133 | + set(value) { | ||
| 1134 | + // We ignore the value if the stream | ||
| 1135 | + // has not been initialized yet | ||
| 1136 | + if (!this._readableState) { | ||
| 1137 | + return; | ||
| 1138 | + } | ||
| 1139 | + | ||
| 1140 | + // Backward compatibility, the user is explicitly | ||
| 1141 | + // managing destroyed | ||
| 1142 | + this._readableState.destroyed = value; | ||
| 1143 | + } | ||
| 1144 | + }, | ||
| 1145 | + | ||
| 1146 | + readableEnded: { | ||
| 1147 | + enumerable: false, | ||
| 1148 | + get() { | ||
| 1149 | + return this._readableState ? this._readableState.endEmitted : false; | ||
| 1150 | + } | ||
| 1151 | + }, | ||
| 1152 | + | ||
| 1153 | + // Legacy getter for `pipesCount` | ||
| 1154 | + pipesCount: { | ||
| 1155 | + get() { | ||
| 1156 | + return this.pipes.length; | ||
| 1157 | + } | ||
| 1158 | + }, | ||
| 1159 | + | ||
| 1160 | + paused: { | ||
| 1161 | + get() { | ||
| 1162 | + return this[kPaused] !== false; | ||
| 1163 | + }, | ||
| 1164 | + set(value) { | ||
| 1165 | + this[kPaused] = !!value; | ||
| 1166 | + } | ||
| 1182 | 1167 | } | |
| 1183 | 1168 | }); | |
| 1184 | 1169 | ||
| 1170 | + // Exposed for testing purposes only. | ||
| 1171 | + Readable._fromList = fromList; | ||
| 1172 | + | ||
| 1185 | 1173 | // Pluck off n bytes from an array of buffers. | |
| 1186 | 1174 | // Length is the combined lengths of all the buffers in the list. | |
| 1187 | 1175 | // This function is designed to be inlinable, so please take care when making | |
| Back | FazBrowse Home | New Git URL |
0 commit comments