-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* minimal basic working refactor into TS * minimal basic working refactor into TS * looseAsyncIterWrapper func into TypeScript * bump minor version
- Loading branch information
Showing
53 changed files
with
1,483 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
spec: ./!(node_modules)/**/*.{spec,test}.js | ||
spec: ./!(node_modules)/**/*.{spec,test}.{ts,js} | ||
file: | ||
- ./src/spec/testsGlobalSetup.js | ||
watch-files: | ||
- ./src/**/*.ts | ||
- ./src/**/*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
{ | ||
"name": "multerator", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"repository": "https://github.com/shtaif/multerator", | ||
"engineStrict": true, | ||
"engines": { | ||
"node": ">=10.15.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "ts-mocha", | ||
"code-check": "yarn run test && tsc --noEmit" | ||
}, | ||
"files": [ | ||
"src/**/*", | ||
"!src/spec/**/*" | ||
"./dist" | ||
], | ||
"devDependencies": { | ||
"@tsconfig/node10": "^1.0.8", | ||
"@types/chai": "^4.2.21", | ||
"@types/chai-subset": "^1.3.3", | ||
"@types/mocha": "^8.2.3", | ||
"@types/node": "^16.3.3", | ||
"@typescript-eslint/eslint-plugin": "^4.28.3", | ||
"@typescript-eslint/parser": "^4.28.3", | ||
"chai": "^4.2.0", | ||
"chai-as-promised": "^7.1.1", | ||
"chai-subset": "^1.6.0", | ||
"dedent": "^0.7.0", | ||
"eslint": "^7.25.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-standard": "^16.0.3", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"mocha": "^8.1.3", | ||
"prettier": "^2.3.2" | ||
"prettier": "^2.3.2", | ||
"ts-mocha": "^8.0.0", | ||
"typescript": "^4.3.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export default allowOneActiveSubIterAtATime; | ||
|
||
async function* allowOneActiveSubIterAtATime<T>( | ||
source: AsyncIterable<AsyncIterable<T>> | ||
): AsyncGenerator<AsyncGenerator<T>, void, undefined> { | ||
let promise: Promise<void>; | ||
let resolve = noop; | ||
|
||
for await (const partIter of source) { | ||
promise = new Promise(_resolve => (resolve = _resolve)); | ||
|
||
const delayedPartIter = (async function* () { | ||
yield* partIter; | ||
resolve(); | ||
})(); | ||
|
||
yield delayedPartIter; | ||
|
||
await promise; | ||
} | ||
} | ||
|
||
const noop: Function = () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export default asyncIterWindowBetweenOccuranceOf; | ||
|
||
function asyncIterWindowBetweenOccuranceOf<VAL_T, SPLIT_MARK_T>( | ||
valueToSplitBy: SPLIT_MARK_T | ||
): ( | ||
src: AsyncIterable<VAL_T | SPLIT_MARK_T> | ||
) => AsyncGenerator<AsyncGenerator<VAL_T, void>, void> { | ||
return async function* (src) { | ||
const srcIterator = src[Symbol.asyncIterator](); | ||
let done: boolean | undefined = false; | ||
let hasError = false; | ||
let error; | ||
let value: VAL_T | SPLIT_MARK_T; | ||
|
||
try { | ||
for (;;) { | ||
yield (async function* () { | ||
for (;;) { | ||
try { | ||
({ value, done } = await srcIterator.next()); | ||
} catch (err) { | ||
hasError = true; | ||
error = err; | ||
throw err; | ||
} | ||
|
||
if (value === valueToSplitBy || done) { | ||
return; | ||
} | ||
|
||
yield value as VAL_T; // TODO: What do I do about this `as`?... | ||
} | ||
})(); | ||
|
||
if (done) { | ||
break; | ||
} | ||
|
||
if (hasError) { | ||
throw error; | ||
} | ||
} | ||
} finally { | ||
srcIterator.return?.(); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.