Created
July 19, 2011 03:51
-
-
Save michaelficarra/1091267 to your computer and use it in GitHub Desktop.
another TameJS example rewritten in imaginary-coffeescript-with-defer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{resolve} = require "dns" | |
do_one = (host, cb) -> | |
(err, ip) <- resolve host, "A", * | |
console.log if err then "ERROR! #{err}" else "#{host} -> #{ip}" | |
cb() if typeof cb is 'function' | |
do_all = (hosts) -> | |
defer | |
for host, i in hosts | |
do_one host, null | |
return | |
do_all process.argv[2..] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dns = require("dns"); | |
function do_one (ev, host) { | |
var err, ip; | |
twait { dns.resolve (host, "A", mkevent (err, ip));} | |
if (err) { console.log ("ERROR! " + err); } | |
else { console.log (host + " -> " + ip); } | |
ev(); | |
} | |
function do_all (lst) { | |
twait { | |
for (var i = 0; i < lst.length; i++) { | |
do_one (mkevent (), lst[i]); | |
} | |
} | |
} | |
do_all (process.argv.slice (2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment