Skip to content

Instantly share code, notes, and snippets.

@watson
Last active February 4, 2017 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save watson/ff582ff3fddd15964d0a75e486a20cdc to your computer and use it in GitHub Desktop.
Save watson/ff582ff3fddd15964d0a75e486a20cdc to your computer and use it in GitHub Desktop.
Run through the entire npm CouchDB database and list each change-set larger than a previous set
'use strict'
var ChangesStream = require('changes-stream')
var block = 0
var biggest = 0
var changes = new ChangesStream({
db: 'https://replicate.npmjs.com',
include_docs: true,
since: 0,
highWaterMark: 4 // reduce memory - default is 16
})
changes.on('data', function (change) {
block++
var data = JSON.stringify(change)
var size = Buffer.byteLength(data)
if (size > biggest) {
biggest = size
console.log('block: %d, seq: %d, bytes: %d, id: %s', block, change.seq, size, change.id)
}
})
block: 1, seq: 2, bytes: 114943, id: _design/scratch
block: 3865, seq: 3905, bytes: 177588, id: meta-objects
block: 4680, seq: 4725, bytes: 185544, id: everyauth-goellan
block: 5311, seq: 5366, bytes: 201330, id: transmit
block: 6853, seq: 6928, bytes: 220510, id: applitude
block: 7824, seq: 7908, bytes: 221841, id: cloudflash-firewall
block: 7874, seq: 7960, bytes: 221927, id: shorewall
block: 8214, seq: 8302, bytes: 235047, id: pilotfish
block: 8926, seq: 9026, bytes: 388699, id: nodefront
block: 9745, seq: 9857, bytes: 1133166, id: bvm
block: 19322, seq: 19551, bytes: 1141016, id: rrestjs
block: 22282, seq: 22543, bytes: 2159683, id: yarnlang
block: 261119, seq: 281371, bytes: 4605982, id: botfather
block: 393659, seq: 848207, bytes: 6009073, id: npm
block: 412481, seq: 903154, bytes: 14194322, id: vs-deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment