@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,5 +1,5 @@
1
1
  # Async tools
2
- R&D async tools tree-shakable ES module
2
+ Tree-shakable ES module with async tools.
3
3
 
4
4
  ## Installation
5
5
  You can install this package with your favorite package manager.<br/>
@@ -1,13 +1,22 @@
1
1
  import { symAI } from "../../constants.js";
2
- const StreamFinishError = new Error("Stream is done");
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 InternalStreamFinishError = StreamFinishError;
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
+ }
@@ -1,2 +1,5 @@
1
1
  import { Dependency } from "../dependency.ts";
2
- export declare function next<T>(dep: Dependency<T>): Promise<T>;
2
+ export declare function next<T>(dep: Dependency<T>): {
3
+ promise: Promise<T>;
4
+ dispose: () => void;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fbltd/async",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Miscellaneous async utils",
5
5
  "homepage": "https://github.com/GlennMiller1991/async",
6
6
  "type": "module",