@rsdk/common.node 5.11.0-next.6 → 5.11.0-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const streamToBuffer: (stream: NodeJS.ReadableStream) => Promise<Buffer>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.streamToBuffer = void 0;
|
|
4
|
+
/*
|
|
5
|
+
*Reads stream to Node.js Buffer chunk by chunk
|
|
6
|
+
* @param stream Readable stream
|
|
7
|
+
* @returns Promise<Buffer>
|
|
8
|
+
*/
|
|
9
|
+
const streamToBuffer = async (stream) => {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
for await (const chunk of stream) {
|
|
12
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
13
|
+
}
|
|
14
|
+
return Buffer.concat(chunks);
|
|
15
|
+
};
|
|
16
|
+
exports.streamToBuffer = streamToBuffer;
|
|
17
|
+
//# sourceMappingURL=stream-to-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-to-buffer.js","sourceRoot":"","sources":["../src/stream-to-buffer.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACI,MAAM,cAAc,GAAG,KAAK,EACjC,MAA6B,EACZ,EAAE;IACnB,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAVW,QAAA,cAAc,kBAUzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdk/common.node",
|
|
3
|
-
"version": "5.11.0-next.
|
|
3
|
+
"version": "5.11.0-next.7",
|
|
4
4
|
"description": "Useful common classes, functions and types",
|
|
5
5
|
"license": "Apache License 2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"rxjs": "^7.1.0"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "934a2768b507e724697845631ed68874f4b9e53c"
|
|
25
25
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*Reads stream to Node.js Buffer chunk by chunk
|
|
3
|
+
* @param stream Readable stream
|
|
4
|
+
* @returns Promise<Buffer>
|
|
5
|
+
*/
|
|
6
|
+
export const streamToBuffer = async (
|
|
7
|
+
stream: NodeJS.ReadableStream, // Why not `Readable` from `node:stream`? - https://github.com/microsoft/TypeScript/issues/39051
|
|
8
|
+
): Promise<Buffer> => {
|
|
9
|
+
const chunks: Buffer[] = [];
|
|
10
|
+
|
|
11
|
+
for await (const chunk of stream) {
|
|
12
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return Buffer.concat(chunks);
|
|
16
|
+
};
|