File tree 5 files changed +45
-43
lines changed
5 files changed +45
-43
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 ;
@@ -23,6 +22,12 @@ const {
23
22
24
23
const { validateCallback } = require ( 'internal/validators' ) ;
25
24
25
+ const {
26
+ isIterable,
27
+ isReadable,
28
+ isStream,
29
+ } = require ( 'internal/streams/utils' ) ;
30
+
26
31
let EE ;
27
32
let PassThrough ;
28
33
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 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 256
256
'lib/internal/streams/state.js' ,
257
257
'lib/internal/streams/pipeline.js' ,
258
258
'lib/internal/streams/end-of-stream.js' ,
259
+ 'lib/internal/streams/utils.js' ,
259
260
'deps/v8/tools/splaytree.js' ,
260
261
'deps/v8/tools/codemap.js' ,
261
262
'deps/v8/tools/consarray.js' ,
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ const expectedModules = new Set([
98
98
'NativeModule internal/streams/readable' ,
99
99
'NativeModule internal/streams/state' ,
100
100
'NativeModule internal/streams/transform' ,
101
+ 'NativeModule internal/streams/utils' ,
101
102
'NativeModule internal/streams/writable' ,
102
103
'NativeModule internal/timers' ,
103
104
'NativeModule internal/url' ,
You can’t perform that action at this time.
0 commit comments