Skip to content

Instantly share code, notes, and snippets.

@griffinmichl
Created May 16, 2016 20:09
Show Gist options
  • Save griffinmichl/42e449098db9e065f36a0d2f664f5e1c to your computer and use it in GitHub Desktop.
Save griffinmichl/42e449098db9e065f36a0d2f664f5e1c to your computer and use it in GitHub Desktop.
const task1 = done => setTimeout(_ => {console.log('1'); done()}, 100)
const task2 = done => setTimeout(_ => {console.log('2'); done()}, 50)
const task3 = done => setTimeout(_ => {console.log('3'); done()}, 25)
const taskRunner1 = queue(1)
taskRunner1.push(task1)
taskRunner1.push(task2)
taskRunner1.push(task3)
// 1
// 2
// 3
const taskRunner2 = queue(2)
taskRunner2.push(task1)
taskRunner2.push(task2)
taskRunner2.push(task3)
// 2
// 3
// 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment