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

nvb

v0.1.0

Published

a frugal utility and library for awaiting HTTP callbacks from builds etc.

Downloads

5

Readme

nvb

This utility lets you write or launch a process that will wait for a given set of clients to connect to it. HTTP-based Promise.all() for the console!

Each client ("part") is identified by a name. When all clients have connected, the listener ends its job and yields success (for CLI, this means exit 0; for nvb.listen() it's a resolved promise).

Install

# for a global install as root, use:
npm install -g nvb
# or if you prefer a local install for use in your project, with CLI tools in ./node_modules/.bin :
npm install nvb --save

Use from CLI

In one terminal:

nvb clientA clientB
# The process does not exit until you've called both clients
# Also, on timeout, the exit code will be 2 - you can inspect the last command's exit code by executing the below:
echo $?

In another:

nvb-client clientA
nvb-client clientB

The main nvb process should exit after you've called both clientA and clientB. Try that again, but call the client with the same name twice or a name that has not been declared on the server and observe what happens.

Also add some auth and configure a custom port, and pass two fancy names to wait for:

export NVB_PORT=15678
export NVB_TOKEN=super-secret-stuff
export NVB_TIMEOUT=10000
nvb mainApp backgroundWorker &
# Børk børk
NVB_TOKEN=totally-forgot nvb-client backgroundWorker
# Only the main app is having a good day today:
nvb-client mainApp
# In a sec, you're going to see nvb complain about the background worker missing

Use from Node

// On the server that will listen to the minions waking up:
require('nvb').listen({ parts: [ 'minion1', 'minion2' ] }).then(onFulfilled, onRejected);

// On the clients:
require('nvb').notify({ name: 'minion1' });

nvb.listen([ options ]) → Promise

Start listening for all clients to connect.

nvb.notify([ options ]) → Promise

Connect to an nvb server and indicate the client's presence.

Options

options.parts : Array.<string>

The set of client names to await. When all of them have connected, the promise resolves. Only used on the server.

options.address : string

The address to listen on or to connect to. By default, :: is used on the server (all interfaces) and ::1 on the client (localhost).

options.port : number

The port to listen on or to connect to. By default, 6786 or whatever is passed in environment variable NVB_PORT.

options.token : string

If passed, uses a string value to authenticate against the server using an X-NVB-Token. On the server, this parameter sets the required token. Defaults to env variable NVB_TOKEN - unused if empty.

options.timeout : number

Sets the timeout (ms) for connecting and listening. By default, 10000 on the client and 60000 on the server.

License

MIT