1
1
'use strict' ;
2
- require ( '../common' ) ;
2
+ const common = require ( '../common' ) ;
3
3
const Readable = require ( '_stream_readable' ) ;
4
4
const Writable = require ( '_stream_writable' ) ;
5
5
const assert = require ( 'assert' ) ;
@@ -54,7 +54,7 @@ function toArray(callback) {
54
54
55
55
function fromArray ( list ) {
56
56
const r = new Readable ( { objectMode : true } ) ;
57
- r . _read = noop ;
57
+ r . _read = common . mustNotCall ( ) ;
58
58
list . forEach ( function ( chunk ) {
59
59
r . push ( chunk ) ;
60
60
} ) ;
@@ -63,8 +63,6 @@ function fromArray(list) {
63
63
return r ;
64
64
}
65
65
66
- function noop ( ) { }
67
-
68
66
test ( 'can read objects from stream' , function ( t ) {
69
67
const r = fromArray ( [ { one : '1' } , { two : '2' } ] ) ;
70
68
@@ -144,7 +142,7 @@ test('can read strings as objects', function(t) {
144
142
const r = new Readable ( {
145
143
objectMode : true
146
144
} ) ;
147
- r . _read = noop ;
145
+ r . _read = common . mustNotCall ( ) ;
148
146
const list = [ 'one' , 'two' , 'three' ] ;
149
147
list . forEach ( function ( str ) {
150
148
r . push ( str ) ;
@@ -162,7 +160,7 @@ test('read(0) for object streams', function(t) {
162
160
const r = new Readable ( {
163
161
objectMode : true
164
162
} ) ;
165
- r . _read = noop ;
163
+ r . _read = common . mustNotCall ( ) ;
166
164
167
165
r . push ( 'foobar' ) ;
168
166
r . push ( null ) ;
@@ -178,7 +176,7 @@ test('falsey values', function(t) {
178
176
const r = new Readable ( {
179
177
objectMode : true
180
178
} ) ;
181
- r . _read = noop ;
179
+ r . _read = common . mustNotCall ( ) ;
182
180
183
181
r . push ( false ) ;
184
182
r . push ( 0 ) ;
@@ -229,7 +227,7 @@ test('high watermark push', function(t) {
229
227
highWaterMark : 6 ,
230
228
objectMode : true
231
229
} ) ;
232
- r . _read = function ( n ) { } ;
230
+ r . _read = common . mustNotCall ( ) ;
233
231
for ( let i = 0 ; i < 6 ; i ++ ) {
234
232
const bool = r . push ( i ) ;
235
233
assert . strictEqual ( bool , i !== 5 ) ;
0 commit comments