mirror of
https://gitdab.com/cadence/out-of-your-element.git
synced 2025-09-10 20:32:50 +02:00
Qualify kind of stream
This commit is contained in:
parent
0d0ca98e13
commit
a5fd30d535
11 changed files with 26 additions and 25 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
const Ty = require("../types")
|
||||
const assert = require("assert").strict
|
||||
const streamWeb = require("stream/web")
|
||||
|
||||
const passthrough = require("../passthrough")
|
||||
const {sync} = passthrough
|
||||
|
@ -343,7 +344,7 @@ async function ping() {
|
|||
/**
|
||||
* @param {string} mxc
|
||||
* @param {RequestInit} [init]
|
||||
* @return {Promise<Response & {body: import("stream/web").ReadableStream<Uint8Array>}>}
|
||||
* @return {Promise<Response & {body: streamWeb.ReadableStream<Uint8Array>}>}
|
||||
*/
|
||||
async function getMedia(mxc, init = {}) {
|
||||
const mediaParts = mxc?.match(/^mxc:\/\/([^/]+)\/(\w+)$/)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const mixin = require("@cloudrac3r/mixin-deep")
|
||||
const stream = require("stream")
|
||||
const {ReadableStream} = require("stream/web")
|
||||
const streamWeb = require("stream/web")
|
||||
const getStream = require("get-stream")
|
||||
|
||||
const {reg, writeRegistration} = require("./read-registration.js")
|
||||
|
@ -22,7 +22,7 @@ class MatrixServerError extends Error {
|
|||
/**
|
||||
* @param {string} method
|
||||
* @param {string} url
|
||||
* @param {string | object | ReadableStream | stream.Readable} [body]
|
||||
* @param {string | object | streamWeb.ReadableStream | stream.Readable} [body]
|
||||
* @param {any} [extra]
|
||||
*/
|
||||
async function mreq(method, url, body, extra = {}) {
|
||||
|
@ -30,7 +30,7 @@ async function mreq(method, url, body, extra = {}) {
|
|||
body = JSON.stringify(body)
|
||||
} else if (body instanceof stream.Readable && reg.ooye.content_length_workaround) {
|
||||
body = await getStream.buffer(body)
|
||||
} else if (body instanceof ReadableStream && reg.ooye.content_length_workaround) {
|
||||
} else if (body instanceof streamWeb.ReadableStream && reg.ooye.content_length_workaround) {
|
||||
body = await stream.consumers.buffer(stream.Readable.fromWeb(body))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue