forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs: add a fast-path for readFileSync utf-8
Backport-PR-URL: nodejs#48658
- Loading branch information
Showing
6 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const { handleErrorFromBinding } = require('internal/fs/utils'); | ||
|
||
const binding = internalBinding('fs'); | ||
|
||
/** | ||
* @param {string} path | ||
* @param {number} flag | ||
* @return {string} | ||
*/ | ||
function readFileSyncUtf8(path, flag) { | ||
const response = binding.readFileSync(path, flag); | ||
|
||
if (typeof response === 'string') { | ||
return response; | ||
} | ||
|
||
handleErrorFromBinding({ errno: response, path }); | ||
} | ||
|
||
module.exports = { | ||
readFileSyncUtf8, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters