11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Coffee-script非同期関数色々。

Posted at

IcedCoffeeScript

CoffeeScriptそのものを拡張するIcedCoffeeScript、作者はtameJSを作った@maxtaco

host = "http://search.twitter.com/"
list = [key1, key2, key3]
res  = []
await for keyword, i in list
  url = "#{host}/search.json?q=#{keyword}&callback=?"
  $.getJSON url, defer res[i]
console.log JSON.stringify res

kriskowal / q

CommonJS Promise/A

host = "http://search.twitter.com/"
list = [key1, key2, key3]
tesk = []
res  = []
for keyword, i in list
  url = "#{host}/search.json?q=#{keyword}&callback=?"
  tesk[i] = $.getJSON url, (data) -> res[i] = data
Q.all(tesk).then -> console.log JSON.stringify res

mbostock / queue

D3の作者が作ったミニマルな同期関数ツール。
queueの引数で、なんとパラレリズム(同時に実行されるタスクの量)が調整出来ちゃいます。

host = "http://search.twitter.com/"
list = [key1, key2, key3]
res  = []
que = queue(3)
for keyword, i in list
  url = "#{host}/search.json?q=#{keyword}&callback=?"
  que().defer($.getJSON, url)
que.awaitAll (error, res...) ->
  console.log JSON.stringify res
11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?