Fix the async calls.

This is a breaking change. But that's okay, the previous behavior for
async was just plain wrong and would crash the entire node process,
which is unacceptable. A major version bump will be needed to release
this.
This commit is contained in:
Ruben Vermeersch 2013-12-17 14:30:07 +01:00
parent e61e535a79
commit fe2e17990a

View File

@ -12,15 +12,7 @@ var PO = function () {
};
PO.prototype.save = function (filename, callback) {
fs.writeFile(filename, this.toString(), function (err) {
if (err) {
throw err;
}
if (callback) {
callback();
}
});
fs.writeFile(filename, this.toString(), callback);
};
PO.prototype.toString = function () {
@ -54,10 +46,10 @@ PO.prototype.toString = function () {
PO.load = function (filename, callback) {
fs.readFile(filename, 'utf-8', function (err, data) {
if (err) {
throw err;
return callback(err);
}
var po = PO.parse(data);
callback(po);
callback(null, po);
});
};