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

replico

v1.0.1

Published

A REPL with support for await

Downloads

1

Readme

replico NPM version

A REPL with support for await

  • Track Promise results
  • Support for await keyword (expl: user = await db.User.get('foobar') will populate user variable once promise is resolved)

Installation

# For the command line "replico"
npm install --global replico

# And/or to use replico api in a project
npm install --save replico

Command line usage

replico

Api usage

Basic replacement of repl (see https://nodejs.org/dist/latest-v5.x/docs/api/repl.html#repl_class_replserver)

var replico = require('replico')

let replServer = replico({
  prompt: `${CBLUE}\u2234 ${CRESET}`,
  terminal: true
})

Define your own eval

var replico = require('replico')

let replServer = replico({
  prompt: `MyRepl> `,
  terminal: true
})

replServer.eval = function (cmd, context, filename, callback) {
  if (cmd === 'foo') {
    // ... your own implementation
    return callback(null, 'bar')
  } else if (/yield/.test(cmd)) {
    // Or use replico's eval (with bluebird-co):
    return replico.coEval.call(this, cmd, context, filename, callback)
  } else {
    // If you need it, superEval is a reference to the default repl eval
    return this.superEval(cmd, context, filename, callback)
  }
}

Plug it in your project

'use strict'
const net = require('net')
const replico = require('replico')

const CRESET = '\x1b[0m'
const CBLUE = '\x1b[34m'

var history = ['console.log("ok")']

net.createServer((socket) => {
  socket.write(`${CBLUE}Welcome${CRESET}\n`)

  function extendContext (context) {
    context.actions = {
      hello (who) {
        socket.write('OK ' + who + '\n')
      }
    }
  }

  let replServer = replico({
    prompt: `${CBLUE}\u2234 ${CRESET}`,
    input: socket,
    output: socket,
    terminal: true,
    history: history
  })

  replServer.on('exit', () => {
    history = replServer.history.slice()
    socket.end()
  })

  replServer.on('reset', extendContext)

  replServer.defineCommand('chist', {
    help: 'Clear history',
    action: function () {
      history = []
      replServer.history = []
      this.displayPrompt()
    }
  })

  extendContext(replServer.context)
}).listen(5423, function () {
  console.log('Ready on 5423')
})

Then you can use netcat or repli:

nc localhost 5423
# Or repli
repli localhost 5423

The MIT License • By Novadiscovery