@poe-platform/safe-bash 0.1.64 → 0.1.66

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.
@@ -10168,6 +10168,15 @@ var Capture = class {
10168
10168
  }
10169
10169
  return bytes2;
10170
10170
  }
10171
+ takeBytes() {
10172
+ const chunk = this.chunks.length === 1 ? this.chunks[0] : void 0;
10173
+ const bytes2 = chunk && chunk.byteLength === chunk.buffer.byteLength ? chunk : this.bytes();
10174
+ this.chunks.length = 0;
10175
+ this.length = 0;
10176
+ this.#tail = void 0;
10177
+ this.#tailLength = 0;
10178
+ return bytes2;
10179
+ }
10171
10180
  };
10172
10181
  var typedSavedVariables = /* @__PURE__ */ new WeakMap();
10173
10182
  var valueScope = /* @__PURE__ */ Symbol("shell value allocation scope");
@@ -15633,8 +15642,8 @@ shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
15633
15642
  });
15634
15643
  else await stdin?.close();
15635
15644
  }
15636
- const stdoutBytes = stdout.bytes();
15637
- const stderrBytes = stderr.bytes();
15645
+ const stdoutBytes = stdout.takeBytes();
15646
+ const stderrBytes = stderr.takeBytes();
15638
15647
  return {
15639
15648
  stdout: new TextDecoder("utf-8", { ignoreBOM: true }).decode(stdoutBytes),
15640
15649
  stderr: new TextDecoder("utf-8", { ignoreBOM: true }).decode(stderrBytes),
@@ -17240,9 +17249,16 @@ async function execute(program, context, files, quiet, budget) {
17240
17249
  }
17241
17250
  break;
17242
17251
  }
17243
- case "y":
17244
- pattern = [...pattern].map((character) => instruction.translation.get(character) ?? character).join("");
17252
+ case "y": {
17253
+ budget.step(pattern.length);
17254
+ const translated = import_buffer.Buffer.allocUnsafe(pattern.length);
17255
+ for (let index = 0; index < pattern.length; index++) {
17256
+ if (index % 256 === 0) await budget.checkpoint();
17257
+ translated[index] = (instruction.translation.get(pattern[index]) ?? pattern[index]).charCodeAt(0);
17258
+ }
17259
+ pattern = translated.toString("latin1");
17245
17260
  break;
17261
+ }
17246
17262
  case "b":
17247
17263
  pc = instruction.jump;
17248
17264
  continue;