-
-
Save tim-smart/342765 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
asyncFunction: (x, y, z) ~> | |
yield | |
readFirstFile: (dir, ~, error) ~> | |
[err, files]: fs.readdir dir, ~ | |
return error(err) if err | |
[err, out]: fs.readFile files[o], ~ | |
return error(err) if err | |
yield content | |
content: fs.readFirstFile dir, ~, (err) -> sys.puts err | |
cacheData: (data) -> | |
[code, message]: backend.cache data, ~ | |
log(message) if code is 'error' | |
map: (list) ~> | |
res: [] | |
list.forEach (o) -> | |
res.push(if callback_given? then yield o else o) | |
list |
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
(function(){ | |
var asyncFunction, cacheData, map, readFirstFile; | |
asyncFunction = function asyncFunction(x, y, z, __callback) { | |
return __callback(); | |
}; | |
readFirstFile = function readFirstFile(dir, __callback, error) { | |
return fs.readdir(dir, (function(__this) { | |
var __func = function(err, files) { | |
if (err) { | |
return error(err); | |
} | |
return fs.readFile(files[0], (function(__this) { | |
var __func = function(err, out) { | |
if (err) { | |
return error(err); | |
} | |
return __callback(out); | |
}; | |
return (function() { | |
return __func.apply(__this, arguments); | |
}); | |
})(this)); | |
}; | |
return (function() { | |
return __func.apply(__this, arguments); | |
}); | |
})(this)); | |
}; | |
readFirstFile(dir, ((function(__this) { | |
var __func = function(content) { }; | |
return (function() { | |
return __func.apply(__this, arguments); | |
}); | |
})(this)), function(err) { | |
return sys.puts(err); | |
}); | |
cacheData = function cacheData(data) { | |
return backend.cache(data, (function(__this) { | |
var __func = function(code, message) { | |
if (code === 'error') { | |
return log(message); | |
} | |
}; | |
return (function() { | |
return __func.apply(__this, arguments); | |
}); | |
})(this)); | |
}; | |
map = function map(list, __callback) { | |
var res; | |
res = []; | |
list.forEach(function(o) { | |
if ((typeof __callback !== "undefined" && __callback !== null)) { | |
return res.push(__callback(o)); | |
} else { | |
return res.push(o); | |
} | |
}); | |
return list; | |
}; | |
})(); |
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
asyncFunction: (x, y, z, __callback) -> | |
__callback() | |
readFirstFile: (dir, __callback, error) -> | |
fs.readdir dir, (err, files) => | |
return error(err) if err | |
fs.readFile files[0], (err, out) => | |
return error(err) if err | |
__callback(out) | |
readFirstFile(dir, ((content) =>), (err) -> sys.puts err) | |
cacheData: (data) -> | |
backend.cache data, (code, message) => | |
log(message) if code is 'error' | |
map: (list, __callback) -> | |
res: [] | |
list.forEach (o) -> | |
if __callback? then res.push(__callback(o)) else res.push(o) | |
list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment