Skip to content

Commit

Permalink
Extract helper
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 5, 2022
1 parent 7350844 commit 8672129
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/utils/chunkAssignment.ts
@@ -1,6 +1,7 @@
import ExternalModule from '../ExternalModule';
import Module from '../Module';
import { getOrCreate } from './getOrCreate';
import { concatLazy } from './iterators';
import relativeId from './relativeId';
import { timeEnd, timeStart } from './timers';

Expand Down Expand Up @@ -331,15 +332,8 @@ function mergeSignatures(sourceSignature: string, targetSignature: string): stri
return signature;
}

function* concatLazy<T>(...iterators: Iterable<T>[]) {
for (const iterator of iterators) {
yield* iterator;
}
}

// DEBUGGING HELPERS, REMOVED BY TREE-SHAKING
/* eslint-disable @typescript-eslint/no-unused-vars */

const relativeModuleId = (module: Module) => relativeId(module.id);

const printModuleMap = (label: string, map: DependentModuleMap) =>
Expand Down
10 changes: 10 additions & 0 deletions src/utils/iterators.ts
@@ -0,0 +1,10 @@
/**
* Concatenate a number of iterables to a new iterable without fully evaluating
* their iterators. Useful when e.g. working with large sets or lists and when
* there is a chance that the iterators will not be fully exhausted.
*/
export function* concatLazy<T>(...iterables: Iterable<T>[]) {
for (const iterable of iterables) {
yield* iterable;
}
}

0 comments on commit 8672129

Please sign in to comment.