File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 ArrayIsArray,
88 ReflectApply,
99 SymbolAsyncIterator,
10- SymbolIterator,
1110} = primordials ;
1211
1312let eos ;
@@ -22,6 +21,12 @@ const {
2221 ERR_STREAM_DESTROYED
2322} = require ( 'internal/errors' ) . codes ;
2423
24+ const {
25+ isIterable,
26+ isReadable,
27+ isStream,
28+ } = require ( 'internal/streams/utils' ) ;
29+
2530let EE ;
2631let PassThrough ;
2732let Readable ;
@@ -78,26 +83,6 @@ function popCallback(streams) {
7883 return streams . pop ( ) ;
7984}
8085
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-
10186function makeAsyncIterable ( val ) {
10287 if ( isIterable ( val ) ) {
10388 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 245245 'lib/internal/streams/state.js' ,
246246 'lib/internal/streams/pipeline.js' ,
247247 'lib/internal/streams/end-of-stream.js' ,
248+ 'lib/internal/streams/utils.js' ,
248249 'deps/v8/tools/splaytree.js' ,
249250 'deps/v8/tools/codemap.js' ,
250251 'deps/v8/tools/consarray.js' ,
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ const expectedModules = new Set([
7979 'NativeModule internal/process/warning' ,
8080 'NativeModule internal/querystring' ,
8181 'NativeModule internal/source_map/source_map_cache' ,
82+ 'NativeModule internal/streams/utils' ,
8283 'NativeModule internal/timers' ,
8384 'NativeModule internal/url' ,
8485 'NativeModule internal/util' ,
You can’t perform that action at this time.
0 commit comments