New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mybug/wait

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mybug/wait

await anything synchronously

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

wait

await anything synchronously.

usage

wait(awaitable)

params awaitable: an awaitable value

return the promiseValue just like using await

example

const wait = require('@mybug/wait')
const su = require('superagent')
let resp = wait(su('https://api.npms.io/v2/search?q=scope:mybug')) //async http request 
console.log(resp.body) // result is printed synchronously

use together with @mybug/awaitor

wait can resolve an operation which returns a promise, but not an operation which needs a callback.

you can either:

  1. wrap the operation to return a promise
  2. just call the operation, use @mybug/awaitor as callback, like below
const awaitor = require('@mybug/awaitor')
const wait = require('@mybug/wait')

let cb = awaitor()
foo(1,2,cb) // whenever a callback is needed, just use cb
let result = wait(cb) //result is an array, containing the args cb received
console.log(result) // [3]

function foo(a,b,cb){
  setTimeout(()=>cb(a+b),1000)
}

also useful as debug tool

When being paused on a breakpoint, you can evaluate expressions but no async operations can be evaluated immediately.

Use @mybug/wait to solve the problem, you will get the result of the async operation while still being paused on that breakpoint.

You don't even have to require @mybug/wait in your code. Just install @mybug/wait as a devDependency. When debugging, evaluate global.wait=process.mainModule.require('@mybug/wait'). Then by evaluating wait(anyAsyncOperation()), you will see the async operation gets done and returned.

Keywords

FAQs

Package last updated on 28 Dec 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