Skip to content

Instantly share code, notes, and snippets.

@minodisk
Last active December 19, 2015 08:39
Show Gist options
  • Select an option

  • Save minodisk/5926833 to your computer and use it in GitHub Desktop.

Select an option

Save minodisk/5926833 to your computer and use it in GitHub Desktop.
$.whenのまずい設計をラップ
do ->
$.extend
parallel: (ds) ->
d = new $.Deferred
$.when.apply($, ds)
.done if ds.length <= 1
(results...) -> d.resolve [ results ]
else
(results...) -> d.resolve results
.fail d.reject
d.promise()
parallelEach: (items, iterator) ->
$.parallel _.map items, iterator
@minodisk

minodisk commented Jul 4, 2013

Copy link
Copy Markdown
Author

↑これって全部jsDeferredのパクリ。jsDeferredの設計が綺麗すぎるだけに$.Deferredの設計のまずさが引き立つ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment