File tree Expand file tree Collapse file tree 4 files changed +44
-43
lines changed Expand file tree Collapse file tree 4 files changed +44
-43
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ const {
11
11
FunctionPrototypeCall,
12
12
ReflectApply,
13
13
SymbolAsyncIterator,
14
- SymbolIterator,
15
14
} = primordials ;
16
15
17
16
let eos ;
@@ -27,6 +26,12 @@ const {
27
26
28
27
const { validateCallback } = require ( 'internal/validators' ) ;
29
28
29
+ const {
30
+ isIterable,
31
+ isReadable,
32
+ isStream,
33
+ } = require ( 'internal/streams/utils' ) ;
34
+
30
35
let EE ;
31
36
let PassThrough ;
32
37
let Readable ;
@@ -82,26 +87,6 @@ function popCallback(streams) {
82
87
return ArrayPrototypePop ( streams ) ;
83
88
}
84
89
85
- function isReadable ( obj ) {
86
- return ! ! ( obj && typeof obj . pipe === 'function' ) ;
87
- }
88
-
89
- function isWritable ( obj ) {
90
- return ! ! ( obj && typeof obj . write === 'function' ) ;
91
- }
92
-
93
- function isStream ( obj ) {
94
- return isReadable ( obj ) || isWritable ( obj ) ;
95
- }
96
-
97
- function isIterable ( obj , isAsync ) {
98
- if ( ! obj ) return false ;
99
- if ( isAsync === true ) return typeof obj [ SymbolAsyncIterator ] === 'function' ;
100
- if ( isAsync === false ) return typeof obj [ SymbolIterator ] === 'function' ;
101
- return typeof obj [ SymbolAsyncIterator ] === 'function' ||
102
- typeof obj [ SymbolIterator ] === 'function' ;
103
- }
104
-
105
90
function makeAsyncIterable ( val ) {
106
91
if ( isIterable ( val ) ) {
107
92
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 3
3
const {
4
4
ArrayPrototypePop,
5
5
Promise,
6
- SymbolAsyncIterator,
7
- SymbolIterator,
8
6
} = primordials ;
9
7
10
8
const {
@@ -15,29 +13,14 @@ const {
15
13
validateAbortSignal,
16
14
} = require ( 'internal/validators' ) ;
17
15
16
+ const {
17
+ isIterable,
18
+ isStream,
19
+ } = require ( 'internal/streams/utils' ) ;
20
+
18
21
let pl ;
19
22
let eos ;
20
23
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
-
41
24
function pipeline ( ...streams ) {
42
25
if ( ! pl ) pl = require ( 'internal/streams/pipeline' ) ;
43
26
return new Promise ( ( resolve , reject ) => {
Original file line number Diff line number Diff line change 263
263
'lib/internal/streams/state.js' ,
264
264
'lib/internal/streams/pipeline.js' ,
265
265
'lib/internal/streams/end-of-stream.js' ,
266
+ 'lib/internal/streams/utils.js' ,
266
267
'deps/v8/tools/splaytree.js' ,
267
268
'deps/v8/tools/codemap.js' ,
268
269
'deps/v8/tools/consarray.js' ,
You can’t perform that action at this time.
0 commit comments