fs: fix permanent deoptimizations
PR-URL: https://github.com/nodejs/node/pull/12456 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
e9c02c6762
commit
e8a429075f
12
lib/fs.js
12
lib/fs.js
@ -82,8 +82,8 @@ function getOptions(options, defaultOptions) {
|
||||
}
|
||||
|
||||
function copyObject(source) {
|
||||
const target = {};
|
||||
for (const key in source)
|
||||
var target = {};
|
||||
for (var key in source)
|
||||
target[key] = source[key];
|
||||
return target;
|
||||
}
|
||||
@ -320,7 +320,7 @@ fs.existsSync = function(path) {
|
||||
};
|
||||
|
||||
fs.readFile = function(path, options, callback) {
|
||||
callback = maybeCallback(arguments[arguments.length - 1]);
|
||||
callback = maybeCallback(callback || options);
|
||||
options = getOptions(options, { flag: 'r' });
|
||||
|
||||
if (handleError((path = getPathFromURL(path)), callback))
|
||||
@ -1216,9 +1216,7 @@ fs.futimesSync = function(fd, atime, mtime) {
|
||||
binding.futimes(fd, atime, mtime);
|
||||
};
|
||||
|
||||
function writeAll(fd, isUserFd, buffer, offset, length, position, callback_) {
|
||||
var callback = maybeCallback(arguments[arguments.length - 1]);
|
||||
|
||||
function writeAll(fd, isUserFd, buffer, offset, length, position, callback) {
|
||||
// write(fd, buffer, offset, length, position, callback)
|
||||
fs.write(fd, buffer, offset, length, position, function(writeErr, written) {
|
||||
if (writeErr) {
|
||||
@ -1249,7 +1247,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, position, callback_) {
|
||||
}
|
||||
|
||||
fs.writeFile = function(path, data, options, callback) {
|
||||
callback = maybeCallback(arguments[arguments.length - 1]);
|
||||
callback = maybeCallback(callback || options);
|
||||
options = getOptions(options, { encoding: 'utf8', mode: 0o666, flag: 'w' });
|
||||
const flag = options.flag || 'w';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user