File tree Expand file tree Collapse file tree 4 files changed +40
-21
lines changed Expand file tree Collapse file tree 4 files changed +40
-21
lines changed Original file line number Diff line number Diff line change 7
7
ArrayIsArray,
8
8
ReflectApply,
9
9
SymbolAsyncIterator,
10
- SymbolIterator,
11
10
} = primordials ;
12
11
13
12
let eos ;
@@ -22,6 +21,12 @@ const {
22
21
ERR_STREAM_DESTROYED
23
22
} = require ( 'internal/errors' ) . codes ;
24
23
24
+ const {
25
+ isIterable,
26
+ isReadable,
27
+ isStream,
28
+ } = require ( 'internal/streams/utils' ) ;
29
+
25
30
let EE ;
26
31
let PassThrough ;
27
32
let Readable ;
@@ -78,26 +83,6 @@ function popCallback(streams) {
78
83
return streams . pop ( ) ;
79
84
}
80
85
81
- function isReadable ( obj ) {
82
- return ! ! ( obj && typeof obj . pipe === 'function' ) ;
83
- }
84
-
85
- function isWritable ( obj ) {
86
- return ! ! ( obj && typeof obj . write === 'function' ) ;
87
- }
88
-
89
- function isStream ( obj ) {
90
- return isReadable ( obj ) || isWritable ( obj ) ;
91
- }
92
-
93
- function isIterable ( obj , isAsync ) {
94
- if ( ! obj ) return false ;
95
- if ( isAsync === true ) return typeof obj [ SymbolAsyncIterator ] === 'function' ;
96
- if ( isAsync === false ) return typeof obj [ SymbolIterator ] === 'function' ;
97
- return typeof obj [ SymbolAsyncIterator ] === 'function' ||
98
- typeof obj [ SymbolIterator ] === 'function' ;
99
- }
100
-
101
86
function makeAsyncIterable ( val ) {
102
87
if ( isIterable ( val ) ) {
103
88
return val ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const {
4
+ SymbolAsyncIterator,
5
+ SymbolIterator,
6
+ } = primordials ;
7
+
8
+ function isReadable ( obj ) {
9
+ return ! ! ( obj && typeof obj . pipe === 'function' ) ;
10
+ }
11
+
12
+ function isWritable ( obj ) {
13
+ return ! ! ( obj && typeof obj . write === 'function' ) ;
14
+ }
15
+
16
+ function isStream ( obj ) {
17
+ return isReadable ( obj ) || isWritable ( obj ) ;
18
+ }
19
+
20
+ function isIterable ( obj , isAsync ) {
21
+ if ( ! obj ) return false ;
22
+ if ( isAsync === true ) return typeof obj [ SymbolAsyncIterator ] === 'function' ;
23
+ if ( isAsync === false ) return typeof obj [ SymbolIterator ] === 'function' ;
24
+ return typeof obj [ SymbolAsyncIterator ] === 'function' ||
25
+ typeof obj [ SymbolIterator ] === 'function' ;
26
+ }
27
+
28
+ module . exports = {
29
+ isIterable,
30
+ isReadable,
31
+ isStream,
32
+ } ;
Original file line number Diff line number Diff line change 245
245
'lib/internal/streams/state.js' ,
246
246
'lib/internal/streams/pipeline.js' ,
247
247
'lib/internal/streams/end-of-stream.js' ,
248
+ 'lib/internal/streams/utils.js' ,
248
249
'deps/v8/tools/splaytree.js' ,
249
250
'deps/v8/tools/codemap.js' ,
250
251
'deps/v8/tools/consarray.js' ,
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ const expectedModules = new Set([
79
79
'NativeModule internal/process/warning' ,
80
80
'NativeModule internal/querystring' ,
81
81
'NativeModule internal/source_map/source_map_cache' ,
82
+ 'NativeModule internal/streams/utils' ,
82
83
'NativeModule internal/timers' ,
83
84
'NativeModule internal/url' ,
84
85
'NativeModule internal/util' ,
You can’t perform that action at this time.
0 commit comments