lazy require fs

This commit is contained in:
Septs 2021-03-06 01:59:15 +08:00
parent d6937a7da2
commit 29d40186c9
No known key found for this signature in database
GPG Key ID: 6C253909AE7FC3A4

View File

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