🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

npm-publish-stream

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-publish-stream

A ReadableStream emitting data for each new module published to npm

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

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.

Keywords

npm

FAQs

Package last updated on 28 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts