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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@leonardvandriel/interact

v0.2.3

Published

Interactive node console, extended

Readme

Interact

Interactive node console, extended.

An interactive node console with auto-import, source reload, support for promises.

Installation

npm install @leonardvandriel/interact --save-dev

Create a configuration file console in the project root with content:

#!/usr/bin/env node
const interact = require('@leonardvandriel/interact')
interact.start()

Getting started

Start the console:

node console

Now run any node code:

> 1 + 1

Te result can be referred to with _:

> _ + 1

After making changes to the source, we can reload without restarting the console:

> .reload

NB: this reloads the sources referenced in module, but does not reload the configuration in the console file.

To get more details on the current configuration:

> .config

And for more in-console help:

> .help

All configuration is passed upon invoking interact.start(..) from console file:

const config = {}
config.useColor = true
interact.start(config)

More options can be found in the example console file. Internally we use Node's REPL module.

Import and reload

To import (require) modules, add module to the configuration:

const config = { module: {} }
config.module.fs = 'fs'
config.module.myclass = './lib/myclass'

After restarting (not reloading) the console, fs is available:

> fs.readFileSync('LICENSE', 'utf8')
> myclass.run()

When making changes to imported modules, a restart is not necessary. Instead we can reload the module:

> .reload
> .r

Perhaps there is additional informat that we want to make accessible in the REPL. This can be done by adding init to our configuration:

config.postInit = (context) => { context.myvar = 3 }

This variable is now accessible in the REPL:

> myvar
3

Reloading will delete the import cache and re-import the modules. Some modules contain state that will be lost after reloading. To persist module state, we can temporarily save it during the reloading:

config.preLoad = (context, temp) => { if (context.myclass) temp.database = context.myclass.database }
config.postLoad = (context, temp) => { if (temp.database) context.myclass.database = temp.database }

Promises

When evaluation results in a promise, this promise object is echoed instead of the result. We can capture all promises instead and await them:

config.capturePromise = true

This will assign an index to every promise and so it can be linked to the result later on:

> new Promise(r => setTimeout(r, 5000)).then(_ => 1234)
=> [1]

And 5 seconds later:

[1]: 1234

Often promises return almost immediately, which makes indexing unnecessary. To wait for 0.5 seconds, add to the configuration:

config.waitPromise = 500

Now simple promises are seamlessly evaluated:

> Promise.resolve(1234)
1234

History

The REPL history can be accessed with the up/down arrows. To persist this history across console runs, add to the configration:

config.historyLength = 100

This will store and reload history from the file .node_repl_history.

Make sure to add this path to .gitignore. History can also be store somewhere more centrally by changing the path:

config.historyFile = '/home/me/.node_repl_history'

Tests

npm test

License

Interact is licensed under the terms of the BSD 3-Clause License, see the included LICENSE file.

Authors

  • Leo Vandriel