本文整理汇总了TypeScript中bluebird.join函数的典型用法代码示例。如果您正苦于以下问题:TypeScript join函数的具体用法?TypeScript join怎么用?TypeScript join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了join函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: sendGetAllRequestToAnalytics
export const getAllEntities = (cb: GetAllHandler) =>
Bluebird.join(
getAll<Linode.Linode>(getLinodes)(),
getAll<Linode.NodeBalancer>(getNodeBalancers)(),
getAll<Linode.Volume>(getVolumes)(),
getAll<Linode.Domain>(getDomains)(),
/** for some reason typescript thinks ...results is implicitly typed as 'any' */
// @ts-ignore
(...results) => {
const resultData = [
results[0].data,
results[1].data,
results[2].data,
results[3].data,
]
/** total number of entities returned, as determined by the results API property */
const numOfEntities = results[0].results
+ results[1].results
+ results[2].results
+ results[3].results
sendGetAllRequestToAnalytics(numOfEntities);
/** for some reason typescript thinks ...results is implicitly typed as 'any' */
// @ts-ignore
cb(...resultData)
}
);
开发者ID:displague,项目名称:manager,代码行数:28,代码来源:getAll.ts
示例2: joinDeployment
function joinDeployment(payload, reply, args) {
const vol = payload.sender.volunteer;
let newTask = false;
if (args.new_task) newTask = args.new_task;
Promise.join(
vol.currentTask().fetch(),
new Deployment().where({id: args.id}).fetch(),
function(task, deployment) {
if (!deployment) throw new Error(`invalid deployment id: ${args.id}`);
let promise = null;
if (task) {
promise = vol.unassignTask();
} else {
promise = Promise.resolve();
}
promise.then(function() {
return vol.save({deployment_id: deployment.id});
}).then(function() {
let text = `Great! Welcome to the ${deployment.name} deployment!`;
if (!newTask) text += ` Say 'ask' for a new task.`;
reply(msgUtil.quickReplyMessage(text, ["ask"]));
}).then(function() {
if (newTask) getAndAssignVolTask(vol);
});
}
);
}
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:27,代码来源:handlers.ts
示例3: putStatusToStream
.then((emailDataList: Array<EmailData>) => {
const emailDataListWithTriggers: Array<EmailData> =
emailDataList.filter((emailData) => emailData.triggeredSendKey !== undefined);
const triggers: Promise<Array<any>> = Promise.map(emailDataListWithTriggers, createTriggeredSend).map(sendTriggeredSend);
const subscriptions: Promise<Array<any>> = Promise.map(emailDataList, createSubscription).map(subscribeEmailToList);
return Promise.join(triggers, subscriptions)
.map((responses: Array<any>) => {
return responses.map((response: any) => {
if (!response.body.Results[0]) throw "No results";
return response.body.Results;
});
})
.map((allResponses: Array<Array<any>>) => {
allResponses.map((results: Array<any>) => {
results.map((result: any) => {
console.log(JSON.stringify(result));
if (result.StatusCode !== 'OK') {
console.log("Failed! StatusCode: " + result.StatusCode + " StatusMessage: " + result.StatusMessage);
throw result;
}
return result;
});
});
})
.then(() => putStatusToStream(makeSuccessPutRequest(emailDataList)))
.catch((error) => {
console.log(error);
putStatusToStream(makeFailurePutRequest(emailDataList, error))
})
.then(() => Promise.resolve(emailDataList));
})
开发者ID:sndrs,项目名称:email-signup,代码行数:34,代码来源:triggersubscriberhandler.ts
示例4: async
router.get('/search', async (req, res) => {
const pinyin = req.query.pinyin.toLowerCase();
const mostUsedPromise = knex('cjk')
.where({
pronunciation: pinyin,
})
.where('frequency', '<=', 5)
.orderBy('frequency', 'ASC')
.orderBy('usage', 'DESC')
.select('id', 'pronunciation', 'ideogram', 'frequency', 'usage');
const lessUsedPromise = knex('cjk')
.where({
pronunciation: pinyin,
})
.where('frequency', '>', 5)
.orderBy('frequency', 'ASC')
.orderBy('usage', 'DESC')
.select('id', 'pronunciation', 'ideogram', 'frequency', 'usage');
bluebird.join(mostUsedPromise, lessUsedPromise, (mostUsed, lessUsed) => {
const result: any = {};
result.items = mostUsed;
result.lessUsed = lessUsed;
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(result));
});
});
开发者ID:pierophp,项目名称:pinyin,代码行数:29,代码来源:unihan.controller.ts
示例5: remindVolunteersOfTasksAvailable
export function remindVolunteersOfTasksAvailable(): Promise<any> {
const twelveHoursAgo = moment().subtract(12, "hours");
const getVolunteers = Volunteer.collection().query((qb) => {
qb.whereNull("current_task")
.where("deployment_id", DEPLOYMENT_ID)
.where((qb) => {
qb.where("last_response", "<", twelveHoursAgo.format(DATE_FORMAT))
.orWhereNull("last_response");
}).where((qb) => {
qb.where("last_messaged", "<", twelveHoursAgo.format(DATE_FORMAT))
.orWhereNull("last_messaged");
})
}).fetch();
const getTaskPool = new Deployment({id: DEPLOYMENT_ID}).fetch()
.then((deployment) => deployment.getTaskPool());
return Promise.join(getVolunteers, getTaskPool, (volunteers, tasks) => {
return Promise.mapSeries(volunteers.map<Volunteer>(), (volunteer) => {
if (tasks.length > 0) {
const task = tasks.pop();
return TaskFsm.assign(task, volunteer)
.then(() => task.getProposalMessage(volunteer))
.then(message => message.send());
}
});
});
}
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:28,代码来源:remind_new_tasks.ts
示例6: it
it('deve executar multiplas operaçþes assincronas em conjunto', done => {
Promise.join<Array<number>>(operacaoAssincrona(10), operacaoAssincrona(20), (result1, result2) => [...result1, ...result2])
.filter<number>(response => !!(response % 2))
.then(response => {
expect(response).to.deep.equal([1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]);
})
.finally(done);
});
开发者ID:feliperohdee,项目名称:node-meetup-cheatsheet,代码行数:8,代码来源:promises.ts
示例7: function
"msg:done": function(task: Task) {
const updateSlot = new BeaconSlot({id: task.context.slot})
.save({beacon_id: task.context.currentBeacon}, {patch: true});
const updateScore = task.saveScore(40);
Promise.join(updateSlot, updateScore, () => {
this.handle(task, "complete");
});
},
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:8,代码来源:replace_beacon_task.ts
示例8: apply
export default function apply(config: Config) {
let client = config.client;
let command = config.commands.apply;
let migrations = listMigrations(config.files.directory);
let journal = readJournal(client.name, client.config, client.journalTable);
let states = Promise.join(migrations, journal, getMigrationStates)
let applicableIDs = states
.then(R.filter(isApplicable))
.then(ss => R.map(s => s.migrationID, ss));
let toApplyIDs: Promise<string[]>;
if (command.pending) {
toApplyIDs = applicableIDs;
} else if (command.id) {
toApplyIDs = applicableIDs.then(R.filter(id => id === command.id));
} else if (command.to) {
toApplyIDs = applicableIDs.then(R.filter(id => id <= command.to));
} else if (command.number) {
toApplyIDs = applicableIDs.then(R.take(command.number));
} else {
toApplyIDs = Promise.resolve([]);
}
let toApply = Promise.join(migrations, toApplyIDs, (ms, ids) =>
R.filter(m => R.contains(m.id, ids), ms)
);
let apply = toApply.then(ms =>
applyFunction(command.method)(
client.name, client.config, client.journalTable, ms
)
);
let previousEntry = journal.then(es => R.last(es));
let newEntries = Promise.join(previousEntry, apply, (prev, es) =>
prev ? R.filter(e => e.timestamp > prev.timestamp, es) : apply
);
return newEntries
.then(R.map(formatJournalEntry))
.then(R.join(''));
}
开发者ID:programble,项目名称:careen,代码行数:44,代码来源:apply.ts
示例9: revert
export default function revert(config: Config) {
let client = config.client;
let command = config.commands.revert;
let migrations = listMigrations(config.files.directory);
let journal = readJournal(client.name, client.config, client.journalTable);
let states = Promise.join(migrations, journal, getMigrationStates);
let revertableIDs = states
.then(R.filter(isRevertable))
.then(ss => R.map(s => s.migrationID, ss));
let toRevertIDs: Promise<string[]>;
if (command.id) {
toRevertIDs = revertableIDs.then(R.filter(id => id === command.id));
} else if (command.to) {
toRevertIDs = revertableIDs.then(R.filter(id => id > command.to));
} else if (command.number) {
toRevertIDs = revertableIDs.then(R.reverse).then(R.take(command.number));
} else {
toRevertIDs = Promise.resolve([]);
}
let toRevert = Promise.join(migrations, toRevertIDs, (ms, ids) =>
R.filter(m => R.contains(m.id, ids), R.reverse(ms))
);
let revert = toRevert.then(ms =>
revertFunction(command.method)(
client.name, client.config, client.journalTable, ms
)
);
let previousEntry = journal.then(es => R.last(es));
let newEntries = Promise.join(previousEntry, revert, (prev, es) =>
R.filter(e => e.timestamp > prev.timestamp, es)
);
return newEntries
.then(R.map(formatJournalEntry))
.then(R.join(''));
}
开发者ID:programble,项目名称:careen,代码行数:42,代码来源:revert.ts
示例10: Volunteer
return Promise.map<LeaderQueryResultRow, LeaderboardRow>(rows, (row) => {
row.total_score = row.total_score === null ? 0 : row.total_score;
const getProfile = bot.FBPlatform.getUserProfile(String(row.volunteer_fbid));
const getVolunteer = new Volunteer({fbid: row.volunteer_fbid}).fetch();
return Promise.join(getProfile, getVolunteer, (profile, vol) => {
const result = row as LeaderboardRow;
result.profilePicURL = profile.profile_pic;
result.name = vol.username;
return result;
});
}).then((results) => {
开发者ID:CMUBigLab,项目名称:cmuNodeFbot,代码行数:11,代码来源:routes.ts
注:本文中的bluebird.join函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论