@travetto/worker
Advanced tools
Comparing version 0.6.6 to 0.6.7
@@ -11,4 +11,4 @@ { | ||
"dependencies": { | ||
"@travetto/base": "^0.6.7", | ||
"@travetto/exec": "^0.6.6", | ||
"@travetto/base": "^0.6.8", | ||
"@travetto/exec": "^0.6.7", | ||
"@types/generic-pool": "^3.1.9", | ||
@@ -36,4 +36,4 @@ "generic-pool": "^3.7.1" | ||
}, | ||
"version": "0.6.6", | ||
"gitHead": "c35fd3147d5c95e72f0a22d67124ff4d48da0878" | ||
"version": "0.6.7", | ||
"gitHead": "db85544d26a8e9f9932ccc314b88f113fafbdee5" | ||
} |
import { InputSource } from './types'; | ||
function isIterator<T>(o: any): o is Iterator<T> { | ||
type Itr<T> = Iterator<T> | AsyncIterator<T>; | ||
function isIterator<T>(o: any): o is Itr<T> { | ||
return 'next' in o; | ||
@@ -9,7 +11,7 @@ } | ||
private src: Iterator<X>; | ||
private src: Itr<X>; | ||
private ondeck: X; | ||
done = false; | ||
constructor(src: (() => Iterator<X>) | Iterator<X>) { | ||
constructor(src: (() => Itr<X>) | Itr<X>) { | ||
if (isIterator(src)) { | ||
@@ -22,4 +24,4 @@ this.src = src; | ||
private primeNext() { | ||
const res = this.src.next(); | ||
private async primeNext() { | ||
const res = await this.src.next(); | ||
this.done = res.done; | ||
@@ -29,5 +31,5 @@ this.ondeck = res.value; | ||
hasNext() { | ||
async hasNext() { | ||
if (this.ondeck === undefined) { | ||
this.primeNext(); | ||
await this.primeNext(); | ||
} | ||
@@ -37,4 +39,4 @@ return !this.done; | ||
next() { | ||
this.hasNext(); | ||
async next() { | ||
await this.hasNext(); | ||
@@ -41,0 +43,0 @@ const out = this.ondeck; |
export interface InputSource<X> { | ||
hasNext(): boolean; | ||
hasNext(): boolean | Promise<boolean>; | ||
next(): X | Promise<X>; | ||
} |
@@ -92,3 +92,3 @@ import * as os from 'os'; | ||
while (src.hasNext()) { | ||
while (await src.hasNext()) { | ||
const worker = (await this.pool.acquire())!; | ||
@@ -95,0 +95,0 @@ const nextInput = await src.next(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18921
439
Updated@travetto/base@^0.6.8
Updated@travetto/exec@^0.6.7