本文整理汇总了TypeScript中q类的典型用法代码示例。如果您正苦于以下问题:TypeScript q类的具体用法?TypeScript q怎么用?TypeScript q使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了q类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("should successfully send a message", function(done: MochaDone) {
const port: string = HostPlatform.getExtensionPipePath();
let receivedMessage: ExtensionMessage;
mockServer = net.createServer(function(client: net.Socket): void {
mockServer.close();
client.on("data", function(data: Buffer) {
const messageData: any = JSON.parse(data.toString("utf8"));
client.end();
receivedMessage = messageData.message;
});
});
mockServer.on("error", done);
mockServer.listen(port);
const sender = new ExtensionMessageSender();
Q({})
.then(function() {
return sender.sendMessage(ExtensionMessage.START_PACKAGER);
})
.then(function() {
assert.equal(receivedMessage, ExtensionMessage.START_PACKAGER);
}).done(() => done(), done);
});
示例2: test
test("should successfully send a message", function(done: MochaDone) {
let receivedMessage: ExtensionMessage;
mockServer = net.createServer(function(client: net.Socket): void {
mockServer.close();
client.on("data", function(data: Buffer) {
const messageData: any = JSON.parse(data.toString("utf8"));
client.end();
receivedMessage = messageData.message;
});
});
mockServer.on("error", done);
mockServer.listen(port);
const sender = RemoteExtension.atProjectRootPath(projectRootPath);
Q({})
.then(function() {
return sender.startPackager();
})
.then(function() {
assert.equal(receivedMessage, ExtensionMessage.START_PACKAGER);
}).done(() => done(), done);
});
示例3: Q
.then((model: OntoUmlModel | OntoObjectModel): Q.Promise<OntoObjectModel> => {
if (frontEnd.returnsOntoObjectModel) {
return Q(model as OntoObjectModel);
}
const objectMapper = new OntoUmlToOntoObjectModelMapper();
const objectModel = objectMapper.mapToOntoObjectModel(model as OntoUmlModel);
return Q(objectModel);
})
示例4: basicExecutorFactory
updateSettings(newSettings: AppSettings): Q.Promise<any> {
if (this.settingsLocation.readOnly) return Q.reject(new Error('must be writable'));
this.appSettings = newSettings.attachExecutors((dataCube) => {
if (dataCube.clusterName === 'native') {
var fileManager = this.getFileManagerFor(dataCube.source);
if (fileManager) {
var dataset = fileManager.dataset;
if (!dataset) return null;
return basicExecutorFactory({
datasets: { main: dataset }
});
}
} else {
var clusterManager = this.getClusterManagerFor(dataCube.clusterName);
if (clusterManager) {
var external = clusterManager.getExternalByName(dataCube.name);
if (!external) return null;
return basicExecutorFactory({
datasets: { main: external }
});
}
}
return null;
});
return Q(null); // ToDo: actually save settings
}
示例5: RangeError
return TelemetryHelper.generate("launch", (generator) => {
const resolver = new PlatformResolver();
const runOptions = this.parseRunOptions();
const mobilePlatform = resolver.resolveMobilePlatform(runOptions.platform);
if (!mobilePlatform) {
throw new RangeError("The target platform could not be read. Did you forget to add it to the launch.json configuration arguments?");
} else {
const sourcesStoragePath = path.join(this.projectRootPath, ".vscode", ".react");
const packager = new Packager(this.projectRootPath, sourcesStoragePath);
return Q({})
.then(() => {
generator.step("startPackager");
return packager.start();
})
// We've seen that if we don't prewarm the bundle cache, the app fails on the first attempt to connect to the debugger logic
// and the user needs to Reload JS manually. We prewarm it to prevent that issue
.then(() => {
generator.step("prewarmBundleCache");
return packager.prewarmBundleCache(runOptions.platform);
})
.then(() => {
generator.step("mobilePlatform.runApp");
return mobilePlatform.runApp(runOptions);
})
.then(() => {
generator.step("Starting App Worker");
return new MultipleLifetimesAppWorker(sourcesStoragePath, runOptions.debugAdapterPort).start();
}) // Start the app worker
.then(() => {
generator.step("mobilePlatform.enableJSDebuggingMode");
return mobilePlatform.enableJSDebuggingMode(runOptions);
}).then(() =>
Log.logMessage("Debugging session started succesfuly."));
}
});
示例6: introspectDataSource
}).then((ds: string[]) => {
if (!Array.isArray(ds)) throw new Error('invalid result from data source list');
var unknownDataSourceNames: string[] = [];
var nonQueryableDataSources: DataSource[] = [];
ds.forEach((d: string) => {
var existingDataSources = myDataSources.filter((dataSource) => {
return dataSource.engine === 'druid' && dataSource.source === d;
});
if (existingDataSources.length === 0) {
unknownDataSourceNames.push(d);
} else {
nonQueryableDataSources = nonQueryableDataSources.concat(existingDataSources.filter((dataSource) => {
return !dataSource.isQueryable();
}));
}
});
nonQueryableDataSources = nonQueryableDataSources.concat(unknownDataSourceNames.map((name) => {
var newDataSource = dataSourceStubFactory(name);
log(`Adding Druid data source: '${name}'`);
addOrUpdateDataSource(newDataSource);
return newDataSource;
}));
// Nothing to do
if (!nonQueryableDataSources.length) return Q(null);
return Q.allSettled(nonQueryableDataSources.map((dataSource) => {
return introspectDataSource(dataSource);
}));
}).catch((e: Error) => {
示例7: Q
.then((isRunning: boolean) => {
if (isRunning) {
/* close the server old instance */
return Q({})
.then(()=> simulate.stopSimulate());
}
}).then(() => {