1.2.1 • Published 3 years ago

sleepover v1.2.1

Weekly downloads
11
License
MIT
Repository
github
Last release
3 years ago

sleepover Tests

Step/loop & sleep methods

npm.io

Install

$ npm install sleepover

Usage

const { sleep, over, snooze } = require('sleepover')

sleep(500)
//=> delays execution for 500ms using Atomics.wait

over(30, (i) => console.log(i))
//=> loops 30 times, calling the provided method each time

async function something() {
  await snooze(500)
  //=> delays execution for 500ms using async/await + Promise + setTimeout
}

API

sleep(delay)

delay

Type: number

The number, in ms, that you'd like to delay execution of your code. (utilizes the Atomics API under the hood)

over(times, callback)

times

Type: number

The number of times you would like to loop/iterate.

callback

Type: function

The callback function you want executed on each iteration (it gets provided a single index argument).

snooze(delay)

delay

Type: number

The number, in ms, that you'd like to delay execution of your code. (utilizes a Promise + setTimeout)

atomics

Type: boolean

Result of the test conditions for defining Atomics support in the current environment. Use this to determine whether ot use sleep or snooze respectively.

License

MIT © Darcy Clarke

1.2.0

3 years ago

1.2.1

3 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago