Potential rewrite of same change. seeking review

@humphd the change you asked for said to rule out undefined, but now that I think about it, isn't the fact that it is undefined the problem? The object has no such attribute, and thats why it breaks. I have written a new way of checking this and would like your opinion on it.

I could just undone the == -> === change but I expect that there might be a good reason not to do that.
This commit is contained in:
MuchtarSalimov 2018-10-09 20:17:27 -04:00 committed by GitHub
parent df57e35500
commit 7ad1312830
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -1870,12 +1870,17 @@ function appendFile(fs, context, path, data, options, callback) {
if(!flags) {
return callback(new Errors.EINVAL('flags is not valid', path));
}
if (typeof options === 'object' && options.encoding === undefined ) {
options.encoding = 'utf8';
}
data = data || '';
if(typeof data === 'number') {
data = '' + data;
}
if(typeof data === 'string' && (options.encoding === null || options.encoding === 'utf8')) {
if(typeof data === 'string' && options.encoding === 'utf8') {
data = Encoding.encode(data);
}