@fbltd/async 1.0.11 → 1.0.12
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/bin/dependency-stream/utils/index.js +17 -5
- package/dist/bin/dependency-stream/utils/next.js +7 -0
- package/dist/bin/dependency-stream/utils/once.stream.js +28 -0
- package/dist/types/dependency-stream/contracts.d.ts +9 -1
- package/dist/types/dependency-stream/utils/index.d.ts +3 -2
- package/dist/types/dependency-stream/utils/next.d.ts +2 -0
- package/dist/types/dependency-stream/utils/once.stream.d.ts +3 -0
- package/package.json +1 -1
- package/dist/bin/dependency-stream/utils/once.js +0 -19
- package/dist/types/dependency-stream/utils/once.d.ts +0 -9
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var race_stream_1 = require("./race.stream");
|
|
7
|
-
Object.defineProperty(exports, "raceStream", { enumerable: true, get: function () { return race_stream_1.raceStream; } });
|
|
17
|
+
__exportStar(require("./once.stream"), exports);
|
|
18
|
+
__exportStar(require("./race.stream"), exports);
|
|
19
|
+
__exportStar(require("./next"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onceStream = onceStream;
|
|
4
|
+
const get_promise_1 = require("../../get-promise");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
function onceStream(dep) {
|
|
7
|
+
const externalDispose = (0, get_promise_1.getPromise)();
|
|
8
|
+
const iterator = dep[constants_1.symAI]({ externalDispose });
|
|
9
|
+
function isDisposed() {
|
|
10
|
+
return externalDispose.isFulfilled || iterator.isDisposed;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
get isDisposed() {
|
|
14
|
+
return isDisposed();
|
|
15
|
+
},
|
|
16
|
+
dispose: externalDispose.resolve,
|
|
17
|
+
[constants_1.symAI]() {
|
|
18
|
+
return {
|
|
19
|
+
next: async () => {
|
|
20
|
+
const result = await iterator.next();
|
|
21
|
+
if (!isDisposed())
|
|
22
|
+
externalDispose.resolve();
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -2,9 +2,17 @@ export interface IIteratorOwner<TValue = any> {
|
|
|
2
2
|
value: TValue;
|
|
3
3
|
dispose(): void;
|
|
4
4
|
}
|
|
5
|
+
export type IStreamReturn = void;
|
|
6
|
+
export type IStreamIteratorReturn = IteratorReturnResult<IStreamReturn>;
|
|
7
|
+
export type IStreamIteratorYield<T> = IteratorYieldResult<T>;
|
|
5
8
|
export interface IStreamIterator<TValue = any> {
|
|
6
9
|
owner: IIteratorOwner<TValue>;
|
|
7
10
|
dispose(): void;
|
|
8
11
|
readonly isDisposed: boolean;
|
|
9
|
-
next(): Promise<IteratorResult<TValue,
|
|
12
|
+
next(): Promise<IteratorResult<TValue, IStreamReturn>>;
|
|
13
|
+
}
|
|
14
|
+
export interface IStreamOwner<TValue = any> {
|
|
15
|
+
dispose(): void;
|
|
16
|
+
readonly isDisposed: boolean;
|
|
17
|
+
[Symbol.asyncIterator](): AsyncIterator<TValue, IStreamReturn>;
|
|
10
18
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from "./once.stream";
|
|
2
|
+
export * from "./race.stream";
|
|
3
|
+
export * from "./next";
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.once = once;
|
|
4
|
-
function once(dep) {
|
|
5
|
-
let isIterationWas = false;
|
|
6
|
-
const iterator = dep[Symbol.asyncIterator]();
|
|
7
|
-
return {
|
|
8
|
-
[Symbol.asyncIterator]() {
|
|
9
|
-
return {
|
|
10
|
-
next: async () => {
|
|
11
|
-
if (isIterationWas)
|
|
12
|
-
return { done: true };
|
|
13
|
-
return iterator.next();
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
},
|
|
17
|
-
dispose: iterator.dispose,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DependencyStream } from "../dependency-stream";
|
|
2
|
-
export declare function once(dep: DependencyStream): {
|
|
3
|
-
[Symbol.asyncIterator](): {
|
|
4
|
-
next: () => Promise<IteratorYieldResult<any> | IteratorReturnResult<void> | {
|
|
5
|
-
done: boolean;
|
|
6
|
-
}>;
|
|
7
|
-
};
|
|
8
|
-
dispose: () => void;
|
|
9
|
-
};
|