test('Promise.bind - promise, without value', function (t) { t.plan(4) twice(function () { var trans = ins.startTransaction() var p = resolved('foo') p = Promise.bind(p) p.then(function (result) { t.strictEqual(result, undefined) t.strictEqual(ins.currentTransaction.id, trans.id) }) }) })
Promise.all(promises) .bind(this) .then(function() { this.request(method, url, data, callback); })
async function init() { const conn = await amqp.connect('amqp://localhost'); process.once('SIGINT', conn.close.bind(conn)); ch = await conn.createChannel(); logger.info('client has connected to mq'); await ch.assertQueue(queueName, { durable: false }); }
constructor (server, roomName) { super() this.server = server this.roomName = roomName this.name = this.roomName this.historyMaxGetMessages = this.server.historyMaxGetMessages this.redis = this.server.redis this.exitsErrorName = 'roomExists' this.prefix = 'rooms' mixin(this, StateOperations, this.name, this.exitsErrorName, this.redis, this.makeKeyName.bind(this), this.stateReset.bind(this)) }
constructor() { this.queue = config.get("consumer").queue; rabbitMq.subscribeQueue(this.queue, this.handleMessage.bind(this)); logger.info("Created Consumer for : ", this.queue); }
// helper methods function createSchools(dynamoDB, geohashClient) { // add some schools return _.reduce(schools, (promise, school) => { const location = school.Location; return promise.then(() => { return geohashClient .putAsync('Schools', school.Item, location.lat, location.lng) .then(() => console.log('added school: %s', school.Item.name)); }); }, Promise.bind(this)); }
constructor (server, userName) { super() this.server = server this.userName = userName this.name = this.userName this.prefix = 'users' this.exitsErrorName = 'userExists' this.redis = this.server.redis mixin(this, StateOperations, this.name, this.exitsErrorName, this.redis, this.makeKeyName.bind(this), this.stateReset.bind(this)) }
this.getGeneratedKey().bind(this).then(function(key) { return this.getStorageAdapter().get(key); }).then(function(doc) { this.setCAS(doc.cas); this.setData(doc.value); return this; })
/** * Loads the Package plugin and uses it to create the deployment package for all * Lambda functions in the service. */ packageFunctions() { const plugin = this.getPlugin("Package"); if (!plugin) { throw new Error("Could not find Package plugin"); } this.serverless.cli.log("Packaging functions"); return new BbPromise.bind(plugin) .then(plugin.cleanup) .then(plugin.validate) .then(plugin.packageService); }
const syncChartKeys = function () { const listOptions = { Bucket : this.options.input.bucket, Delimiter : '/', Prefix : '' }; if (this.request.payload.subRepo) { listOptions.Prefix = `${this.request.payload.subRepo}/`; } return Promise .resolve() .bind(this) .then(pageResultsAsync.bind(this, listOptions)) .then(function () { this.server.log(['debug'], `Found ${this.syncChartKeys.length} chart(s)`); }); }
hubClient.open() .then(hubClient.getPartitionIds.bind(hubClient)) .then(pids => pids.map(pid => hubClient.createReceiver('$Default', pid, { 'startAfterTime': Date.now() }) .then(receiver => { console.log('Created partition receiver: ' + pid) receiver.on('errorReceived', err => console.log(err.message)); receiver.on('message', m => console.log(JSON.stringify(m.body))); }) ) ) .catch(err => console.log(err.message));
test('Promise.bind - non-promise, without value', function (t) { t.plan(6) function Obj () {} twice(function () { var trans = ins.startTransaction() var obj = new Obj() var n = obj.n = Math.random() var p = Promise.bind(obj) p.then(function (result) { t.strictEqual(this.n, n) t.strictEqual(result, undefined) t.strictEqual(ins.currentTransaction.id, trans.id) }) }) })
test('Promise.bind - with value', function (t) { t.plan(6) function Obj () {} twice(function () { var trans = ins.startTransaction() var obj = new Obj() var n = obj.n = Math.random() var p = resolved('foo') p = Promise.bind(obj, p) p.then(function (result) { t.strictEqual(this.n, n) t.strictEqual(result, 'foo') t.strictEqual(ins.currentTransaction.id, trans.id) }) }) })
async function init() { const conn = await amqp.connect('amqp://localhost'); process.once('SIGINT', conn.close.bind(conn)); ch = await conn.createChannel(); logger.info('server has connected to mq'); ch.prefetch(1); }
async function init() { const conn = await amqp.connect('amqp://localhost'); process.once('SIGINT', conn.close.bind(conn)); ch = await conn.createConfirmChannel(); logger.info('client has connected to mq'); await ch.assertQueue(queueName, { durable: false }); }