poddrill 0.2.0 → 0.2.1
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/dist/owner.js +8 -21
- package/package.json +1 -1
package/dist/owner.js
CHANGED
|
@@ -571,28 +571,17 @@ function takeMessages(buffer) {
|
|
|
571
571
|
const bodies = [];
|
|
572
572
|
let rest = buffer;
|
|
573
573
|
for (;;) {
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
574
|
+
const newline = rest.indexOf("\n");
|
|
575
|
+
if (newline === -1) {
|
|
576
576
|
return { bodies, rest };
|
|
577
577
|
}
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
if (
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
const lengthText = match[1];
|
|
584
|
-
if (lengthText === undefined) {
|
|
585
|
-
return { bodies, rest: Buffer.alloc(0) };
|
|
586
|
-
}
|
|
587
|
-
const length = Number(lengthText);
|
|
588
|
-
const start = headerEnd + 4;
|
|
589
|
-
if (!Number.isInteger(length) || rest.length < start + length) {
|
|
590
|
-
return { bodies, rest };
|
|
578
|
+
const line = rest.subarray(0, newline).toString("utf8");
|
|
579
|
+
rest = Buffer.from(rest.subarray(newline + 1));
|
|
580
|
+
if (line.trim() === "") {
|
|
581
|
+
continue;
|
|
591
582
|
}
|
|
592
|
-
const body = rest.subarray(start, start + length).toString("utf8");
|
|
593
|
-
rest = Buffer.from(rest.subarray(start + length));
|
|
594
583
|
try {
|
|
595
|
-
bodies.push(JSON.parse(
|
|
584
|
+
bodies.push(JSON.parse(line));
|
|
596
585
|
}
|
|
597
586
|
catch {
|
|
598
587
|
bodies.push(undefined);
|
|
@@ -784,9 +773,7 @@ function toolList() {
|
|
|
784
773
|
];
|
|
785
774
|
}
|
|
786
775
|
function writeMessage(message) {
|
|
787
|
-
|
|
788
|
-
const header = Buffer.from(`Content-Length: ${body.length}\r\n\r\n`, "utf8");
|
|
789
|
-
process.stdout.write(Buffer.concat([header, body]));
|
|
776
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
790
777
|
}
|
|
791
778
|
function asRecord(value) {
|
|
792
779
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|