@@ -22,7 +22,7 @@ import {
22
22
23
23
/**
24
24
* @param {ImportCandidate | ImportCandidateStream } input
25
- * @param {(content:ToContent) => AsyncIterable<Uint8Array> } normaliseContent
25
+ * @param {(content:ToContent) => Promise< AsyncIterable<Uint8Array> > } normaliseContent
26
26
*/
27
27
// eslint-disable-next-line complexity
28
28
export async function * normalise ( input , normaliseContent ) {
@@ -72,6 +72,13 @@ export async function * normalise (input, normaliseContent) {
72
72
return
73
73
}
74
74
75
+ // Node ReadableStream<Node ReadableStream>
76
+ if ( value . _readableState ) {
77
+ // @ts -ignore Node readable streams have a `.path` property so we need to pass it as the content
78
+ yield * map ( peekable , ( /** @type {ImportCandidate } */ value ) => toFileObject ( { content : value } , normaliseContent ) )
79
+ return
80
+ }
81
+
75
82
// (Async)Iterable<Blob>
76
83
// (Async)Iterable<String>
77
84
// (Async)Iterable<{ path, content }>
@@ -103,7 +110,7 @@ export async function * normalise (input, normaliseContent) {
103
110
104
111
/**
105
112
* @param {ImportCandidate } input
106
- * @param {(content:ToContent) => AsyncIterable<Uint8Array> } normaliseContent
113
+ * @param {(content:ToContent) => Promise< AsyncIterable<Uint8Array> > } normaliseContent
107
114
*/
108
115
async function toFileObject ( input , normaliseContent ) {
109
116
// @ts -ignore - Those properties don't exist on most input types
@@ -117,7 +124,6 @@ async function toFileObject (input, normaliseContent) {
117
124
}
118
125
119
126
if ( content ) {
120
- // @ts -ignore TODO vmx 2021-03-30 enable again
121
127
file . content = await normaliseContent ( content )
122
128
} else if ( ! path ) { // Not already a file object with path or content prop
123
129
// @ts -ignore - input still can be different ToContent
0 commit comments