Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>lazy resolved promise snippetsNew to Visual Studio Code? Get it now.
lazy resolved promise snippets

lazy resolved promise snippets

CDLL

|
344 installs
| (1) | Free
quick timeout/interval promise resolve snippets for vscode
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

lazyResolve Snippets

Quickly and easily generate timeout/interval promise resolve in javascript/typescript/coffeescript.

When coding javascript with

new Promise...
// with timeouter
new Promise((resolve, reject) => {
  setTimeout(() => {
    if (SOME_RESOLVE_CONDITIONS) resolve()
    else reject()
  }, 0)
})
// with interval
new Promise((resolve, reject) => {
  const LOOP = setInterval(() => {
    if (SOME_RESOLVE_CONDITIONS) {
      clearInterval(LOOP)
      resolve()
    }
    else if (SOME_REJECT_REASONS) {
      clearInterval(LOOP)
      reject()
    }
    else // todos...
  }, 0)
})

in typescript is the same as the javascript version.

Or when coding with coffeescript, when

new Promise...
# with timeouter
new Promise (resolve, reject)=>
  setTimeout ()=>
    if SOME_RESOLVE_CONDITIONS
    then resolve()
    else reject()
  , 0
# with interval
new Promise (resolve, reject)=>
  LOOP = setInterval ()=>
    if SOME_RESOLVE_CONDITIONS
      clearInterval LOOP
      resolve()
    else if SOME_REJECT_REASONS
      clearInterval LOOP
      reject()
    else # todos...
  , 0

For any question or suggestions, pls issue me @ faq

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft