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


TypeScript base.TPromise.wrap方法代码示例

本文整理汇总了TypeScript中vs/base/common/winjs.base.TPromise.wrap方法的典型用法代码示例。如果您正苦于以下问题:TypeScript base.TPromise.wrap方法的具体用法?TypeScript base.TPromise.wrap怎么用?TypeScript base.TPromise.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/base/common/winjs.base.TPromise的用法示例。


在下文中一共展示了base.TPromise.wrap方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getTelemetryInfo

	getTelemetryInfo(): TPromise<ITelemetryInfo> {
		return TPromise.wrap({
			instanceId: 'someValue.instanceId',
			sessionId: 'someValue.sessionId',
			machineId: 'someValue.machineId'
		});
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:7,代码来源:telemetryUtils.ts

示例2: confirm

	public confirm(confirmation: IConfirmation): TPromise<boolean> {
		let messageText = confirmation.message;
		if (confirmation.detail) {
			messageText = messageText + '\n\n' + confirmation.detail;
		}

		return TPromise.wrap(window.confirm(messageText));
	}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:8,代码来源:messageService.ts

示例3: extractZip

function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, logService: ILogService): TPromise<void> {
	let isCanceled = false;
	let last = TPromise.wrap<any>(null);
	let extractedEntriesCount = 0;

	return new TPromise((c, e) => {
		const throttler = new SimpleThrottler();

		const readNextEntry = () => {
			extractedEntriesCount++;
			zipfile.readEntry();
		};

		zipfile.once('error', e);
		zipfile.once('close', () => last.then(() => {
			if (isCanceled || zipfile.entryCount === extractedEntriesCount) {
				c(null);
			} else {
				e(new ExtractError('Incomplete', new Error(nls.localize('incompleteExtract', "Incomplete. Found {0} of {1} entries", extractedEntriesCount, zipfile.entryCount))));
			}
		}, e));
		zipfile.readEntry();
		zipfile.on('entry', (entry: Entry) => {
			logService.debug(targetPath, 'Found', entry.fileName);

			if (isCanceled) {
				return;
			}

			if (!options.sourcePathRegex.test(entry.fileName)) {
				readNextEntry();
				return;
			}

			const fileName = entry.fileName.replace(options.sourcePathRegex, '');

			// directory file names end with '/'
			if (/\/$/.test(fileName)) {
				const targetFileName = path.join(targetPath, fileName);
				last = mkdirp(targetFileName).then(() => readNextEntry());
				return;
			}

			const stream = ninvoke(zipfile, zipfile.openReadStream, entry);
			const mode = modeFromEntry(entry);

			last = throttler.queue(() => stream.then(stream => extractEntry(stream, fileName, mode, targetPath, options).then(() => readNextEntry())));
		});
	}, () => {
		logService.debug(targetPath, 'Cancelled.');
		isCanceled = true;
		last.cancel();
		zipfile.close();
	}).then(null, err => TPromise.wrapError(toExtractError(err)));
}
开发者ID:jumpinjackie,项目名称:sqlopsstudio,代码行数:55,代码来源:zip.ts

示例4:

	// Convert the command on the ExtHost side so we can pass the original externalNode to the registered handler
	$getInternalCommand(providerId: string, mainThreadNode: InternalTreeExplorerNode): TPromise<modes.Command> {
		const commandConverter = this.commands.converter;

		if (mainThreadNode.clickCommand) {
			const extNode = this._extNodeMaps[providerId][mainThreadNode.id];

			const internalCommand = commandConverter.toInternal({
				title: '',
				command: mainThreadNode.clickCommand,
				arguments: [extNode]
			});

			return TPromise.wrap(internalCommand);
		}

		return TPromise.as(null);
	}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:18,代码来源:extHostTreeExplorers.ts

示例5: extractZip

function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions): TPromise<void> {
	let isCanceled = false;
	let last = TPromise.wrap<any>(null);

	return new TPromise((c, e) => {
		const throttler = new SimpleThrottler();

		zipfile.once('error', e);
		zipfile.once('close', () => last.then(c, e));
		zipfile.on('entry', (entry: Entry) => {
			if (isCanceled) {
				return;
			}

			if (!options.sourcePathRegex.test(entry.fileName)) {
				return;
			}

			const fileName = entry.fileName.replace(options.sourcePathRegex, '');

			// directory file names end with '/'
			if (/\/$/.test(fileName)) {
				const targetFileName = path.join(targetPath, fileName);
				last = mkdirp(targetFileName);
				return;
			}

			const stream = ninvoke(zipfile, zipfile.openReadStream, entry);
			const mode = modeFromEntry(entry);

			last = throttler.queue(() => stream.then(stream => extractEntry(stream, fileName, mode, targetPath, options)));
		});
	}, () => {
		isCanceled = true;
		last.cancel();
		zipfile.close();
	}).then(null, err => TPromise.wrapError(toExtractError(err)));
}
开发者ID:costincaraivan,项目名称:vscode,代码行数:38,代码来源:zip.ts

示例6: setInput

	public setInput(input: EditorInput, options?: EditorOptions): TPromise<void> {

		// Return early for same input unless we force to open
		const forceOpen = options && options.forceOpen;
		if (!forceOpen && input.matches(this.input)) {
			return TPromise.wrap<void>(null);
		}

		// Otherwise set input and resolve
		return super.setInput(input, options).then(() => {
			return input.resolve(true).then(model => {

				// Assert Model instance
				if (!(model instanceof BinaryEditorModel)) {
					return TPromise.wrapError<void>(new Error('Unable to open file as binary'));
				}

				// Assert that the current input is still the one we expect. This prevents a race condition when loading takes long and another input was set meanwhile
				if (!this.input || this.input !== input) {
					return null;
				}

				// Render Input
				this.resourceViewerContext = ResourceViewer.show(
					{ name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag(), mime: model.getMime() },
					this.binaryContainer.getHTMLElement(),
					this.scrollbar,
					resource => this.callbacks.openInternal(input, options),
					resource => this.callbacks.openExternal(resource),
					meta => this.handleMetadataChanged(meta)
				);

				return TPromise.as<void>(null);
			});
		});
	}
开发者ID:costincaraivan,项目名称:vscode,代码行数:36,代码来源:binaryEditor.ts

示例7: capturePage

	capturePage(windowId: number): TPromise<string> {
		return TPromise.wrap(this.channel.call('capturePage', windowId));
	}
开发者ID:,项目名称:,代码行数:3,代码来源:

示例8: writeInTerminal

	writeInTerminal(selector: string, text: string): TPromise<void> {
		return TPromise.wrap(this.channel.call('writeInTerminal', [selector, text]));
	}
开发者ID:,项目名称:,代码行数:3,代码来源:

示例9: getWindowIds

	getWindowIds(): TPromise<number[]> {
		return TPromise.wrap(this.channel.call('getWindowIds'));
	}
开发者ID:,项目名称:,代码行数:3,代码来源:

示例10: typeInEditor

	typeInEditor(selector: string, text: string): TPromise<void> {
		return TPromise.wrap(this.channel.call('typeInEditor', [selector, text]));
	}
开发者ID:,项目名称:,代码行数:3,代码来源:


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