Socket
Socket
Sign inDemoInstall

async-repl

Package Overview
Dependencies
10
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-repl

Node repl that supports "await".


Version published
Weekly downloads
332
increased by5.4%
Maintainers
2
Install size
3.96 MB
Created
Weekly downloads
 

Readme

Source

async-repl

This uses the native async/await support in Node 7.x and newer to let you await promises in the repl ("read-eval-print-loop" -- the interactive Node command line).

Install

npm install -g async-repl

Examples

$ async-repl
async> 1 + 2
3
async> 1 + await new Promise(r => setTimeout(() => r(2), 1000))
3
async> let x = 1 + await new Promise(r => setTimeout(() => r(2), 1000))
undefined
async> x
3
async>
const repl = require('repl');
const stubber = require('async-repl/stubber');
const replInstance = repl.start({ prompt: 'my-fancy-repl> ' });
stubber(replInstance);

Caveats

  • This tool doesn't support multi-line input.

  • Top-level object destructuring assignment like:

      let { x } = await someThing()
    

    doesn't currently work due to a bug in recast (see test suite), but you can workaround like:

      ({x} = await someThing())
    
  • We necessarily resolve the top-level expression promise for you, so if you don't want to wait for resolution you should make sure you're not returning the promise as an expression.

      # This will not block because it's a statement
      let myPromise = makePromise()
    
      # This will block because it's an expression
      otherPromise = makePromise()
    
      # This will block because now we're using the promise value as an expression
      myPromise
    
  • const variables in the repl scope can be overridden

    async> const a = 1
    undefined
    async> a = 2
    2
    

Keywords

FAQs

Last updated on 03 Sep 2018

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