@ai-sdk/provider-utils 3.0.36 → 3.0.37

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,13 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 3.0.37
4
+
5
+ ### Patch Changes
6
+
7
+ - ab3990f: fix(provider-utils): avoid excessive memory usage when base64 encoding byte arrays
8
+ - Updated dependencies [c2089a9]
9
+ - @ai-sdk/provider@2.0.4
10
+
3
11
  ## 3.0.36
4
12
 
5
13
  ### Patch Changes
package/dist/index.js CHANGED
@@ -811,7 +811,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
811
811
  }
812
812
 
813
813
  // src/version.ts
814
- var VERSION = true ? "3.0.36" : "0.0.0-test";
814
+ var VERSION = true ? "3.0.37" : "0.0.0-test";
815
815
 
816
816
  // src/get-from-api.ts
817
817
  var getOriginalFetch = () => globalThis.fetch;
@@ -3003,11 +3003,12 @@ function convertBase64ToUint8Array(base64String) {
3003
3003
  return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
3004
3004
  }
3005
3005
  function convertUint8ArrayToBase64(array) {
3006
- let latin1string = "";
3007
- for (let i = 0; i < array.length; i++) {
3008
- latin1string += String.fromCodePoint(array[i]);
3006
+ const chunks = [];
3007
+ const chunkSize = 4096;
3008
+ for (let i = 0; i < array.length; i += chunkSize) {
3009
+ chunks.push(String.fromCodePoint(...array.subarray(i, i + chunkSize)));
3009
3010
  }
3010
- return btoa(latin1string);
3011
+ return btoa(chunks.join(""));
3011
3012
  }
3012
3013
  function convertToBase64(value) {
3013
3014
  return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;