Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 benchmark/fs/bench-writeFileSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tmpdir.refresh();

// Some variants are commented out as they do not show a change and just slow
const bench = common.createBenchmark(main, {
encoding: ['utf8'],
encoding: ['utf8', 'UTF8'],
useFd: ['true', 'false'],
length: [1024, 102400, 1024 * 1024],

Expand Down
5 changes: 3 additions & 2 deletions 5 lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const {
custom: kCustomPromisifiedSymbol,
},
SideEffectFreeRegExpPrototypeExec,
normalizeEncoding,
defineLazyProperties,
isWindows,
isMacOS,
Expand Down Expand Up @@ -428,7 +429,7 @@ function tryReadSync(fd, isUserFd, buffer, pos, len) {
function readFileSync(path, options) {
options = getOptions(options, { flag: 'r' });

if (options.encoding === 'utf8' || options.encoding === 'utf-8') {
if (options.encoding && normalizeEncoding(options.encoding) === 'utf8') {
if (!isInt32(path)) {
path = getValidatedPath(path);
}
Expand Down Expand Up @@ -2383,7 +2384,7 @@ function writeFileSync(path, data, options) {
const flag = options.flag || 'w';

// C++ fast path for string data and UTF8 encoding
if (typeof data === 'string' && (options.encoding === 'utf8' || options.encoding === 'utf-8')) {
if (typeof data === 'string' && normalizeEncoding(options.encoding) === 'utf8') {
if (!isInt32(path)) {
path = getValidatedPath(path);
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.