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

hot-repl

v0.2.5

Published

inspect state, replace functions, kill app, all at the distance of a TCP connection

Downloads

2

Readme

Intro

hot-repl aims at offering the developer a way in the app while its running, exposing a REPL via TCP.

For it to work you must respect these constraints:

  • your program must have its state unified in a state object named ST.

  • all relevant functions in use must be defined in another object, named FN.

  • functions defined in FN must only refer/change other FN functions and/or ST members.

If you respect these rules, fire hot-repl by passing it ST, FN and a port number.

Now when you run your app it will keep the TCP port opened.

If you connect to it via telnet, you can hotswap any of their members.
That means you can turn on debug vars, inspect the app state, patch faulty functions, etc.

API

the hot-repl exports a function with the following arguments:

  • {Object} ST - state object
  • {Object} FN - functions object
  • {Number} [tcpPort]=5566 - TCP port to use
  • {Boolean} [debug]=false - if trueish logs TCP port and TCP client connections and disconnections

Install

npm install hot-repl

Tutorial

The example-server-app.js defines ST as {a:1, b:2} and defines FN as the functions add and atEverySecond.

Then it sets the app to call FN.atEverySecond every 1000 ms.

add is a proper sum of arguments 1 and 2.

atEverySecond calls a with state vars a and b.

So by now you should be guessing that by calling the app you get 3 printed every second.

So now you want to change stuff, right?

Fire telnet:

telnet 127.0.0.1 5566

then call ST

> ST
< {a:1, b:2}

ST is OK. Let's change a...

> ST.a = 4
< 4

Now the console should read 6 (4+2)

So let's now change the add function...

> FN.add = function() { return 42; }
< [Function]

Now the console reads 42 because its calling add which ignores its arguments and returns 42.

So how would we get rid of that repeatable task? You just assign the interval timer to a variable in ST. Then you could clearInterval(ST.timer)

To print stuff in the server just:

console.log('hi')

And to kill it:

process.exit(0);