本文整理匯總了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'
});
}
示例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));
}
示例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)));
}
示例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);
}
示例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)));
}
示例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);
});
});
}
示例7: capturePage
capturePage(windowId: number): TPromise<string> {
return TPromise.wrap(this.channel.call('capturePage', windowId));
}
示例8: writeInTerminal
writeInTerminal(selector: string, text: string): TPromise<void> {
return TPromise.wrap(this.channel.call('writeInTerminal', [selector, text]));
}
示例9: getWindowIds
getWindowIds(): TPromise<number[]> {
return TPromise.wrap(this.channel.call('getWindowIds'));
}
示例10: typeInEditor
typeInEditor(selector: string, text: string): TPromise<void> {
return TPromise.wrap(this.channel.call('typeInEditor', [selector, text]));
}