Socket
Socket
Sign inDemoInstall

areply

Package Overview
Dependencies
7
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    areply

areply create read–eval–print-loop (repl) programs


Version published
Maintainers
1
Created

Readme

Source

areply

the read-eval-print-loop creator for node.js

features

you can add commands listen keypresses listen for user commands listen for user inputs save history

usage

create a simple repl

const areply = require("areply");
const repl = new areply(
  "history-file.txt",
  "my-repl-name",
  "my-repl-prefix",
  "my-repl-version",
  "my-repl-original-name",
  "my-repl-description"
);

explanation:

  • first arg is the history file to save the repl history
  • second arg is the name to show on questions
  • third arg is the prefix of commands
  • fourth arg is the version of repl
  • fifth arg is the original name of the repl
  • last arg is the description of repl

start the repl

repl.start();
  • this will start the repl process

create a command

repl.addCommand("command-name", "command-description", commandFunction);

explanation:

  • first arg is the name of command
  • second arg is the description of command
  • last arg is the function that will be called when user call the command

listening events

//keypress
repl.on("keypress", ({ ch, key }) => {
  // the ch is the char
  // the key is the key pressed info
});
//command
repl.on("command", (data) => {
  // this returns the command name and arguments parsed in string and array
});
//user input
repl.on("line", (line) => {
  //the full repl input
});

Keywords

FAQs

Last updated on 08 Apr 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc