@ai-sdk/provider-utils 4.0.0-beta.36 → 4.0.0-beta.38

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
@@ -77,6 +77,53 @@ function createAbortError() {
77
77
  return new DOMException("Delay was aborted", "AbortError");
78
78
  }
79
79
 
80
+ // src/delayed-promise.ts
81
+ var DelayedPromise = class {
82
+ constructor() {
83
+ this.status = { type: "pending" };
84
+ this._resolve = void 0;
85
+ this._reject = void 0;
86
+ }
87
+ get promise() {
88
+ if (this._promise) {
89
+ return this._promise;
90
+ }
91
+ this._promise = new Promise((resolve2, reject) => {
92
+ if (this.status.type === "resolved") {
93
+ resolve2(this.status.value);
94
+ } else if (this.status.type === "rejected") {
95
+ reject(this.status.error);
96
+ }
97
+ this._resolve = resolve2;
98
+ this._reject = reject;
99
+ });
100
+ return this._promise;
101
+ }
102
+ resolve(value) {
103
+ var _a;
104
+ this.status = { type: "resolved", value };
105
+ if (this._promise) {
106
+ (_a = this._resolve) == null ? void 0 : _a.call(this, value);
107
+ }
108
+ }
109
+ reject(error) {
110
+ var _a;
111
+ this.status = { type: "rejected", error };
112
+ if (this._promise) {
113
+ (_a = this._reject) == null ? void 0 : _a.call(this, error);
114
+ }
115
+ }
116
+ isResolved() {
117
+ return this.status.type === "resolved";
118
+ }
119
+ isRejected() {
120
+ return this.status.type === "rejected";
121
+ }
122
+ isPending() {
123
+ return this.status.type === "pending";
124
+ }
125
+ };
126
+
80
127
  // src/extract-response-headers.ts
81
128
  function extractResponseHeaders(response) {
82
129
  return Object.fromEntries([...response.headers]);
@@ -216,7 +263,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
216
263
  }
217
264
 
218
265
  // src/version.ts
219
- var VERSION = true ? "4.0.0-beta.36" : "0.0.0-test";
266
+ var VERSION = true ? "4.0.0-beta.38" : "0.0.0-test";
220
267
 
221
268
  // src/get-from-api.ts
222
269
  var getOriginalFetch = () => globalThis.fetch;
@@ -2362,6 +2409,7 @@ import {
2362
2409
  EventSourceParserStream as EventSourceParserStream2
2363
2410
  } from "eventsource-parser/stream";
2364
2411
  export {
2412
+ DelayedPromise,
2365
2413
  EventSourceParserStream2 as EventSourceParserStream,
2366
2414
  VERSION,
2367
2415
  asSchema,