本文整理汇总了TypeScript中jest-haste-map.FS.getAbsoluteFileIterator方法的典型用法代码示例。如果您正苦于以下问题:TypeScript FS.getAbsoluteFileIterator方法的具体用法?TypeScript FS.getAbsoluteFileIterator怎么用?TypeScript FS.getAbsoluteFileIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jest-haste-map.FS
的用法示例。
在下文中一共展示了FS.getAbsoluteFileIterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: resolveInverseModuleMap
resolveInverseModuleMap(
paths: Set<Config.Path>,
filter: (file: Config.Path) => boolean,
options?: Resolver.ResolveModuleConfig,
): Array<DependencyResolver.ResolvedModule> {
if (!paths.size) {
return [];
}
const collectModules = (
related: Set<Config.Path>,
moduleMap: Array<DependencyResolver.ResolvedModule>,
changed: Set<Config.Path>,
) => {
const visitedModules = new Set();
const result: Array<DependencyResolver.ResolvedModule> = [];
while (changed.size) {
changed = new Set(
moduleMap.reduce<Array<Config.Path>>((acc, module) => {
if (
visitedModules.has(module.file) ||
!module.dependencies.some(dep => changed.has(dep))
) {
return acc;
}
const file = module.file;
if (filter(file)) {
result.push(module);
related.delete(file);
}
visitedModules.add(file);
acc.push(module.file);
return acc;
}, []),
);
}
return result.concat(
Array.from(related).map(file => ({dependencies: [], file})),
);
};
const relatedPaths = new Set<Config.Path>();
const changed: Set<Config.Path> = new Set();
for (const path of paths) {
if (this._hasteFS.exists(path)) {
const modulePath = isSnapshotPath(path)
? this._snapshotResolver.resolveTestPath(path)
: path;
changed.add(modulePath);
if (filter(modulePath)) {
relatedPaths.add(modulePath);
}
}
}
const modules: Array<DependencyResolver.ResolvedModule> = [];
for (const file of this._hasteFS.getAbsoluteFileIterator()) {
modules.push({
dependencies: this.resolve(file, options),
file,
});
}
return collectModules(relatedPaths, modules, changed);
}