Skip to content

Commit

Permalink
quick promise practice
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgtwo committed Jun 6, 2024
1 parent 97f93a8 commit 79c62d6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions apply/setinterval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// const setCancellableInterval = (cb, dur, ...args) => {

// const timerId = setInterval(() => cb.apply(null, args), dur)
// return () => clearInterval(timerId)
// }

// let i = 0;

// const cancel = setCancellableInterval(() => {
// i++;
// }, 10);

// cancel(); // Called at t = 25
// console.log(i)



function promiseFactory(cb) {
return new Promise(cb)
}

(async function () {
const boom = await promiseFactory((res, rej) => setTimeout(() => res(123), 2000))
console.log(boom)
})()

0 comments on commit 79c62d6

Please sign in to comment.