本文整理汇总了TypeScript中lazy.js函数的典型用法代码示例。如果您正苦于以下问题:TypeScript js函数的具体用法?TypeScript js怎么用?TypeScript js使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了js函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return new Promise<File[]>((resolve: (result: File[]) => void) => {
// map out files linked to changes
// - queue holds files touched by a change
// - pre-fill with actually changed files
// - loop queue, if current not seen:
// - add to result
// - from refMap queue all files referring to current
let result: IFileDict = Object.create(null);
let queue = Lazy<File>(this.changed).values().toArray();
while (queue.length > 0) {
let next = queue.shift();
let fp = next.fullPath;
if (result[fp]) {
continue;
}
result[fp] = next;
if (fp in this.refMap) {
let arr = this.refMap[fp];
for (let i = 0, ii = arr.length; i < ii; i++) {
// just add it and skip expensive checks
queue.push(arr[i]);
}
}
}
resolve(Lazy<File>(result).values().toArray());
});
示例2: Lazy
}).then((fileNames: string[]) => {
this.files = Lazy(fileNames).filter(this.checkAcceptFile).map((fileName: string) => {
let file = File.fromPathAndFilename(this.options.dtPath, fileName);
this.fileMap[file.fullPath] = file;
return file;
}).toArray();
}).return();
示例3: Lazy
return util.readFile(file.fullPath).then((content: string) => {
file.references = Lazy(util.extractReferenceTags(content)).map((ref: string) => {
return path.resolve(path.dirname(file.fullPath), ref);
}).reduce((memo: File[], ref: string) => {
if (ref in this.fileMap) {
memo.push(this.fileMap[ref]);
} else {
console.log(` not mapped? -> ${ref}`);
// console.log(Object.keys(this.fileMap).join('\n'));
}
return memo;
}, []);
// return the object
return file;
});
示例4: File
return new Promise<void>((resolve) => {
// filter changes and bake map for easy lookup
this.changed = Object.create(null);
this.removed = Object.create(null);
Lazy(changes).filter((full) => {
return this.checkAcceptFile(full);
}).uniq().each((local) => {
let full = util.fixPath(path.resolve(this.options.dtPath, local));
let file = this.getFile(full);
if (!file) {
// TODO figure out what to do here
// what does it mean? deleted?
file = new File(this.options.dtPath, local);
this.setFile(file);
this.removed[full] = file;
} else {
this.changed[full] = file;
}
});
resolve(null);
});