fs: getOption to populate passed in default values
In fs.js
, the getOption
can be improved to populate the option object with the passed in defaultOptions if the default options are not there in the original option object. This way we don't have to do options.flag || 'w'
etc.
For example in the fs.writeFile
fs.writeFile = function(file, options, cb) {
options = getOptions(options, {flag: 'w'});
/* later somewhere */
flags = options.flags || 'w'
/* could have just been the below had getOptions populated the default values if it did not exist */
flags = options.flags
}
Similar patterns are present in few more parts of the fs
module
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines
Affected core subsystem(s)
fs, test