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

node-prompt

v0.2.2

Published

A customizable command prompt for node applications, locally or over the net.

Downloads

18

Readme

node-prompt

node-prompt lets you control a node application directly from another computer, using a REPL interface.

Usage

Getting started
var prompt = require('node-prompt').stdin({prompt: '> '}); // Read from stdin

// *** OR ***

var prompt = require('node-prompt').net({ // Read from a network connection
    prompt: '> ',
    port: 43210,
    allowMultipleClients: false
});

// The above options are the defaults
Set up some commands
prompt.command('getCurrentClients', function () {...});
prompt.command('doMyCustomAction', function () {...});
prompt.command('getUsageCPU', function () {...});
Or multiple commands at once
prompt.command({
	getCurrentClients: function () {...},
	doMyCustomAction: function () {...},
	getUsageCPU: function () {...}
});

Access the application

You can execute commands remotely by using the node-prompt CLI tool.

First, install the CLI tool:

sudo npm install -g node-prompt

Then connect to your node application, and start typing commands!

node-prompt myapplication.com:9000
> getUsageCPU
CPU usage at 2%
> doMyCustomAction 45 "this is a single argument"
You did a custom action with 2 arguments!

Synchronous and asynchronous return values

For synchronous commands, you can send back a response message by returning a string. If an error is thrown, that error message will be sent back as the response, instead.

You can only send response messages that are strings. If any other type of data is returned, an empty string is used instead.

There are two ways to have asynchronous commands...

Callbacks

If the first argument of the handler is named $callback, a node-style callback function will be passed as that argument. All other arguments will come after.

prompt.command('getUsername', function ($callback, emailAddress) {
    getUsername(emailAddress, $callback);
});

Promises

If the handler returns a promise (or promise-like object), its fulfillment value or rejection reason will be used as the response message.

prompt.command('getUsername', function (emailAddress) {
    return getUsername(emailAddress);
});