npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spinner

v0.3.4

Published

Spawns child processes and allocates `process.env.PORT` for each.

Downloads

2,463

Readme

Spinner

Spin up node scripts bound to dynamic ports (forked from nploy)

$ npm install spinner

createRouter(opts)

Options:

  • range - Port range [7000..7099]
  • time - Time to idle [15]
  • debug - Output logs
  • routes - Hash of routing pairs (source -> target) [{}]
  • output - Determines how child process output is handled:
    • false - Will not capture child process output
    • "console" - Will pipe child process stdin/stderr to console.info/console.error
    • "process" - Will pipe child process stdin/stderr to process.stdin/process.stderr

Example:

var spinner = require('spinner');
var router = spinner.createRouter({ port: 5000, dir: '../test' });

router.setRoutes({
  'foo': 'a/index.js'
, 'goo': 'b/index.js'
});

router.getRoute('foo', function(err, route, child) {
  if (err) throw new Error(err);
  console.log('Use %s:%d to access "foo"', route.host, route.port);
  router.kill('foo', function(err) {
    console.log('"foo" is now dead');
    router.close();
  });
});

The router object has the following API.

Properties

  • range - Returns the port range configured in the router
  • idletime - Time in seconds to wait without a call to getRoute before the process is killed
  • options - Options object

setRoute(source, target), setRoutes(map)

target may be a path to a node.js script or an object with a script property (path to the script) and extra options passed to the forever module when starting the child process.

Update routes table with source -> script pair(s).

getRoute(source, callback)

Returns a route to a source. Callback is function(err, port, child) where port is the same port passed to the app in process.env.PORT.

clearRoute(source), clearRoutes([map])

Deletes route(s). If map is if not provided, all routes will be deleted

kill(source, callback)

Kills the process associated with source. callback is function(err).

close()

Shuts down the router. Namely, removes the idle timer.

getchild(source), getpid(source)

Returns the forever child of a source or it's PID.

Testing

Run tests:

npm test

Licence

MIT/X11

Author (nploy): George Stagas (@stagas)

Author (spinner): Elad Ben-Israel (@eladb)