npm-publish-stream

1.0.2 • Public • Published

NpmPublishStream

Build Status

A Node.js ReadableStream that emits data for each module published to npm, in near-realtime.

NPM

NpmPublishStream uses simple polling against the npm registry server to fetch data about publish events

Example

const NpmPublishStream = require('npm-publish-stream')
    , colorsTmpl = require('colors-tmpl')
 
    , outf = colorsTmpl('{green}{bold}%s{/bold}@%s{/green} <{yellow}http://npm.im/%s{/yellow}>: %s')
    , desclength = 70
 
function shorten (s) {
  return s.length <= desclength ? s : s.substring(0, desclength) + '...'
}
 
new NpmPublishStream()
  .on('data', function (data) {
    console.log(
        outf
      , data.id
      , data.doc['dist-tags'].latest
      , data.id
      , shorten(data.doc.description || '')
    )
  })
  .on('error', console.log)

And we get an endless stream of npm published packages:

Example

API

There is only a constructor that makes a object stream. The constructor can take an options object though, the following properties are accepted::

  • 'startTime': a Date object specifying when you would like the stream to start from, this would normally be at some point in the past although not too far back unless you want to be flooded with data.
  • 'refreshRate': an integer specifying the length in milliseconds between each refresh from the npm registry. This is the polling-frequency and you can increase or decrease it from the default 30000 (30s).
  • 'hostname': a string if you wish to specify a different registry other than the global npm registry.
  • 'port': an integer if you wish to specify a different registry other than the global npm registry.

Inspired by @bcoe's npm-tweets which runs on Twitter.

Licence

Super Simple Blog Loader for Node.js is Copyright (c) 2013 Rod Vagg @rvagg and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.

Readme

Keywords

Package Sidebar

Install

npm i npm-publish-stream

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • rvagg