Natural Pacifist Manatees
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

stop.js

0.2.3 • Public • Published

version Build Status codecov

Stop.js

The Promise based setTimeout and setImmediate for the modern browsers and node.

‼️Important

stop.js change to use milliseconds as default unit. #1

Browser Supported

Why

In ES7 async/await is awesome, but that only supported with Promise.

Installation

npm i --save stop.js

Includes babel-polyfill before use async and await

Before

console.log(1)
setTimeout(()=>{
  console.log(2) // slow than 5 secs
}, 5000)

After

import stop from 'stop.js'
 
async function asyncFunc() {
  console.log(1)
  await stop(5000)
  console.log(2) // slow than 5 secs
}
 
asyncFunc()

setImmediate

0 is default, it'll call the YuzuJS/setImmediate library

console.log(1)
setImmediate(()=>{
  console.log(2)
})

same as

console.log(1)
await stop(0)
console.log(2)

or pass nothing

console.log(1)
await stop()
console.log(2)

API

stop([ms = 0])

install

npm i stop.js

Downloadsweekly downloads

0

version

0.2.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability