Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-repl

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-repl

Node repl that supports "await".

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
808
decreased by-61.17%
Maintainers
2
Weekly downloads
 
Created
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

Package last updated on 03 Sep 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc