web-streams-polyfill 4.0.0-beta.3 → 4.1.0

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.
@@ -1,34 +1,22 @@
1
- /// <reference lib="es2018.asynciterable" />
2
-
3
1
  /**
4
2
  * A signal object that allows you to communicate with a request and abort it if required
5
3
  * via its associated `AbortController` object.
6
4
  *
7
5
  * @remarks
8
- * This interface is compatible with the `AbortSignal` interface defined in TypeScript's DOM types.
9
- * It is redefined here, so it can be polyfilled without a DOM, for example with
10
- * {@link https://www.npmjs.com/package/abortcontroller-polyfill | abortcontroller-polyfill} in a Node environment.
6
+ * This is equivalent to the `AbortSignal` interface defined in TypeScript's DOM types or `@types/node`.
11
7
  *
12
8
  * @public
13
9
  */
14
- export declare interface AbortSignal {
15
- /**
16
- * Whether the request is aborted.
17
- */
18
- readonly aborted: boolean;
19
- /**
20
- * The abort reason.
21
- */
10
+ export declare type AbortSignal = typeof globalThis extends {
11
+ AbortSignal: {
12
+ prototype: infer T;
13
+ };
14
+ } ? T : {
15
+ aborted: boolean;
22
16
  readonly reason?: any;
23
- /**
24
- * Add an event listener to be triggered when this signal becomes aborted.
25
- */
26
17
  addEventListener(type: 'abort', listener: () => void): void;
27
- /**
28
- * Remove an event listener that was previously added with {@link AbortSignal.addEventListener}.
29
- */
30
18
  removeEventListener(type: 'abort', listener: () => void): void;
31
- }
19
+ };
32
20
 
33
21
  /**
34
22
  * A queuing strategy that counts the number of bytes in each chunk.
@@ -134,7 +122,7 @@ export declare class ReadableByteStreamController {
134
122
  *
135
123
  * @public
136
124
  */
137
- export declare class ReadableStream<R = any> {
125
+ export declare class ReadableStream<R = any> implements AsyncIterable<R> {
138
126
  constructor(underlyingSource: UnderlyingByteSource, strategy?: {
139
127
  highWaterMark?: number;
140
128
  size?: undefined;
@@ -218,7 +206,14 @@ export declare class ReadableStream<R = any> {
218
206
  /**
219
207
  * {@inheritDoc ReadableStream.values}
220
208
  */
221
- [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator<R>;
209
+ [Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
210
+ /**
211
+ * Creates a new ReadableStream wrapping the provided iterable or async iterable.
212
+ *
213
+ * This can be used to adapt various kinds of objects into a readable stream,
214
+ * such as an array, an async generator, or a Node.js readable stream.
215
+ */
216
+ static from<R>(asyncIterable: Iterable<R> | AsyncIterable<R> | ReadableStreamLike<R>): ReadableStream<R>;
222
217
  }
223
218
 
224
219
  /**
@@ -226,7 +221,7 @@ export declare class ReadableStream<R = any> {
226
221
  *
227
222
  * @public
228
223
  */
229
- export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
224
+ export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterableIterator<R> {
230
225
  next(): Promise<IteratorResult<R, undefined>>;
231
226
  return(value?: any): Promise<IteratorResult<any>>;
232
227
  }
@@ -252,7 +247,7 @@ export declare class ReadableStreamBYOBReader {
252
247
  *
253
248
  * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
254
249
  */
255
- read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamBYOBReadResult<T>>;
250
+ read<T extends ArrayBufferView>(view: T, options?: ReadableStreamBYOBReaderReadOptions): Promise<ReadableStreamBYOBReadResult<T>>;
256
251
  /**
257
252
  * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
258
253
  * If the associated stream is errored when the lock is released, the reader will appear errored in the same way
@@ -265,6 +260,16 @@ export declare class ReadableStreamBYOBReader {
265
260
  releaseLock(): void;
266
261
  }
267
262
 
263
+ /**
264
+ * Options for {@link ReadableStreamBYOBReader.read | reading} a stream
265
+ * with a {@link ReadableStreamBYOBReader | BYOB reader}.
266
+ *
267
+ * @public
268
+ */
269
+ export declare interface ReadableStreamBYOBReaderReadOptions {
270
+ min?: number;
271
+ }
272
+
268
273
  /**
269
274
  * A result returned by {@link ReadableStreamBYOBReader.read}.
270
275
  *
@@ -368,6 +373,18 @@ export declare class ReadableStreamDefaultReader<R = any> {
368
373
  releaseLock(): void;
369
374
  }
370
375
 
376
+ /**
377
+ * A common interface for a `ReadableStreamDefaultReader` implementation.
378
+ *
379
+ * @public
380
+ */
381
+ export declare interface ReadableStreamDefaultReaderLike<R = any> {
382
+ readonly closed: Promise<undefined>;
383
+ cancel(reason?: any): Promise<void>;
384
+ read(): Promise<ReadableStreamDefaultReadResult<R>>;
385
+ releaseLock(): void;
386
+ }
387
+
371
388
  /**
372
389
  * A result returned by {@link ReadableStreamDefaultReader.read}.
373
390
  *
@@ -390,6 +407,16 @@ export declare interface ReadableStreamIteratorOptions {
390
407
  preventCancel?: boolean;
391
408
  }
392
409
 
410
+ /**
411
+ * A common interface for a `ReadadableStream` implementation.
412
+ *
413
+ * @public
414
+ */
415
+ export declare interface ReadableStreamLike<R = any> {
416
+ readonly locked: boolean;
417
+ getReader(): ReadableStreamDefaultReaderLike<R>;
418
+ }
419
+
393
420
  /**
394
421
  * A pair of a {@link ReadableStream | readable stream} and {@link WritableStream | writable stream} that can be passed
395
422
  * to {@link ReadableStream.pipeThrough}.
@@ -447,10 +474,17 @@ export declare interface Transformer<I = any, O = any> {
447
474
  * through {@link Transformer.transform | transform()}, and the writable side is about to be closed.
448
475
  */
449
476
  flush?: TransformerFlushCallback<O>;
477
+ /**
478
+ * A function called when the readable side is cancelled, or when the writable side is aborted.
479
+ */
480
+ cancel?: TransformerCancelCallback;
450
481
  readableType?: undefined;
451
482
  writableType?: undefined;
452
483
  }
453
484
 
485
+ /** @public */
486
+ export declare type TransformerCancelCallback = (reason: any) => void | PromiseLike<void>;
487
+
454
488
  /** @public */
455
489
  export declare type TransformerFlushCallback<O> = (controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
456
490
 
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.21.2"
8
+ "packageVersion": "7.48.1"
9
9
  }
10
10
  ]
11
11
  }
package/es5/package.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "name": "web-streams-polyfill",
3
- "main": "../dist/ponyfill.es5.js",
4
- "module": "../dist/ponyfill.es5.mjs",
5
- "types": "../types/ponyfill.d.ts"
6
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "web-streams-polyfill",
3
- "main": "../../dist/polyfill.es5.js",
4
- "types": "../../types/polyfill.d.ts"
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "web-streams-polyfill",
3
- "main": "../dist/polyfill.js",
4
- "types": "../types/polyfill.d.ts"
5
- }