pretty-repl
Extends repl.REPLServer to allow for a colorize function
Last updated 2 months ago by addaleax .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pretty-repl 
SYNC missed versions from official npm registry.

Pretty REPL

Node.js CI

An extension of the Node REPL (repl.REPLServer) that applies syntax highlighting as the user types.

Pretty REPL Screenshot

How to use it

Install the package:

$ npm install --save pretty-repl

Use the package:

const repl = require('pretty-repl');

const options = {
    prompt: '→ '
};

repl.start(options);

options is an an object with the same options as repl.REPLServer.

Additionally, it's possible to pass an additional colorize property to the options object:

{
    colorize: function (str) {
        // str is the the string in input.
        // the function should return the string that has been colorized to output in the REPL.
    }
}

Known issues

  • The implementation in Node.js versions 11 and 12, this module works by monkey-patching the Interface prototype (readline module). If you use readline (or a module that depends on it) somewhere else, you may want to test everything thoroughly. In theory, there should be no side effects.
  • For Node.js versions older than 11, this module does nothing.

Credits

Pretty repl is inspired and includes code fragments from:

Current Tags

  • 2.4.0                                ...           latest (2 months ago)

14 Versions

  • 2.4.0                                ...           2 months ago
  • 2.3.1                                ...           3 months ago
  • 2.3.0                                ...           9 months ago
  • 2.2.1                                ...           9 months ago
  • 2.2.0                                ...           9 months ago
  • 2.1.3                                ...           9 months ago
  • 2.1.2                                ...           9 months ago
  • 2.1.1                                ...           9 months ago
  • 2.1.0                                ...           9 months ago
  • 2.0.1                                ...           9 months ago
  • 2.0.0                                ...           9 months ago
  • 1.0.2                                ...           9 months ago
  • 1.0.1                                ...           9 months ago
  • 1.0.0                                ...           9 months ago

Copyright 2014 - 2017 © taobao.org |