@xsai/utils-stream 0.3.2 → 0.3.4
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.d.ts +2 -3
- package/dist/index.js +5 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ interface SmoothStreamOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
declare const smoothStream: ({ chunking, delay }?: SmoothStreamOptions) => TransformStream<string, string>;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
declare function toAsyncIterator<T>(stream: ReadableStream<T>): AsyncGenerator<T, void, unknown>;
|
|
19
|
+
declare function readableStreamToAsyncIterator<T>(res: ReadableStream<T>): AsyncGenerator<T, void, unknown>;
|
|
21
20
|
|
|
22
|
-
export { type SimulateReadableStreamOptions, type SmoothStreamOptions, simulateReadableStream, smoothStream, toAsyncIterator };
|
|
21
|
+
export { type SimulateReadableStreamOptions, type SmoothStreamOptions, simulateReadableStream, smoothStream, readableStreamToAsyncIterator as toAsyncIterator };
|
package/dist/index.js
CHANGED
|
@@ -34,13 +34,14 @@ const smoothStream = ({ chunking = "word", delay = 10 } = {}) => {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
async function*
|
|
38
|
-
const reader =
|
|
37
|
+
async function* readableStreamToAsyncIterator(res) {
|
|
38
|
+
const reader = res.getReader();
|
|
39
39
|
try {
|
|
40
40
|
while (true) {
|
|
41
41
|
const { done, value } = await reader.read();
|
|
42
|
-
if (done)
|
|
42
|
+
if (done) {
|
|
43
43
|
return;
|
|
44
|
+
}
|
|
44
45
|
yield value;
|
|
45
46
|
}
|
|
46
47
|
} finally {
|
|
@@ -48,4 +49,4 @@ async function* toAsyncIterator(stream) {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
export { simulateReadableStream, smoothStream, toAsyncIterator };
|
|
52
|
+
export { simulateReadableStream, smoothStream, readableStreamToAsyncIterator as toAsyncIterator };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsai/utils-stream",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"description": "extra-small AI SDK.",
|
|
6
6
|
"author": "Moeru AI",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@moeru/std": "^0.1.0-beta.
|
|
32
|
+
"@moeru/std": "^0.1.0-beta.7"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "pkgroll"
|