Socket
Socket
Sign inDemoInstall

promirepl

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    promirepl

Promise infused REPL


Version published
Weekly downloads
1.6K
decreased by-19.01%
Maintainers
1
Install size
7.96 kB
Created
Weekly downloads
 

Changelog

Source

v2.0.1 (2019-03-02)

  • Put newline back after break.

Readme

Source

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({}));

Keywords

FAQs

Last updated on 02 Mar 2019

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