Merge pull request #40 from septs/master

lazy require fs
This commit is contained in:
Ruben Vermeersch 2021-03-09 09:21:07 +01:00 committed by GitHub
commit 11b1affe5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,3 @@
var fs = require('fs');
function trim(string) { function trim(string) {
return string.replace(/^\s+|\s+$/g, ''); return string.replace(/^\s+|\s+$/g, '');
} }
@ -13,7 +11,7 @@ var PO = function () {
}; };
PO.prototype.save = function (filename, callback) { PO.prototype.save = function (filename, callback) {
fs.writeFile(filename, this.toString(), callback); require('fs').writeFile(filename, this.toString(), callback);
}; };
PO.prototype.toString = function () { PO.prototype.toString = function () {
@ -65,7 +63,7 @@ PO.prototype.toString = function () {
}; };
PO.load = function (filename, callback) { PO.load = function (filename, callback) {
fs.readFile(filename, 'utf-8', function (err, data) { require('fs').readFile(filename, 'utf-8', function (err, data) {
if (err) { if (err) {
return callback(err); return callback(err);
} }