diff --git a/README.md b/README.md index 7cfcb93b9d924cc08df47d57625dc228bd704f6b..cdd07586a73e4fe45a7b945006a3b6ff1f3e1027 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## Module Overview -- `mol-comp` Computation abstraction with progress tracking and cancellation support. +- `mol-task` Computation abstraction with progress tracking and cancellation support. - `mol-data` Collections (integer based sets, inteface to columns/tables, etc.) - `mol-math` Math related (loosely) algorithms and data structures. - `mol-io` Parsing library. Each format is parsed into an interface that corresponds to the data stored by it. diff --git a/src/mol-comp/computation.ts b/src/mol-task/computation.ts similarity index 100% rename from src/mol-comp/computation.ts rename to src/mol-task/computation.ts diff --git a/src/mol-comp/context.ts b/src/mol-task/context.ts similarity index 100% rename from src/mol-comp/context.ts rename to src/mol-task/context.ts diff --git a/src/mol-comp/index.ts b/src/mol-task/index.ts similarity index 100% rename from src/mol-comp/index.ts rename to src/mol-task/index.ts diff --git a/src/mol-comp/scheduler.ts b/src/mol-task/scheduler.ts similarity index 100% rename from src/mol-comp/scheduler.ts rename to src/mol-task/scheduler.ts diff --git a/src/mol-comp/time.ts b/src/mol-task/time.ts similarity index 100% rename from src/mol-comp/time.ts rename to src/mol-task/time.ts diff --git a/src/mol-comp/util.ts b/src/mol-task/util.ts similarity index 100% rename from src/mol-comp/util.ts rename to src/mol-task/util.ts diff --git a/src/perf-tests/structure.ts b/src/perf-tests/structure.ts index 4cb8ce453da97a58ff2b63ead4de33a5302d4b71..c996b85c9a53c8a8ca89dc35885574b9d967a501 100644 --- a/src/perf-tests/structure.ts +++ b/src/perf-tests/structure.ts @@ -29,15 +29,21 @@ async function readData(path: string) { } } -function *test() { - yield 10; - return 15; +(Symbol as any).asyncIterator = (Symbol as any).asyncIterator || Symbol.for('Symbol.asyncIterator'); + +interface ProgressGenerator<T> extends AsyncIterableIterator<number | T> { + next(cont?: boolean): Promise<IteratorResult<number | T>> +} + +async function *test(): ProgressGenerator<boolean> { + const r = yield await new Promise<number>(res => res(10)); + return r; } -async function runIt<T>(itP: () => IterableIterator<T>) { +async function runIt(itP: () => ProgressGenerator<boolean>) { const it = itP(); while (true) { - const { value, done } = it.next(); + const { value, done } = await it.next(true); if (done) return value; } } diff --git a/tsconfig.json b/tsconfig.json index b86472f6a8c056804790ac6851f83cd9f0ef1bc9..2a05ce80fe9c8ec062c73e278f08c50915a92e5e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "strictNullChecks": true, "strictFunctionTypes": true, //"downlevelIteration": true, - "lib": [ "es6", "dom" ], + "lib": [ "es6", "dom", "esnext.asynciterable" ], "outDir": "build/node_modules", "baseUrl": "src", "paths": {