Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ok    = async () => true
  2. const fail  = async () => false
  3. const run   = async (list: Array<() => Promise<boolean>>): Promise<boolean> => {
  4.   for(let i = 0; i < list.length; i++) {
  5.     let result = await list[i]()
  6.     if(result) { return true }
  7.   } return false
  8. }
  9. //--------------------------------------------------
  10. // quiz: can you write this without async/await in
  11. //       a clean and concise fashion?
  12. //--------------------------------------------------
  13. run([fail, fail, fail, fail, fail, ok]).then(result => {
  14.   console.log(result)
  15. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement