@types/k6 0.53.0 → 0.53.1

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.
k6/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for k6 (https://grafana.com/docs/k6/lates
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 13 Aug 2024 10:38:02 GMT
11
+ * Last updated: Fri, 23 Aug 2024 08:10:16 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -0,0 +1,198 @@
1
+ /**
2
+ * This module provides an experimental implementation of the Streams API
3
+ * for k6.
4
+ *
5
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/
6
+ */
7
+
8
+ /**
9
+ * The ReadableStream object provides the API for creating and managing readable
10
+ * streams of raw data, bit by bit, as soon as it is available, without needing to generate a buffer, string, or blob.
11
+ */
12
+ export class ReadableStream {
13
+ /**
14
+ * The ReadableStream constructor returns a newly created ReadableStream object.
15
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/
16
+ *
17
+ * @param underlyingSource - defines the source of data for the stream.
18
+ * @param queuingStrategy - defines the queuing strategy to adopt for the stream.
19
+ */
20
+ constructor(underlyingSource?: UnderlyingSource, queuingStrategy?: QueuingStrategy);
21
+
22
+ /**
23
+ * Closes the stream and signals a reason for the closure.
24
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/cancel/
25
+ *
26
+ * Used when you’ve completely finished with the stream and don’t need any more data from it,
27
+ * even if chunks are enqueued waiting to be read.
28
+ *
29
+ * That data is lost after cancel is called, and the stream is not readable anymore.
30
+ * To close the stream without getting rid of enqueued chunks, use `ReadableStreamDefaultController.close()`.
31
+ *
32
+ * It returns a promise that is resolved with `undefined` when the stream is canceled.
33
+ *
34
+ * @param reason - the reason for canceling the stream.
35
+ */
36
+ cancel(reason: any): Promise<void>;
37
+
38
+ /**
39
+ * Creates a reader and locks the stream to it.
40
+ * While the stream is locked, no other reader can be acquired until this one is released.
41
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/getreader/
42
+ */
43
+ getReader(): ReadableStreamDefaultReader;
44
+ }
45
+
46
+ /**
47
+ * The object that defines the source of data for the stream.
48
+ */
49
+ export interface UnderlyingSource {
50
+ /**
51
+ * Called when the stream is created.
52
+ * It can be used to perform any setup tasks.
53
+ * The content of this method is to be defined by the user.
54
+ */
55
+ start?: (controller: ReadableStreamDefaultController) => void | Promise<void>;
56
+
57
+ /**
58
+ * Called repeatedly to fetch and queue data into the stream,
59
+ * until it reaches its high watermark.
60
+ * If `pull()` returns a promise, it won’t be called again until the promise is resolved.
61
+ */
62
+ pull?: (controller: ReadableStreamDefaultController) => void | Promise<void>;
63
+
64
+ /**
65
+ * Called when the stream is canceled.
66
+ * It can be used to release access to the stream source and perform any cleanup tasks.
67
+ * The reason parameter passed to this method is an optional human-readable value
68
+ * that represents the reason for canceling the stream.
69
+ */
70
+ cancel?: (reason?: any) => void | Promise<void>;
71
+
72
+ /**
73
+ * Specifies the type of the underlying source.
74
+ * It can currently only receive the value 'default' which is its default value.
75
+ */
76
+ type?: "default";
77
+ }
78
+
79
+ /**
80
+ * The object that allows the user to control a ReadableStream’s state and internal queue.
81
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultcontroller/
82
+ */
83
+ export interface ReadableStreamDefaultController {
84
+ /**
85
+ * Closes the associated stream.
86
+ * Readers can still read any previously enqueued chunks from the stream.
87
+ * Once those chunks are read, the stream closes, and no more data is available.
88
+ */
89
+ close: () => void;
90
+
91
+ /**
92
+ * Enqueues a chunk of data into the associated stream.
93
+ */
94
+ enqueue: (chunk: any) => void;
95
+
96
+ /**
97
+ * Makes any future interactions with the associated stream to error.
98
+ */
99
+ error: (reason: any) => void;
100
+ }
101
+
102
+ /**
103
+ * The object that defines the queuing strategy to adopt for the stream.
104
+ *
105
+ * Although the user can define a custom queueing strategy, the default behavior and recommended way
106
+ * to use the `ReadableStream` is to use a `CountQueuingStrategy` object.
107
+ */
108
+ export interface QueuingStrategy {
109
+ /**
110
+ * Represents the maximum number of chunks that the stream can hold in its internal queue.
111
+ * The default value is 1.
112
+ */
113
+ highWaterMark?: number;
114
+
115
+ /**
116
+ * Returns the size of the chunk passed as an argument.
117
+ * The default value is a function that returns 1.
118
+ */
119
+ size?(chunk: any): number;
120
+ }
121
+
122
+ /**
123
+ * The CountQueuingStrategy object is the default QueuingStrategy for ReadableStream.
124
+ * It counts the number of chunks in the queue.
125
+ */
126
+ export class CountQueuingStrategy {
127
+ /**
128
+ * The CountQueuingStrategy constructor returns a newly created CountQueuingStrategy object.
129
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestream/countqueuingstrategy/
130
+ *
131
+ * @param options - an object with optional property `highWaterMark` that determines
132
+ * the maximum number of chunks that the queue can contain.
133
+ */
134
+ constructor(options?: { highWaterMark?: number });
135
+
136
+ /**
137
+ * Represents the maximum number of chunks that the stream can hold in its internal queue.
138
+ * The default value is 1.
139
+ */
140
+ readonly highWaterMark: number;
141
+
142
+ /**
143
+ * Returns the size of the chunk passed as an argument.
144
+ * The default value is a function that returns 1.
145
+ */
146
+ size(chunk: any): number;
147
+ }
148
+
149
+ /**
150
+ * The object used to read stream data.
151
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/
152
+ */
153
+ export class ReadableStreamDefaultReader {
154
+ /**
155
+ * The ReadableStreamDefaultReader constructor returns a newly created ReadableStreamDefaultReader object.
156
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/
157
+ *
158
+ * @param stream - defines the stream the reader will own.
159
+ */
160
+ constructor(stream: ReadableStream);
161
+
162
+ /**
163
+ * Closes the reader and signals a reason for the closure.
164
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/cancel/
165
+ *
166
+ * Used when you’ve completely finished with the stream and don’t need any more data from it,
167
+ * even if chunks are enqueued waiting to be read.
168
+ * That data is lost after cancel is called, and the stream is not readable anymore.
169
+ * To close the stream without getting rid of enqueued chunks, use `ReadableStreamDefaultController.close()`.
170
+ *
171
+ * It returns a promise that is resolved with `undefined` when the stream is canceled.
172
+ *
173
+ * @param reason - the reason for canceling the stream.
174
+ */
175
+ cancel(reason: any): Promise<void>;
176
+
177
+ /**
178
+ * Returns a promise providing access to the next chunk in the stream’s internal queue.
179
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/read/
180
+ *
181
+ * - If the stream is closed and no more data is available, the promise resolves with an object of the form:
182
+ * `{ done: true, value: undefined }`.
183
+ * - If the stream is errored, the promise rejects with the error that caused the stream to error.
184
+ */
185
+ read(): Promise<{ done: false; value: any } | { done: true; value: undefined }>;
186
+
187
+ /**
188
+ * Releases the reader’s lock on the stream.
189
+ * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/streams/readablestreamdefaultreader/releaselock/
190
+ *
191
+ * If the associated stream is errored as the lock is released, the reader will be errored as well.
192
+ * This method is useful when done with the stream and want to release the lock on it.
193
+ *
194
+ * If the reader’s lock is released as pending read operations are still in progress,
195
+ * the reader’s `ReadableStreamDefaultReader.read()` calls are immediately rejected with a `TypeError`.
196
+ */
197
+ readonly releaseLock: () => void;
198
+ }
@@ -1,4 +1,5 @@
1
1
  import { CookieJar } from "../http";
2
+ import { ReadableStream } from "./streams";
2
3
 
3
4
  /**
4
5
  * This module provides an experimental implementation of the WebSocket API
@@ -139,6 +140,7 @@ export class Blob {
139
140
  arrayBuffer(): Promise<ArrayBuffer>;
140
141
  bytes(): Promise<Uint8Array>;
141
142
  slice(start?: number, end?: number): Blob;
143
+ stream(): ReadableStream;
142
144
  text(): Promise<string>;
143
145
  }
144
146
 
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.53.0",
3
+ "version": "0.53.1",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -60,6 +60,6 @@
60
60
  },
61
61
  "scripts": {},
62
62
  "dependencies": {},
63
- "typesPublisherContentHash": "92a8bee7b16799f1931e143dd216dc6b86d2f2e8c322c82b6c5c68090b18d592",
63
+ "typesPublisherContentHash": "51f2f592838cc27d3b1784aa8140db6d7c0e256577c0d8f960419afa871ee531",
64
64
  "typeScriptVersion": "4.8"
65
65
  }