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 ;
@@ -23,6 +22,12 @@ const {
2322
2423const { validateCallback } = require ( 'internal/validators' ) ;
2524
25+ const {
26+ isIterable,
27+ isReadable,
28+ isStream,
29+ } = require ( 'internal/streams/utils' ) ;
30+
2631let EE ;
2732let PassThrough ;
2833let 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 33const {
44 ArrayPrototypePop,
55 Promise,
6- SymbolAsyncIterator,
7- SymbolIterator,
86} = primordials ;
97
108const {
@@ -15,29 +13,14 @@ const {
1513 validateAbortSignal,
1614} = require ( 'internal/validators' ) ;
1715
16+ const {
17+ isIterable,
18+ isStream,
19+ } = require ( 'internal/streams/utils' ) ;
20+
1821let pl ;
1922let eos ;
2023
21- function isReadable ( obj ) {
22- return ! ! ( obj && typeof obj . pipe === 'function' ) ;
23- }
24-
25- function isWritable ( obj ) {
26- return ! ! ( obj && typeof obj . write === 'function' ) ;
27- }
28-
29- function isStream ( obj ) {
30- return isReadable ( obj ) || isWritable ( obj ) ;
31- }
32-
33- function isIterable ( obj , isAsync ) {
34- if ( ! obj ) return false ;
35- if ( isAsync === true ) return typeof obj [ SymbolAsyncIterator ] === 'function' ;
36- if ( isAsync === false ) return typeof obj [ SymbolIterator ] === 'function' ;
37- return typeof obj [ SymbolAsyncIterator ] === 'function' ||
38- typeof obj [ SymbolIterator ] === 'function' ;
39- }
40-
4124function pipeline ( ...streams ) {
4225 if ( ! pl ) pl = require ( 'internal/streams/pipeline' ) ;
4326 return new Promise ( ( resolve , reject ) => {
Original file line number Diff line number Diff line change 256256 'lib/internal/streams/state.js' ,
257257 'lib/internal/streams/pipeline.js' ,
258258 'lib/internal/streams/end-of-stream.js' ,
259+ 'lib/internal/streams/utils.js' ,
259260 'deps/v8/tools/splaytree.js' ,
260261 'deps/v8/tools/codemap.js' ,
261262 'deps/v8/tools/consarray.js' ,
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ const expectedModules = new Set([
9898 'NativeModule internal/streams/readable' ,
9999 'NativeModule internal/streams/state' ,
100100 'NativeModule internal/streams/transform' ,
101+ 'NativeModule internal/streams/utils' ,
101102 'NativeModule internal/streams/writable' ,
102103 'NativeModule internal/timers' ,
103104 'NativeModule internal/url' ,
You can’t perform that action at this time.
0 commit comments