How to use the delay function from bluebird
Find comprehensive JavaScript bluebird.delay code examples handpicked from public code repositorys.
338 339 340 341 342 343 344 345 346 347
expect(first_mod_of_that_subreddit.name).to.equal('krispykrackers'); expect(await first_mod_of_that_subreddit.created_utc).to.equal(1211483632); }); it('throttles requests as specified by the config parameters', async () => { r.config({request_delay: 2000}); const timer = Promise.delay(1999); await r.getUser('not_an_aardvark').fetch(); await r.getUser('actually_an_aardvark').fetch(); expect(timer.isFulfilled()).to.be.true(); });
+ 17 other calls in file
215 216 217 218 219 220 221 222 223
.withArgs('second').returns(Promise.resolve(expectedBrowser)); const result = pool.getBrowser('first') .then((browser) => { const secondPromise = pool.getBrowser('second'); return Promise.delay(100) .then(() => pool.freeBrowser(browser)) .then(() => secondPromise); });
+ 47 other calls in file
GitHub: gemini-testing/hermione
318 319 320 321 322 323 324 325 326
assert.calledOnce(HookRunner.prototype.runBeforeEachHooks); }); it('should wait beforeEach hooks finish before running test', async () => { const afterBeforeEach = sinon.spy().named('afterBeforeEach'); HookRunner.prototype.runBeforeEachHooks.callsFake(() => Promise.delay(10).then(afterBeforeEach)); const test = mkTest_(); await run_({test});
+ 6 other calls in file
GitHub: gemini-testing/hermione
253 254 255 256 257 258 259 260 261 262
it('should load files sequentially by browsers', async () => { const calls = []; callsFakeLoadFiles_({cb: async () => { calls.push('loadFiles'); await Promise.delay(1); calls.push('afterLoadFiles'); }}); const config = makeConfigStub({browsers: ['bro1', 'bro2']});
+ 9 other calls in file
227 228 229 230 231 232 233 234 235 236
, connection.downport ); }.bind(this)); // TBD: The Non-Preemptive Scheduler while (1) { yield Promise.delay(100); if (this._queue.length > 512) { console.log('Queue reaches maximum size of 512...') // The last item is now lost.
990 991 992 993 994 995 996 997 998 999
retryCount++; var retryTime = Math.floor(Math.random() * 5000); log.warn("parseAndCheckLogin", "Got status code " + data.statusCode + " - " + retryCount + ". attempt to retry in " + retryTime + " milliseconds..."); var url = data.request.uri.protocol + "//" + data.request.uri.hostname + data.request.uri.pathname; if (data.request.headers["Content-Type"].split(";")[0] === "multipart/form-data") { return bluebird.delay(retryTime).then(() => defaultFuncs.postFormData(url, ctx.jar, data.request.formData, {})) .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount)); } else { return bluebird.delay(retryTime).then(() => defaultFuncs.post(url, ctx.jar, data.request.formData)) .then(parseAndCheckLogin(ctx, defaultFuncs, retryCount));
+ 65 other calls in file
4718 4719 4720 4721 4722 4723 4724 4725 4726 4727
if (maybePromise instanceof Promise) { promise._propagateFrom(maybePromise, 7); promise._follow(maybePromise); return promise.then(function(value) { return Promise.delay(value, ms); }); } else { promise._setTrace(void 0); _setTimeout(afterDelay, ms, value, promise);
GitHub: zach1502/website
87 88 89 90 91 92 93 94 95 96
// for each character in line for(let char of line){ if(state.isStyled){ WriteStyledChar(char); if(!ignorePause && (char === '.' || char === '!' || char === '?')){ await P.delay(speechPause); } else{ await P.delay(state.delay); }
+ 43 other calls in file
GitHub: mayflower/stanza.io
![mayflower profile picture](/mayflower.png?size=40)
25 26 27 28 29 30 31 32 33 34
return body; }).catch(BPromise.TimeoutError, function () { throw new ConnectionError('Dead Connection, exceeded timeout limit'); }).catch(function () { if (retries < allowedRetries) { return BPromise.delay(100).then(function () { return retryRequest(opts, timeout, allowedRetries, retries + 1); }); } else { throw new ConnectionError('Dead Connection, exceeded retry limit');
23 24 25 26 27 28 29 30 31 32
var serverfns = {}; //or "require('...')" serverfns.testOk = function () { console.log("testOk called"); //Either return a Promise: return Promise.delay(2000) .then(function () { return "Hello"; }) //or a Value (resolve)
+ 3 other calls in file
GitHub: amoxuk/stf-dev
282 283 284 285 286 287 288 289 290 291
.then(function(out) { return out }) .catch(function(err) { if (/closed/.test(err.message) && times > 1) { return Promise.delay(delay) .then(function() { return tryConnect(times - 1, delay * 2) }) }
GitHub: amoxuk/stf-dev
285 286 287 288 289 290 291 292 293 294
'Device worker "%s" died with code %s' , device.id , err.code ) log.info('Restarting device worker "%s"', device.id) return Promise.delay(500) .then(function() { return work() }) }
GitHub: apostrophecms/apostrophe
488 489 490 491 492 493 494 495 496 497
], disabled: { $ne: true } }).toObject(); if (!user) { await Promise.delay(1000); return false; } try { await self.apos.user.verifyPassword(user, password);
+ 26 other calls in file
34 35 36 37 38 39 40 41 42 43
const dependency = { property: originalProperty }; const callback = async (sinon) => { const stub = sinon.stub(dependency, 'property'); sinon.clock.restore(); await Bluebird.delay(10); assert.strictEqual(dependency.property, stub); }; await sinonTest(callback).call(this);
+ 2 other calls in file
59 60 61 62 63 64 65 66 67 68 69
test('Promise.prototype.spread - then formal', function (t) { t.plan(6) twice(function () { var trans = ins.startTransaction() Promise.delay(1).then(function () { return ['foo', 'bar'] }).spread(function (a, b) { t.strictEqual(a, 'foo') t.strictEqual(b, 'bar')
+ 8 other calls in file
GitHub: qimmer/Plaza
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957
socket.on('detach', function (msg) { // Try to detach cleanly, timeout if no response Promise.any([ _this.dbg.sendDetachRequest(), Promise.delay(3000) ]).finally(function () { _this.dbg.disconnectDebugger(); }); });
+ 3 other calls in file
GitHub: nasolodar/test
1683 1684 1685 1686 1687 1688 1689 1690 1691 1692
return admin .save() .then(function(savedAdmin) { originalDate = savedAdmin.get('created_at'); return Promise.delay(1000).then(function() { return savedAdmin.save('username', 'pablo'); }); }) .then(function(updatedAdmin) {
+ 27 other calls in file
39 40 41 42 43 44 45 46 47 48
throw err } retries-- return Promise.delay(1000).then(function () { return UpdateBucketPolicy(S3Bucket) }) }) }
+ 10 other calls in file
GitHub: ikemnkur/IOTAAPP
363 364 365 366 367 368 369 370 371 372
// message.xp -= 2; // numOfLikes.innerText = parseInt(numOfLikes.innerText) - 1; console.log(`${username} unliked ${message.username}'s comment`); socket.emit("chatVote", message.username, msgBlock.id, 'unlike'); } delay(250); }) let hateBtn = msgBlock.querySelector('#hateBtn'); let hateIcon = msgBlock.querySelector('#hateIcon');
+ 47 other calls in file
403 404 405 406 407 408 409 410 411 412
return Promise.resolve(); } if (/mssql/i.test(knex.client.driverName)) { return Promise.resolve(); } const first = Bluebird.delay(50); const second = first.then(() => Bluebird.delay(50)); return knex.transaction(function(trx) { return Promise.all([ trx.transaction(function(trx2) {
+ 19 other calls in file
bluebird.reject is the most popular function in bluebird (2988 examples)