Detalhes do pacote

promirepl

building511.6kMIT2.0.1

Promise infused REPL

repl, promises

readme (leia-me)

promirepl

A promise infused REPL.

Promirepl provides a Node.js REPL which will automagically unwrap promise values. It also is Node module, with a function that can add these magical promise inspecting capabilities to your own custom REPLs.

This allows you to use promise based APIs from the REPL just as easily as old fashioned synchronous APIs, without a lot of messing around with callbacks and console.log to get at asynchronous values from the REPL.

Installation

Promirepl can be installed with npm install -g promirepl. This installs the prominode executable, which starts a Node.js REPL that has magical promise unwraping capabilities.

Usage

$ prominode

Whenever a value evaluates to a promise (well, technically a thenable), promirepl will wait for the promise to resolve.

> Promise.resolve('hello')
'hello'

> new Promise((resolve) => {
... setTimeout(() => { resolve('some time later'); }, 3000);
... })
'some time later'

If the promise is rejected, it will evaluate as a thrown error.

> Promise.reject(new Error('boom'))
Error: boom
    at repl:1:16
    at REPLServer.defaultEval (repl.js:135:27)

If you would like to stop waiting on a promise, hit escape.

> new Promise(function () {})
Hit escape to stop waiting on promise
break.

If you would like to disable promise unwrapping, enter the .promise command.

> .promise
Promise auto-eval disabled

> Promise.resolve('hello')
{}

> Promise.reject(new Error('boom'))
{}

Programmatic Usage

If you would like to use promirepl within your own custom REPL, use the exported promirepl function.

const customRepl = createCustomRepl();
const { promirepl } = require('promirepl');
promirepl(customRepl.start({}));

changelog (log de mudanças)

promirepl

v2.0.1 (2019-03-02)

  • Put newline back after break.

v2.0.0 (2019-03-02)

  • Over four years isn't too long between releases, isn't it?
  • Requires at least Node 8 now; 6 is about to hit EOL
    • Maybe it will work on older versions, but I won't be testing it
  • Remove extra . from the help display of .promise
  • Share history between the node repl and prominode on Node 11.10.0 and later

1.0.1 (2014-11-15)

  • Add info to package.json

1.0.0 (2014-11-15)

  • Initial release