From 26b47ee094e01f65fd05c4e3fa79fb1b9dc61f7e Mon Sep 17 00:00:00 2001 From: David Humphrey Date: Thu, 3 Jan 2019 10:46:31 -0500 Subject: [PATCH] Remove src/encodings.js, use Buffer methods instead (#657) --- src/encoding.js | 4 ---- src/filesystem/implementation.js | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) delete mode 100644 src/encoding.js diff --git a/src/encoding.js b/src/encoding.js deleted file mode 100644 index 45feceb..0000000 --- a/src/encoding.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - encode: string => Buffer.from(string), - decode: buffer => buffer.toString('utf8') -}; diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index 852a95b..79275ce 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -29,7 +29,6 @@ var XATTR_REPLACE = Constants.XATTR_REPLACE; var FS_NOMTIME = Constants.FS_NOMTIME; var FS_NOCTIME = Constants.FS_NOCTIME; -var Encoding = require('../encoding.js'); var Errors = require('../errors.js'); var DirectoryEntry = require('../directory-entry.js'); var openFiles = require('../open-files.js'); @@ -1827,7 +1826,7 @@ function readFile(context, path, options, callback) { var data; if(options.encoding === 'utf8') { - data = Encoding.decode(buffer); + data = buffer.toString('utf8'); } else { data = buffer; } @@ -1868,7 +1867,7 @@ function writeFile(context, path, data, options, callback) { data = '' + data; } if(typeof data === 'string' && options.encoding === 'utf8') { - data = Encoding.encode(data); + data = Buffer.from(data); } open_file(context, path, flags, function(err, fileNode) { @@ -1903,7 +1902,7 @@ function appendFile(context, path, data, options, callback) { data = '' + data; } if(typeof data === 'string' && options.encoding === 'utf8') { - data = Encoding.encode(data); + data = Buffer.from(data); } open_file(context, path, flags, function(err, fileNode) {