mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
fs: lazily load ReadFileContext
PR-URL: https://github.com/nodejs/node/pull/55998 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
This commit is contained in:
parent
08e0147d97
commit
ba912ee310
1 changed files with 2 additions and 1 deletions
|
@ -164,6 +164,7 @@ let ReadStream;
|
|||
let WriteStream;
|
||||
let rimraf;
|
||||
let kResistStopPropagation;
|
||||
let ReadFileContext;
|
||||
|
||||
// These have to be separate because of how graceful-fs happens to do it's
|
||||
// monkeypatching.
|
||||
|
@ -365,7 +366,7 @@ function readFile(path, options, callback) {
|
|||
callback ||= options;
|
||||
validateFunction(callback, 'cb');
|
||||
options = getOptions(options, { flag: 'r' });
|
||||
const ReadFileContext = require('internal/fs/read/context');
|
||||
ReadFileContext ??= require('internal/fs/read/context');
|
||||
const context = new ReadFileContext(callback, options.encoding);
|
||||
context.isUserFd = isFd(path); // File descriptor ownership
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue