insertOne(item, cb) { item[idField] = new ObjectId(); this.items[item[idField]] = item; cb(undefined, { ops: [item] }); }
insertMany(items, cb) { for (let i = 0; i < items.length; i += 1) { const item = items[i]; item[idField] = new ObjectId(); this.items[item[idField]] = item; } cb(undefined, items); }
var next = function(err, data) { self._isConnecting = false; if (cb) { cb(err, data); } }
stream.once('readable', function() { var message = stream.read(); t.notEqual(message, null); t.ok(Buffer.isBuffer(message.value)); t.equal('test', message.value.toString()); t.equal('testkey', message.key); t.equal(typeof message.offset, 'number'); stream.pause(); cb(); });
setImmediate(function() { cb(null, [{ value: Buffer.from('test'), offset: 1 }]); });
test('sync false logs everything when calling flushSync', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'syncfalse-flush-exit.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(actual.match(/hello/), null) isNot(actual.match(/world/), null) })
client.setKeySerializer(function(_, cb) { t.deepEqual(_, v); setImmediate(function() { cb(new Error('even together we failed')); }); });
removeAllImages (cb) { this.listImages((err, images) => { if (err) { return cb(err, {}) } images.forEach((imageInfo) => { this.removeImage(imageInfo.Id, cb) }) }) }
/** * Scheduler job interface. * Will be called by the scheduler. */ run() { if (this.active) { this.getAndInvoke(this.cb) } }
test('with custom timestamp', async ({ is }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'custom-time.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') is(strip(actual).slice(0, 6), '[test]') })
client.setKeySerializer(function(_, cb) { keySerializerCalled = true; t.deepEqual(_, k); setImmediate(function() { cb(null, 'key'); }); });
test('final works without prior logging', async ({ isNot }) => { var actual = '' const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'final-no-log-before.js')]) child.stdout.pipe(writer((s, enc, cb) => { actual += s cb() })) await once(child, 'close') isNot(strip(actual).match(/WARN\s+: pino.final with prettyPrint does not support flushing/), null) isNot(strip(actual).match(/INFO\s+\(123456 on abcdefghijklmnopqr\): beforeExit/), null) })