sprucehttp_sjs 1.0.10 → 1.0.11
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.
- package/index.js +21 -7
- package/package.json +2 -5
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This is still CommonJS to support both the old and new versions of the module system.
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
@@ -57,11 +57,25 @@ module.exports = {
|
|
|
57
57
|
* @param {string | Buffer} data The data to send.
|
|
58
58
|
*/
|
|
59
59
|
writeDataAsync: function (data) {
|
|
60
|
-
return new Promise(function (resolve) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
return new Promise(async function (resolve) {
|
|
61
|
+
// Send the data in 1 MiB chunks
|
|
62
|
+
const chunkSize = 1024 * 1024;
|
|
63
|
+
// Split the data into chunks
|
|
64
|
+
let chunks = [];
|
|
65
|
+
const data2 = Buffer.from(data);
|
|
66
|
+
for (let i = 0; i < data2.length; i += chunkSize) {
|
|
67
|
+
chunks.push(data2.subarray(i, i + chunkSize));
|
|
68
|
+
}
|
|
69
|
+
// Send all chunks
|
|
70
|
+
for (const chunk of chunks) {
|
|
71
|
+
await new Promise(function (resolve2) {
|
|
72
|
+
process.send({
|
|
73
|
+
type: "data",
|
|
74
|
+
data: chunk
|
|
75
|
+
}, resolve2);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
resolve();
|
|
65
79
|
});
|
|
66
80
|
},
|
|
67
81
|
|
|
@@ -185,7 +199,7 @@ module.exports = {
|
|
|
185
199
|
/**
|
|
186
200
|
* Returns the body of the request as an fs.ReadStream.
|
|
187
201
|
*
|
|
188
|
-
* @param {
|
|
202
|
+
* @param {BufferEncoding | ReadStreamOptions} [options] The options to pass to fs.createReadStream.
|
|
189
203
|
* @returns {fs.ReadStream} A ReadStream of the body of the request.
|
|
190
204
|
*/
|
|
191
205
|
bodyStream: function (options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprucehttp_sjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "A module for responding to requests within SpruceHTTP in an SJS file",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,8 +23,5 @@
|
|
|
23
23
|
"email": "herronjo@stibarc.dev",
|
|
24
24
|
"url": "https://stibarc.dev"
|
|
25
25
|
},
|
|
26
|
-
"license": "Copyright (c) STiBaRC LLC. All rights reserved."
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"sprucehttp_sjs": "file:"
|
|
29
|
-
}
|
|
26
|
+
"license": "Copyright (c) STiBaRC LLC. All rights reserved."
|
|
30
27
|
}
|