Last active
August 29, 2015 13:57
-
-
Save jcoglan/9697712 to your computer and use it in GitHub Desktop.
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
// fs_stat :: String -> (Error -> Stat -> ()) -> () | |
var fs_stat = _.curry(fs.stat, 2); | |
// paths :: [String] | |
var paths = ['file1.txt', 'file2.txt', 'file3.txt']; | |
// tmp :: [(Error -> Stat -> ()) -> ()] | |
var tmp = paths.map(oneparam(fs_stat)); | |
// async.parallel :: [(Error -> a -> ()) -> ()] -> (Error -> [a] -> ()) -> () | |
// statsCallback :: (Error -> [a] -> ()) -> () | |
var statsCallback = _.partial(async.parallel, tmp); | |
statsCallback(function (err, stats) { | |
// use the stats | |
}); |
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
// fs_stat :: String -> Promise Stat | |
var fs_stat = node.lift(fs.stat); // node = require("when/node"); | |
// paths :: [String] | |
var paths = ['file1.txt', 'file2.txt', 'file3.txt']; | |
// tmp :: [Promise Stat] | |
var tmp = paths.map(oneparam(fs_stat)); | |
// statsPromises :: Promise [Stat] | |
var statsPromises = when.all(tmp); | |
statsPromises.then(function(stats) { | |
// use the stats | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
generators: