export function screenshotFirefox(outputFilePath: string) { return run((outputFilePath) => { const app = Application.currentApplication(); app.includeStandardAdditions = true; const Firefox = Application("Firefox"); Firefox.activate(); delay(0.3); const window = Firefox.windows[0]; const windowId = String(window.id()); app.doShellScript(`/usr/sbin/screencapture -o -l ${windowId} "${outputFilePath}"`); }, outputFilePath); }
const mapper = function mapper(rows) { const filter = function filter() { return _.reduce(rows, (prev, curr) => Math.max(prev, curr.eventLoop.high), 0); }; const maxDelay = filter(); return _.map(rows, (row) => ({ delay: Number(row.eventLoop.delay.toFixed(1)), high: Number(maxDelay.toFixed(1)) })); }
async handler(ctx) { await this.Promise.delay(_.random(500, 2500)); this.logger.info("Second called.", ctx.params); return ctx.params; }
Promise.all([broker1.start(), broker2.start(), broker.start()]) .delay(2000) .then(() => { broker.repl(); }) .then(() => broker.call("greeter.hello").then(res => broker.logger.info("Call 'greeter.hello':", res))) .then(() => broker.call("greeter.hello@local").then(res => broker.logger.info("Call 'greeter.hello@local':", res))) .then(() => broker.call("greeter.hello@ns-venus").then(res => broker.logger.info("Call 'greeter.hello@ns-venus':", res))) .then(() => broker.call("greeter.hello@ns-mars").then(res => broker.logger.info("Call 'greeter.hello@ns-mars':", res))) .catch(err => broker.logger.error(err));
delayed() { return this.Promise.resolve() .delay(6000) .then(() => this.actions.find()); }
test('expired data', async t => { const alfy = createAlfy(); alfy.cache.set('expire', {foo: 'bar'}, {maxAge: 5000}); t.true(alfy.cache.has('expire')); t.deepEqual(alfy.cache.get('expire'), {foo: 'bar'}); await delay(5000); t.false(alfy.cache.has('expire')); t.falsy(alfy.cache.get('expire')); t.falsy(alfy.cache.store.expire); });
async handler(ctx) { this.logger.info("Event received.", ctx.params); await this.Promise.delay(_.random(500, 2500)); this.logger.info("Post created.", ctx.params); }
//arrghghh new TWEEN.Tween({x: 0, y: 0}) .to({x: 50, y: 50}, 2000) .easing( TWEEN.Easing.Elastic.Out ) .onUpdate(function(){ _this.marker.scale.set(this.x, this.y); }) .delay((this.previous ? _this.opts.drawTime : 0)) .start();
beforeAll(() => { return master1.start() .then(() => slave1.start()) .delay(100) .then(() => clock = lolex.install()); });
t('Cursor works', async() => { const order = [] await sql`select 1 as x union select 2 as x`.cursor(async(x) => { order.push(x.x + 'a') await delay(100) order.push(x.x + 'b') }) return ['1a1b2a2b', order.join('')] })
test('connection of transaction terminated while in an idle state is rejected (at the end of the transaction)', async (t) => { const pool = createPool(t.context.dsn); await pool.connect(async (connection) => { await connection.query(sql`SET idle_in_transaction_session_timeout=500`); const error = await t.throwsAsync(connection.transaction(async () => { await delay(1000); })); t.true(error instanceof BackendTerminatedError); }); await pool.end(); });
it("destroy mail on-the-fly to node1", () => { servicesChanged.mockClear(); H.removeServices(node1, ["mail"]); return Promise.resolve().delay(100).then(() => { expect(H.hasService(master, "mail")).toBe(false); expect(H.getActionNodes(master, "mail.send")).toEqual([]); expect(servicesChanged).toHaveBeenCalledTimes(1); }); });
async "some.thing"(ctx) { this.logger.info(" ---- event triggered", ctx.eventName); await this.Promise.delay(1000); this.logger.info(" ---- event finished", ctx.eventName); }
async hello(ctx) { await this.Promise.delay(Math.random() * 100); ctx.emit("something.happened", { a: 5 }); return "Hello Metrics"; }
async "5"(ctx) { this.logger.info(`${ctx.action.name} begin. ID: ${++c2}`); await this.Promise.delay(5 * 1000); this.logger.info(`${ctx.action.name} end. ID: ${c2}`); }