本文整理汇总了TypeScript中Q.all函数的典型用法代码示例。如果您正苦于以下问题:TypeScript all函数的具体用法?TypeScript all怎么用?TypeScript all使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了all函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: findPlistFile
public findPlistFile(): Q.Promise<string> {
return Q.all<any>([
this.plistBuddy.getBundleId(this.projectRoot), // Find the name of the application
this.nodeChildProcess.exec("xcrun simctl getenv booted HOME").outcome, // Find the path of the simulator we are running
]).spread((bundleId: string, pathBuffer: Buffer) => {
const pathBefore = path.join(pathBuffer.toString().trim(), "Containers", "Data", "Application");
const pathAfter = path.join("Library", "Preferences", `${bundleId}.plist`);
// Look through $SIMULATOR_HOME/Containers/Data/Application/*/Library/Preferences to find $BUNDLEID.plist
return this.nodeFileSystem.readDir(pathBefore).then((apps: string[]) => {
Log.logInternalMessage(LogLevel.Info, `About to search for plist in base folder: ${pathBefore} pathAfter: ${pathAfter} in each of the apps: ${apps}`);
const plistCandidates = apps.map((app: string) => path.join(pathBefore, app, pathAfter)).filter(filePath =>
this.nodeFileSystem.existsSync(filePath));
if (plistCandidates.length === 0) {
throw new Error(`Unable to find plist file for ${bundleId}`);
} else if (plistCandidates.length > 1) {
TelemetryHelper.sendSimpleEvent("multipleDebugPlistFound");
Log.logWarning(ErrorHelper.getWarning("Multiple plist candidates found. Application may not be in debug mode."));
}
return plistCandidates[0];
});
});
}
示例2: it
it('cannot approve when transaction needs reconstructing', function() {
let approvals = [];
return Q.all([
createTransactionPendingApproval(),
createTransactionPendingApproval()
])
.spread(function(approval1, approval2) {
approvals = [approval1, approval2];
return bitgoSharedKeyUser.pendingApprovals().get({ id: approval1.id() });
})
.then(function(result) {
return result.approve({ walletPassphrase: TestBitGo.TEST_PASSWORD, otp: bitgo.testUserOTP() });
})
.then(function(result) {
result.state.should.eql('approved');
const approval2 = approvals[1];
return bitgoSharedKeyUser.pendingApprovals().get({ id: approval2.id() });
})
.then(function(result) {
return result.approve({ otp: bitgo.testUserOTP() });
})
.then(function() {
throw new Error('approval success');
})
.catch(function(error) {
error.message.should.equal('unspents expired, wallet passphrase or xprv required to recreate transaction');
});
});
示例3: should
.then(initState => {
const asyncTests = initState.allSails.map(sail => {
const newSailNid = sail.id;
return instance.setSailId(initState, newSailNid)
.then(resultState => {
should(resultState.selectedSailId).be.exactly(newSailNid);
should(resultState.selectedCabin.sailId).be.exactly(newSailNid);
should(resultState.cabinGridSelect.inside.sailId).be.exactly(newSailNid);
should(resultState.cabinGridSelect.outside.sailId).be.exactly(newSailNid);
should(resultState.cabinGridSelect.balcony.sailId).be.exactly(newSailNid);
should(resultState.cabinGridSelect.suite.sailId).be.exactly(newSailNid);
resultState.cabintypeSelect.forEach(item => {
should(item.sailId).be.exactly(newSailNid);
});
should(resultState.sailSelect.some(e => e.id === newSailNid)).be.ok();
});
});
Q.all(asyncTests)
.then(r => done())
.catch(done);
});
示例4: reviseDataSources
reviseDataSources(newSettings: AppSettings): Q.Promise<any> {
const { verbose, logger } = this;
var oldSettings = this.appSettings;
var tasks: Q.Promise<any>[] = [];
var oldNativeDataSources = oldSettings.getDataSourcesForCluster('native');
var newNativeDataSources = newSettings.getDataSourcesForCluster('native');
updater(oldNativeDataSources, newNativeDataSources, {
onExit: (oldDataSource) => {
if (oldDataSource.engine === 'native') {
this.removeFileManager(oldDataSource);
} else {
throw new Error(`only native datasources work for now`); // ToDo: fix
}
},
onUpdate: (newDataSource) => {
logger.log(`${newDataSource.name} UPDATED datasource`);
},
onEnter: (newDataSource) => {
if (newDataSource.engine === 'native') {
tasks.push(this.addFileManager(newDataSource));
} else {
throw new Error(`only native datasources work for now`); // ToDo: fix
}
}
});
return Q.all(tasks);
}
示例5: return
return () => {
return q.all(
array.map(row => {
return db.update(insertSt, row)
})
)
}
示例6: updateJob
/**
* Hook to update the BrowserStack job status.
* @public
* @param {Object} update
* @return {q.promise} A promise that will resolve when the update is complete.
*/
updateJob(update: any): q.Promise<any> {
let deferredArray = this.drivers_.map((driver: WebDriver) => {
let deferred = q.defer();
driver.getSession().then((session: Session) => {
let headers: Object = {
'Content-Type': 'application/json',
'Authorization': 'Basic ' +
new Buffer(this.config_.browserstackUser + ':' + this.config_.browserstackKey)
.toString('base64')
};
let options = {
hostname: 'www.browserstack.com',
port: 443,
path: '/automate/sessions/' + session.getId() + '.json',
method: 'GET',
headers: headers
};
let req = https.request(options, (res) => {
res.on('data', (data: Buffer) => {
let info = JSON.parse(data.toString());
if (info && info.automation_session && info.automation_session.browser_url) {
logger.info(
'BrowserStack results available at ' + info.automation_session.browser_url);
} else {
logger.info(
'BrowserStack results available at ' +
'https://www.browserstack.com/automate');
}
});
});
req.end();
req.on('error', (e: Error) => {
logger.info(
'BrowserStack results available at ' +
'https://www.browserstack.com/automate');
});
let jobStatus = update.passed ? 'completed' : 'error';
options.method = 'PUT';
let update_req = https.request(options, (res) => {
let responseStr = '';
res.on('data', (data: Buffer) => {
responseStr += data.toString();
});
res.on('end', () => {
logger.info(responseStr);
deferred.resolve();
});
res.on('error', (e: Error) => {
throw new BrowserError(
logger, 'Error updating BrowserStack pass/fail status: ' + util.inspect(e));
});
});
update_req.write('{"status":"' + jobStatus + '"}');
update_req.end();
});
return deferred.promise;
});
return q.all(deferredArray);
}
示例7: ForbiddenError
.then((categories) => {
if(categories.length > 0) {
throw new ForbiddenError("Categories already been seeded");
}
return Q.all(createAllCategories());
})
示例8: cleanup
cleanup(): Promise<any> {
return Q.all([
this.nodeBuilder && this.nodeBuilder.cleanup(),
this.browserDevBuilder && this.browserDevBuilder.cleanup(),
this.browserProdBuilder && this.browserProdBuilder.cleanup()
]);
}
示例9: putAll
putAll(pairs: [K, V][]): Q.Promise<void> {
var partitionService = this.client.getPartitionService();
var partitionsToKeys: {[id: string]: any} = {};
var pair: [K, V];
var pairId: string;
for (pairId in pairs) {
pair = pairs[pairId];
var keyData = this.toData(pair[0]);
var pId: number = partitionService.getPartitionId(keyData);
if (!partitionsToKeys[pId]) {
partitionsToKeys[pId] = [];
}
partitionsToKeys[pId].push({key: keyData, val: this.toData(pair[1])});
}
var partitionPromises: Q.Promise<void>[] = [];
for (var partition in partitionsToKeys) {
partitionPromises.push(
this.encodeInvokeOnPartition<void>(MapPutAllCodec, Number(partition), partitionsToKeys[partition])
);
}
var deferred = Q.defer<void>();
Q.all(partitionPromises)
.then(function() {
deferred.resolve();
});
return deferred.promise;
}
示例10: getAll
getAll(keys: K[]): Q.Promise<any[]> {
var partitionService = this.client.getPartitionService();
var partitionsToKeys: {[id: string]: any} = {};
var key: K;
for (var i in keys) {
key = keys[i];
var keyData = this.toData(key);
var pId: number = partitionService.getPartitionId(keyData);
if (!partitionsToKeys[pId]) {
partitionsToKeys[pId] = [];
}
partitionsToKeys[pId].push(keyData);
}
var partitionPromises: Q.Promise<[Data, Data][]>[] = [];
for (var partition in partitionsToKeys) {
partitionPromises.push(this.encodeInvokeOnPartition<[Data, Data][]>(
MapGetAllCodec,
Number(partition),
partitionsToKeys[partition])
);
}
var toObject = this.toObject.bind(this);
var deserializeEntry = function(entry: [Data, Data]) {
return [toObject(entry[0]), toObject(entry[1])];
};
return Q.all(partitionPromises).then(function(serializedEntryArrayArray: [Data, Data][][]) {
return Array.prototype.concat.apply([], serializedEntryArrayArray).map(deserializeEntry);
});
}