本文整理汇总了TypeScript中bluebird.delay函数的典型用法代码示例。如果您正苦于以下问题:TypeScript delay函数的具体用法?TypeScript delay怎么用?TypeScript delay使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delay函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: await
var fn = async.cps(function () {
console.log('111');
var first = await(Promise.delay(20).then(() => 'A'), Promise.delay(20).then(() => 'B'));
console.log('222');
var second = await([Promise.delay(20).then(() => 'C'), Promise.delay(20).then(() => 'D')]);
console.log('333');
return { first, second };
});
示例2: Error
promiseList.push((async () => {
await Bluebird.delay(curDelay);
let currentSchedule = JOIN_ROOM_SCHEDULE[0];
const doJoin = async () => {
await Util.DelayedPromise(currentSchedule);
await userSync.OnUpdateGuildMember(member, true);
};
const errorHandler = async (err) => {
log.error(`Error joining rooms for ${member.id}`);
log.error(err);
const idx = JOIN_ROOM_SCHEDULE.indexOf(currentSchedule);
if (idx === JOIN_ROOM_SCHEDULE.length - 1) {
log.warn(`Cannot join rooms for ${member.id}`);
throw new Error(err);
} else {
currentSchedule = JOIN_ROOM_SCHEDULE[idx + 1];
try {
await doJoin();
} catch (e) {
await errorHandler(e);
}
}
};
try {
await doJoin();
} catch (e) {
await errorHandler(e);
}
})());
示例3: rpc
async function rpc() {
const data = Math.random()
await Bluebird.delay(data * 100)
const result = await app.rpc('carrotmq.test.callback', {data: data})
await result.ack()
result.data['data'].should.eql(data)
}
示例4: xit
xit('should sweep funds between two wallets', co(function *() {
const unspentWallet = yield wallets.getWallet({ id: TestV2BitGo.V2.TEST_WALLET2_UNSPENTS_ID });
const sweep1Wallet = yield wallets.getWallet({ id: TestV2BitGo.V2.TEST_SWEEP1_ID });
const sweep2Wallet = yield wallets.getWallet({ id: TestV2BitGo.V2.TEST_SWEEP2_ID });
yield bitgo.unlock({ otp: bitgo.testUserOTP() });
yield Promise.delay(3000);
const params1 = {
address: TestV2BitGo.V2.TEST_SWEEP2_ADDRESS,
walletPassphrase: TestV2BitGo.V2.TEST_SWEEP1_PASSCODE
};
const transaction1 = yield sweep1Wallet.sweep(params1);
transaction1.should.have.property('status');
transaction1.should.have.property('txid');
transaction1.status.should.equal('signed');
yield Promise.delay(8000);
const unspentsResult1 = yield sweep1Wallet.unspents();
const numUnspents1 = unspentsResult1.unspents.length;
numUnspents1.should.equal(0);
const unspentsResult2 = yield sweep2Wallet.unspents();
const numUnspents2 = unspentsResult2.unspents.length;
numUnspents2.should.equal(1);
// sweep funds back to starting wallet
const params2 = {
address: TestV2BitGo.V2.TEST_SWEEP1_ADDRESS,
walletPassphrase: TestV2BitGo.V2.TEST_SWEEP2_PASSCODE
};
const transaction2 = yield unspentWallet.sweep(params2);
transaction2.should.have.property('status');
transaction2.should.have.property('txid');
transaction2.status.should.equal('signed');
yield Promise.delay(8000);
const unspentsResult3 = yield sweep2Wallet.unspents();
const numUnspents3 = unspentsResult3.unspents.length;
numUnspents3.should.equal(0);
const unspentsResult4 = yield sweep1Wallet.unspents();
const numUnspents4 = unspentsResult4.unspents.length;
numUnspents4.should.equal(1);
}));
示例5: catch
promiseList2.push((async () => {
await Bluebird.delay(curDelay);
try {
await discordbot.ChannelSyncroniser.OnGuildUpdate(guild, true);
} catch (err) {
log.warn(`Couldn't update rooms of guild ${guild.id}`, err);
}
})());
示例6: it
it('should resolve with correct messages', async () => {
await client.sendAvailable();
const newSlice = {
slicer_order: 0,
slicer_id: 1,
request: {},
slice_id: 'client-slice-complete',
_created: 'hello'
};
const stopAt = Date.now() + 2000;
const slice = client.waitForSlice(() => (Date.now() - stopAt) > 0);
await bluebird.delay(500);
expect(server.queue.exists('workerId', workerId)).toBeTrue();
const id = server.dequeueWorker(newSlice);
if (!id) {
expect(id).not.toBeNull();
return;
}
const dispatched = await server.dispatchSlice(newSlice, id);
await expect(slice).resolves.toEqual(newSlice);
expect(dispatched).toBeTrue();
expect(server.activeWorkerCount).toBe(1);
await client.sendSliceComplete({
slice: newSlice,
analytics: {
time: [],
memory: [],
size: []
}
});
await bluebird.delay(100);
expect(server.activeWorkerCount).toBe(0);
});
示例7: run
function run(item: string) {
if(++running > maxRunning) maxRunning = running;
return(Promise.delay(100, true).then(() => {
--running;
return(item);
}));
}
示例8: it
it('should fetch a transfer by its sequence Id', co(function *() {
// Wait for worker to do its work
yield Promise.delay(10000);
const transfer = yield wallet.transferBySequenceId({ sequenceId: sequenceId });
transfer.should.have.property('sequenceId');
transfer.sequenceId.should.equal(sequenceId);
}));
示例9: waitForEthNodeToFinishSyncing
async function waitForEthNodeToFinishSyncing(augur: Augur): Promise<void> {
while (true) {
const sync = await getIsEthNodeSyncing(augur);
if (!sync.isEthNodeSyncing) break;
logger.warn(`The Ethereum node has not finished syncing, waiting
Current Block: ${sync.highestBlockNumber}`);
await delay(BLOCKSTREAM_HANDOFF_WAIT_TIME_MS);
}
}