ai 4.0.21 → 4.0.23

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/index.mjs CHANGED
@@ -5192,11 +5192,11 @@ function smoothStream({
5192
5192
  return;
5193
5193
  }
5194
5194
  buffer += chunk.textDelta;
5195
- while (buffer.match(/\s/)) {
5196
- const whitespaceIndex = buffer.search(/\s/);
5197
- const word = buffer.slice(0, whitespaceIndex + 1);
5198
- controller.enqueue({ type: "text-delta", textDelta: word });
5199
- buffer = buffer.slice(whitespaceIndex + 1);
5195
+ const regexp = /\s*\S+\s+/m;
5196
+ while (regexp.test(buffer)) {
5197
+ const chunk2 = buffer.match(regexp)[0];
5198
+ controller.enqueue({ type: "text-delta", textDelta: chunk2 });
5199
+ buffer = buffer.slice(chunk2.length);
5200
5200
  if (delayInMs > 0) {
5201
5201
  await delay2(delayInMs);
5202
5202
  }