gkz / prelude-ls

prelude.ls is a functionally oriented utility library - powerful and flexible, almost all of functions are curried. It is written in, and is the recommended base library for, http://livescript.net
http://preludels.com/
MIT License
424 stars 57 forks source link

Nice to have function async-each #92

Open askucher opened 9 years ago

askucher commented 9 years ago
async-each = (func, arr) -->
      items = arr.slice!
      go = ->
          item = items.splice(0, 1).0
          if item?
             func item, go
      go!

example


[1,2,3] |> async-each (number,done)->
    find-user id: number, (err, user)->
        if user? and confirm 'Are you sure?'
            delete-user number, ->
                done!
anko commented 9 years ago

Sounds approximately like async.js::each |> flip |> curry.

I think async functions are out of scope for prelude-ls. Maybe it's time for a prelude-ls-async library?