mirror of
https://codeberg.org/Kankys/NewLukasBlog.git
synced 2026-11-11 06:14:36 +01:00
OpravyPoAI
This commit is contained in:
1 parent
99aa797101
commit
24fd53c94c
4746 files changed
+700320
-12
No files matched your search
+20
@@ -0,0 +1,20 @@
|
||||
import {getStreamAsArrayBuffer} from './array-buffer.js';
|
||||
|
||||
export async function getStreamAsBuffer(stream, options) {
|
||||
if (!('Buffer' in globalThis)) {
|
||||
throw new Error('getStreamAsBuffer() is only supported in Node.js');
|
||||
}
|
||||
|
||||
try {
|
||||
return arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream, options));
|
||||
} catch (error) {
|
||||
if (error.bufferedData !== undefined) {
|
||||
error.bufferedData = arrayBufferToNodeBuffer(error.bufferedData);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line n/prefer-global/buffer
|
||||
const arrayBufferToNodeBuffer = arrayBuffer => globalThis.Buffer.from(arrayBuffer);
|
||||
Reference in new issue
Block a user