all-the-packages
Version:
All the npm registry metadata as an offline event stream.
25 lines (20 loc) • 648 B
JavaScript
const fs = require('fs')
const path = require('path')
const JSONStream = require('JSONStream')
const mapSync = require('event-stream').mapSync
const EventEmitter = require('events')
const util = require('util')
function Emitter () { EventEmitter.call(this) }
util.inherits(Emitter, EventEmitter)
const emitter = module.exports = new Emitter()
fs.createReadStream(path.join(__dirname, 'skimdb.json'))
.pipe(JSONStream.parse('rows.*'))
.pipe(mapSync(function (pkg) {
emitter.emit('package', pkg.value)
}))
.on('end', function () {
emitter.emit('end')
emitter.emit('done')
emitter.emit('finished')
})