Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

repl8

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

repl8

Automatically generate your REPL commands by writing logic files

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

REPL8

Create your REPL by slotting REPL files and functionality into your import folder.

Installation

Firstly install the module via npm:

npm install repl8

Then require it into your application:

var repl8 = require('repl8');

We simply call the .start function and pass it in an options object:

repl8.start({
  src: __dirname + '/import', // This is required to tell repl8 where to load in our logic
  ignoreUndefined: true, 
  prompt: 'repl8> '
});

The options object takes the same options as the original nodejs .repl function, with the addition of the src option which points to where we will import our REPL commands. http://nodejs.org/api/repl.html#repl_repl_start_options

Writing Commands

Create a file in your import folder with the name of your command. In this example, we will create one called loop.js

This will immediately give our repl the command loop.

Now inside loop.js, lets make give it some functionality.

module.exports = function (max) {
  for (i = 0; i < max; i++)
  {
    console.log("woo " + i);
  }
}

Now restart our REPL and call our new loop function:

repl8> loop(3)
woo 0
woo 1
woo 2

FAQs

Package last updated on 17 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc