0.0.4 • Published 2 years ago
just-a-loop v0.0.4
Just a Loop 🔁
Just a Loop lets your making loops with intervals and timeouts easier in JavaScript.
Usage for Intervals 🎈
import { interval } from "just-a-loop"
interval(({ index }) => {
console.log(index)
}, { delayMs: 50, end: 10 })
The same with setInterval
let index = 0
const interval = setInterval(() => {
if (index >= 10) clearInterval(interval)
console.log(index)
index++
}, 50)
Usage for Timeouts 🎈
import { timeout } from "just-a-loop"
timeout(() => console.log("Hi"), { delayMs: 50 })
The same with setTimeout
const timeout = setTimeout(() => console.log("Hi"), 50)