Skip to content

Instantly share code, notes, and snippets.

@matehat
Created March 24, 2010 18:11
Show Gist options
  • Save matehat/342572 to your computer and use it in GitHub Desktop.
Save matehat/342572 to your computer and use it in GitHub Desktop.
(function(){
var asyncFunction, cacheData, map, readFirstFile;
asyncFunction = function asyncFunction(x, y, z, __callback) {
// some code, and eventually ...
return __callback();
// initiated with an empty `yield`
};
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;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment