@fbltd/async 1.0.17 → 1.0.18
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/README.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { symAI } from "../../constants.js";
|
|
2
|
-
|
|
3
|
-
export async function next(dep) {
|
|
4
|
-
const res = await dep[symAI]().next();
|
|
5
|
-
if (res.done) {
|
|
6
|
-
throw StreamFinishError;
|
|
7
|
-
}
|
|
8
|
-
return res.value;
|
|
9
|
-
}
|
|
2
|
+
import { PromiseConfiguration } from "../../promise-configuration.js";
|
|
10
3
|
/**
|
|
11
4
|
* @internal
|
|
12
5
|
*/
|
|
13
|
-
export const
|
|
6
|
+
export const StreamFinishError = new Error("Stream is done");
|
|
7
|
+
export function next(dep) {
|
|
8
|
+
const disposePromise = new PromiseConfiguration();
|
|
9
|
+
const resultPromise = new PromiseConfiguration();
|
|
10
|
+
dep[symAI]({ externalDispose: disposePromise })
|
|
11
|
+
.next()
|
|
12
|
+
.then((res) => {
|
|
13
|
+
if (res.done)
|
|
14
|
+
resultPromise.reject(StreamFinishError);
|
|
15
|
+
else
|
|
16
|
+
resultPromise.resolve(res.value);
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
promise: resultPromise.promise,
|
|
20
|
+
dispose: () => disposePromise.resolve()
|
|
21
|
+
};
|
|
22
|
+
}
|