@ai-sdk/provider-utils 4.0.51 → 4.0.52

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.52
4
+
5
+ ### Patch Changes
6
+
7
+ - 82e18b0: fix(provider-utils): avoid excessive memory usage when base64 encoding byte arrays
8
+
3
9
  ## 4.0.51
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -271,11 +271,12 @@ function convertBase64ToUint8Array(base64String) {
271
271
  return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
272
272
  }
273
273
  function convertUint8ArrayToBase64(array) {
274
- let latin1string = "";
275
- for (let i = 0; i < array.length; i++) {
276
- latin1string += String.fromCodePoint(array[i]);
274
+ const chunks = [];
275
+ const chunkSize = 4096;
276
+ for (let i = 0; i < array.length; i += chunkSize) {
277
+ chunks.push(String.fromCodePoint(...array.subarray(i, i + chunkSize)));
277
278
  }
278
- return btoa(latin1string);
279
+ return btoa(chunks.join(""));
279
280
  }
280
281
  function convertToBase64(value) {
281
282
  return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
@@ -922,7 +923,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
922
923
  }
923
924
 
924
925
  // src/version.ts
925
- var VERSION = true ? "4.0.51" : "0.0.0-test";
926
+ var VERSION = true ? "4.0.52" : "0.0.0-test";
926
927
 
927
928
  // src/get-from-api.ts
928
929
  var getOriginalFetch = () => globalThis.fetch;