Skip to content

Instantly share code, notes, and snippets.

@JiLiZART
Created May 29, 2016 13:24
Show Gist options
  • Save JiLiZART/813c2496397543af5f37a8641e890b43 to your computer and use it in GitHub Desktop.
Save JiLiZART/813c2496397543af5f37a8641e890b43 to your computer and use it in GitHub Desktop.
const values = [
() => console.log({moveCircleToMiddle: true}),
1000,
() => console.log({showGrayCircle: true}),
() => console.log({showMicrophone: true}),
5000,
() => console.log({moveCircleToTop: true}),
1000,
() => console.log({pulseGrayCircle: true}),
5000,
() => console.log({okText: 1}),
5000,
() => console.log({okText: 2}),
5000,
() => console.log({googleText: 1}),
5000,
() => console.log({googleText: 2})
];
const resolve = (el) => new Promise((resolve) => typeof el === 'function' ? resolve(el()) : setTimeout(resolve, el))
const sequence = (values) => values.reduce((prev, cur) => prev.then(resolve(cur)), Promise.resolve())
sequence(values);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment