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.
Files changed (2) hide show
  1. package/dist/owner.js +8 -21
  2. 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 headerEnd = rest.indexOf("\r\n\r\n");
575
- if (headerEnd === -1) {
574
+ const newline = rest.indexOf("\n");
575
+ if (newline === -1) {
576
576
  return { bodies, rest };
577
577
  }
578
- const header = rest.subarray(0, headerEnd).toString("utf8");
579
- const match = /Content-Length: (\d+)/i.exec(header);
580
- if (match === null) {
581
- return { bodies, rest: Buffer.alloc(0) };
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(body));
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
- const body = Buffer.from(JSON.stringify(message), "utf8");
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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poddrill",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Transcribe episode audio into timed text, group the voices, and store a summary.",
5
5
  "license": "MIT",
6
6
  "author": "Jianyu Zhao",