async function* payloadToMultipartItr(payload, boundary) {
    const files = extractFiles(payload);
    // Start multipart/form-data protocol
    yield enc.encode(`--${boundary}\r\n`);
    // Send all payload fields
    const separator = enc.encode(`\r\n--${boundary}\r\n`);
    let first = true;
    for (const [key, value] of Object.entries(payload)) {
        if (!first)
            yield separator;
        yield valuePart(key, typeof value === "object" ? str(value) : value);
        first = false;
    }
    // Send all files
    for (const { id, origin, file } of files) {
        if (!first)
            yield separator;
        yield* filePart(id, origin, file);
        first = false;
    }
    // End multipart/form-data protocol
    yield enc.encode(`\r\n--${boundary}--`);
}
/**
 * Takes a payload object and produces a valid multipart/form-data stream. The
 * stream is an iterator of `Uint8Array` objects. You also need to specify the
 * boundary string that was used in the Content-Type header of the HTTP request.
 *
 * @param payload a payload object
 * @param boundary the boundary string to use between the parts
 */
Takes a payload object and produces a valid multipart/form-data stream. The
stream is an iterator of `Uint8Array` objects. You also need to specify the
boundary string that was used in the Content-Type header of the HTTP request.

@param payload a payload object
@param boundary the boundary string to use between the parts
Takes a payload object and produces a valid multipart / form - data stream . The stream is an iterator of ` Uint8Array ` objects . You also need to specify the boundary string that was used in the Content - Type header of the HTTP request . @param payload a payload object @param boundary the boundary string to use between the parts
async function* payloadToMultipartItr(payload, boundary) {
    const files = extractFiles(payload);
    yield enc.encode(`--${boundary}\r\n`);
    const separator = enc.encode(`\r\n--${boundary}\r\n`);
    let first = true;
    for (const [key, value] of Object.entries(payload)) {
        if (!first)
            yield separator;
        yield valuePart(key, typeof value === "object" ? str(value) : value);
        first = false;
    }
    for (const { id, origin, file } of files) {
        if (!first)
            yield separator;
        yield* filePart(id, origin, file);
        first = false;
    }
    yield enc.encode(`\r\n--${boundary}--`);
}
async function * payloadToMultipartItr ( payload , boundary ) { const files = extractFiles ( payload ) ; yield enc . encode ( ` ${ boundary } \r \n ` ) ; const separator = enc . encode ( ` \r \n ${ boundary } \r \n ` ) ; let first = true ; for ( const [ key , value ] of Object . entries ( payload ) ) { if ( ! first ) yield separator ; yield valuePart ( key , typeof value === "object" ? str ( value ) : value ) ; first = false ; } for ( const { id , origin , file } of files ) { if ( ! first ) yield separator ; yield * filePart ( id , origin , file ) ; first = false ; } yield enc . encode ( ` \r \n ${ boundary } ` ) ; }
Takes a payload object and produces a valid multipart/form-data stream.
Takes a payload object and produces a valid multipart / form - data stream .
// Start multipart/form-data protocol // Send all payload fields // Send all files // End multipart/form-data protocol