Skip to content

Instantly share code, notes, and snippets.

@hallettj
Last active January 23, 2022 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallettj/0f50c26169173e8480a74e26104e2dfc to your computer and use it in GitHub Desktop.
Save hallettj/0f50c26169173e8480a74e26104e2dfc to your computer and use it in GitHub Desktop.
Lazily-evaluated promise example
// Run with: deno run lazy-promise.js
// See https://github.com/sindresorhus/p-lazy
import PLazy from "https://cdn.skypack.dev/p-lazy"
const a = new PLazy(resolve => {
console.log("this code does not execute")
resolve()
})
const b = new PLazy(resolve => {
console.log("this code executes when it is awaited")
resolve()
})
await b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment