@@ -83,7 +83,14 @@ const {
8383
8484const { FSReqCallback } = binding ;
8585const { toPathIfFileURL } = require ( 'internal/url' ) ;
86- const internalUtil = require ( 'internal/util' ) ;
86+ const {
87+ customPromisifyArgs : kCustomPromisifyArgsSymbol ,
88+ deprecate,
89+ kEmptyObject,
90+ promisify : {
91+ custom : kCustomPromisifiedSymbol ,
92+ } ,
93+ } = require ( 'internal/util' ) ;
8794const {
8895 constants : {
8996 kIoMaxLength,
@@ -164,7 +171,7 @@ const isWindows = process.platform === 'win32';
164171const isOSX = process . platform === 'darwin' ;
165172
166173
167- const showStringCoercionDeprecation = internalUtil . deprecate (
174+ const showStringCoercionDeprecation = deprecate (
168175 ( ) => { } ,
169176 'Implicit coercion of objects with own toString property is deprecated.' ,
170177 'DEP0162'
@@ -276,7 +283,7 @@ function exists(path, callback) {
276283 }
277284}
278285
279- ObjectDefineProperty ( exists , internalUtil . promisify . custom , {
286+ ObjectDefineProperty ( exists , kCustomPromisifiedSymbol , {
280287 __proto__ : null ,
281288 value : function exists ( path ) { // eslint-disable-line func-name-matching
282289 return new Promise ( ( resolve ) => fs . exists ( path , resolve ) ) ;
@@ -623,7 +630,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
623630 if ( ! isArrayBufferView ( buffer ) ) {
624631 // This is fs.read(fd, params, callback)
625632 params = buffer ;
626- ( { buffer = Buffer . alloc ( 16384 ) } = params ?? ObjectCreate ( null ) ) ;
633+ ( { buffer = Buffer . alloc ( 16384 ) } = params ?? kEmptyObject ) ;
627634 }
628635 callback = offsetOrOptions ;
629636 } else {
@@ -636,7 +643,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
636643 offset = 0 ,
637644 length = buffer . byteLength - offset ,
638645 position = null ,
639- } = params ?? ObjectCreate ( null ) ) ;
646+ } = params ?? kEmptyObject ) ;
640647 }
641648
642649 validateBuffer ( buffer ) ;
@@ -679,7 +686,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
679686 binding . read ( fd , buffer , offset , length , position , req ) ;
680687}
681688
682- ObjectDefineProperty ( read , internalUtil . customPromisifyArgs ,
689+ ObjectDefineProperty ( read , kCustomPromisifyArgsSymbol ,
683690 { __proto__ : null , value : [ 'bytesRead' , 'buffer' ] , enumerable : false } ) ;
684691
685692/**
@@ -701,7 +708,7 @@ function readSync(fd, buffer, offset, length, position) {
701708
702709 if ( arguments . length <= 3 ) {
703710 // Assume fs.readSync(fd, buffer, options)
704- const options = offset || ObjectCreate ( null ) ;
711+ const options = offset || kEmptyObject ;
705712
706713 ( {
707714 offset = 0 ,
@@ -772,7 +779,7 @@ function readv(fd, buffers, position, callback) {
772779 return binding . readBuffers ( fd , buffers , position , req ) ;
773780}
774781
775- ObjectDefineProperty ( readv , internalUtil . customPromisifyArgs ,
782+ ObjectDefineProperty ( readv , kCustomPromisifyArgsSymbol ,
776783 { __proto__ : null , value : [ 'bytesRead' , 'buffers' ] , enumerable : false } ) ;
777784
778785/**
@@ -829,7 +836,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
829836 offset = 0 ,
830837 length = buffer . byteLength - offset ,
831838 position = null ,
832- } = offsetOrOptions ?? ObjectCreate ( null ) ) ;
839+ } = offsetOrOptions ?? kEmptyObject ) ;
833840 }
834841
835842 if ( offset == null || typeof offset === 'function' ) {
@@ -872,7 +879,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
872879 return binding . writeString ( fd , str , offset , length , req ) ;
873880}
874881
875- ObjectDefineProperty ( write , internalUtil . customPromisifyArgs ,
882+ ObjectDefineProperty ( write , kCustomPromisifyArgsSymbol ,
876883 { __proto__ : null , value : [ 'bytesWritten' , 'buffer' ] , enumerable : false } ) ;
877884
878885/**
@@ -899,7 +906,7 @@ function writeSync(fd, buffer, offsetOrOptions, length, position) {
899906 offset = 0 ,
900907 length = buffer . byteLength - offset ,
901908 position = null ,
902- } = offsetOrOptions ?? ObjectCreate ( null ) ) ;
909+ } = offsetOrOptions ?? kEmptyObject ) ;
903910 }
904911 if ( position === undefined )
905912 position = null ;
@@ -962,7 +969,7 @@ function writev(fd, buffers, position, callback) {
962969 return binding . writeBuffers ( fd , buffers , position , req ) ;
963970}
964971
965- ObjectDefineProperty ( writev , internalUtil . customPromisifyArgs , {
972+ ObjectDefineProperty ( writev , kCustomPromisifyArgsSymbol , {
966973 __proto__ : null ,
967974 value : [ 'bytesWritten' , 'buffer' ] ,
968975 enumerable : false
@@ -1405,7 +1412,7 @@ function mkdirSync(path, options) {
14051412 */
14061413function readdir ( path , options , callback ) {
14071414 callback = makeCallback ( typeof options === 'function' ? options : callback ) ;
1408- options = getOptions ( options , { } ) ;
1415+ options = getOptions ( options ) ;
14091416 path = getValidatedPath ( path ) ;
14101417
14111418 const req = new FSReqCallback ( ) ;
@@ -1434,7 +1441,7 @@ function readdir(path, options, callback) {
14341441 * @returns {string | Buffer[] | Dirent[] }
14351442 */
14361443function readdirSync ( path , options ) {
1437- options = getOptions ( options , { } ) ;
1444+ options = getOptions ( options ) ;
14381445 path = getValidatedPath ( path ) ;
14391446 const ctx = { path } ;
14401447 const result = binding . readdir ( pathModule . toNamespacedPath ( path ) ,
@@ -1458,7 +1465,7 @@ function readdirSync(path, options) {
14581465function fstat ( fd , options = { bigint : false } , callback ) {
14591466 if ( typeof options === 'function' ) {
14601467 callback = options ;
1461- options = { } ;
1468+ options = kEmptyObject ;
14621469 }
14631470 fd = getValidatedFd ( fd ) ;
14641471 callback = makeStatsCallback ( callback ) ;
@@ -1482,7 +1489,7 @@ function fstat(fd, options = { bigint: false }, callback) {
14821489function lstat ( path , options = { bigint : false } , callback ) {
14831490 if ( typeof options === 'function' ) {
14841491 callback = options ;
1485- options = { } ;
1492+ options = kEmptyObject ;
14861493 }
14871494 callback = makeStatsCallback ( callback ) ;
14881495 path = getValidatedPath ( path ) ;
@@ -1505,7 +1512,7 @@ function lstat(path, options = { bigint: false }, callback) {
15051512function stat ( path , options = { bigint : false } , callback ) {
15061513 if ( typeof options === 'function' ) {
15071514 callback = options ;
1508- options = { } ;
1515+ options = kEmptyObject ;
15091516 }
15101517 callback = makeStatsCallback ( callback ) ;
15111518 path = getValidatedPath ( path ) ;
@@ -1603,7 +1610,7 @@ function statSync(path, options = { bigint: false, throwIfNoEntry: true }) {
16031610 */
16041611function readlink ( path , options , callback ) {
16051612 callback = makeCallback ( typeof options === 'function' ? options : callback ) ;
1606- options = getOptions ( options , { } ) ;
1613+ options = getOptions ( options ) ;
16071614 path = getValidatedPath ( path , 'oldPath' ) ;
16081615 const req = new FSReqCallback ( ) ;
16091616 req . oncomplete = callback ;
@@ -1618,7 +1625,7 @@ function readlink(path, options, callback) {
16181625 * @returns {string | Buffer }
16191626 */
16201627function readlinkSync ( path , options ) {
1621- options = getOptions ( options , { } ) ;
1628+ options = getOptions ( options ) ;
16221629 path = getValidatedPath ( path , 'oldPath' ) ;
16231630 const ctx = { path } ;
16241631 const result = binding . readlink ( pathModule . toNamespacedPath ( path ) ,
@@ -2295,7 +2302,7 @@ function watch(filename, options, listener) {
22952302 if ( typeof options === 'function' ) {
22962303 listener = options ;
22972304 }
2298- options = getOptions ( options , { } ) ;
2305+ options = getOptions ( options ) ;
22992306
23002307 // Don't make changes directly on options object
23012308 options = copyObject ( options ) ;
@@ -2458,16 +2465,14 @@ if (isWindows) {
24582465 } ;
24592466}
24602467
2461- const emptyObj = ObjectCreate ( null ) ;
2462-
24632468/**
24642469 * Returns the resolved pathname.
24652470 * @param {string | Buffer | URL } p
24662471 * @param {string | { encoding?: string | null; } } [options]
24672472 * @returns {string | Buffer }
24682473 */
24692474function realpathSync ( p , options ) {
2470- options = getOptions ( options , emptyObj ) ;
2475+ options = getOptions ( options ) ;
24712476 p = toPathIfFileURL ( p ) ;
24722477 if ( typeof p !== 'string' ) {
24732478 p += '' ;
@@ -2604,7 +2609,7 @@ function realpathSync(p, options) {
26042609 * @returns {string | Buffer }
26052610 */
26062611realpathSync . native = ( path , options ) => {
2607- options = getOptions ( options , { } ) ;
2612+ options = getOptions ( options ) ;
26082613 path = getValidatedPath ( path ) ;
26092614 const ctx = { path } ;
26102615 const result = binding . realpath ( path , options . encoding , undefined , ctx ) ;
@@ -2625,7 +2630,7 @@ realpathSync.native = (path, options) => {
26252630 */
26262631function realpath ( p , options , callback ) {
26272632 callback = typeof options === 'function' ? options : maybeCallback ( callback ) ;
2628- options = getOptions ( options , { } ) ;
2633+ options = getOptions ( options ) ;
26292634 p = toPathIfFileURL ( p ) ;
26302635
26312636 if ( typeof p !== 'string' ) {
@@ -2763,7 +2768,7 @@ function realpath(p, options, callback) {
27632768 */
27642769realpath . native = ( path , options , callback ) => {
27652770 callback = makeCallback ( callback || options ) ;
2766- options = getOptions ( options , { } ) ;
2771+ options = getOptions ( options ) ;
27672772 path = getValidatedPath ( path ) ;
27682773 const req = new FSReqCallback ( ) ;
27692774 req . oncomplete = callback ;
@@ -2782,7 +2787,7 @@ realpath.native = (path, options, callback) => {
27822787 */
27832788function mkdtemp ( prefix , options , callback ) {
27842789 callback = makeCallback ( typeof options === 'function' ? options : callback ) ;
2785- options = getOptions ( options , { } ) ;
2790+ options = getOptions ( options ) ;
27862791
27872792 validateString ( prefix , 'prefix' ) ;
27882793 nullCheck ( prefix , 'prefix' ) ;
@@ -2799,7 +2804,7 @@ function mkdtemp(prefix, options, callback) {
27992804 * @returns {string }
28002805 */
28012806function mkdtempSync ( prefix , options ) {
2802- options = getOptions ( options , { } ) ;
2807+ options = getOptions ( options ) ;
28032808
28042809 validateString ( prefix , 'prefix' ) ;
28052810 nullCheck ( prefix , 'prefix' ) ;
0 commit comments