當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。