当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lazy.js函数代码示例

本文整理汇总了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());
		});
开发者ID:DefinitelyTyped,项目名称:definition-tester,代码行数:28,代码来源:FileIndex.ts

示例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();
开发者ID:rakatyal,项目名称:definition-tester,代码行数:7,代码来源:FileIndex.ts

示例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;
		});
开发者ID:DefinitelyTyped,项目名称:definition-tester,代码行数:15,代码来源:FileIndex.ts

示例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);
		});
开发者ID:DefinitelyTyped,项目名称:definition-tester,代码行数:22,代码来源:FileIndex.ts


注:本文中的lazy.js函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。