@@ -83,7 +83,13 @@ const {
8383
8484const { FSReqCallback } = binding ;
8585const { toPathIfFileURL } = require ( 'internal/url' ) ;
86- const internalUtil = require ( 'internal/util' ) ;
86+ const {
87+ customPromisifyArgs : kCustomPromisifyArgsSymbol ,
88+ kEmptyObject,
89+ promisify : {
90+ custom : kCustomPromisifiedSymbol ,
91+ } ,
92+ } = require ( 'internal/util' ) ;
8793const {
8894 constants : {
8995 kIoMaxLength,
@@ -272,7 +278,7 @@ function exists(path, callback) {
272278 }
273279}
274280
275- ObjectDefineProperty ( exists , internalUtil . promisify . custom , {
281+ ObjectDefineProperty ( exists , kCustomPromisifiedSymbol , {
276282 __proto__ : null ,
277283 value : function exists ( path ) { // eslint-disable-line func-name-matching
278284 return new Promise ( ( resolve ) => fs . exists ( path , resolve ) ) ;
@@ -619,7 +625,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
619625 if ( ! isArrayBufferView ( buffer ) ) {
620626 // This is fs.read(fd, params, callback)
621627 params = buffer ;
622- ( { buffer = Buffer . alloc ( 16384 ) } = params ?? ObjectCreate ( null ) ) ;
628+ ( { buffer = Buffer . alloc ( 16384 ) } = params ?? kEmptyObject ) ;
623629 }
624630 callback = offsetOrOptions ;
625631 } else {
@@ -632,7 +638,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
632638 offset = 0 ,
633639 length = buffer . byteLength - offset ,
634640 position = null ,
635- } = params ?? ObjectCreate ( null ) ) ;
641+ } = params ?? kEmptyObject ) ;
636642 }
637643
638644 validateBuffer ( buffer ) ;
@@ -675,7 +681,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
675681 binding . read ( fd , buffer , offset , length , position , req ) ;
676682}
677683
678- ObjectDefineProperty ( read , internalUtil . customPromisifyArgs ,
684+ ObjectDefineProperty ( read , kCustomPromisifyArgsSymbol ,
679685 { __proto__ : null , value : [ 'bytesRead' , 'buffer' ] , enumerable : false } ) ;
680686
681687/**
@@ -697,7 +703,7 @@ function readSync(fd, buffer, offset, length, position) {
697703
698704 if ( arguments . length <= 3 ) {
699705 // Assume fs.readSync(fd, buffer, options)
700- const options = offset || ObjectCreate ( null ) ;
706+ const options = offset || kEmptyObject ;
701707
702708 ( {
703709 offset = 0 ,
@@ -768,7 +774,7 @@ function readv(fd, buffers, position, callback) {
768774 return binding . readBuffers ( fd , buffers , position , req ) ;
769775}
770776
771- ObjectDefineProperty ( readv , internalUtil . customPromisifyArgs ,
777+ ObjectDefineProperty ( readv , kCustomPromisifyArgsSymbol ,
772778 { __proto__ : null , value : [ 'bytesRead' , 'buffers' ] , enumerable : false } ) ;
773779
774780/**
@@ -825,7 +831,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
825831 offset = 0 ,
826832 length = buffer . byteLength - offset ,
827833 position = null ,
828- } = offsetOrOptions ?? ObjectCreate ( null ) ) ;
834+ } = offsetOrOptions ?? kEmptyObject ) ;
829835 }
830836
831837 if ( offset == null || typeof offset === 'function' ) {
@@ -865,7 +871,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
865871 return binding . writeString ( fd , str , offset , length , req ) ;
866872}
867873
868- ObjectDefineProperty ( write , internalUtil . customPromisifyArgs ,
874+ ObjectDefineProperty ( write , kCustomPromisifyArgsSymbol ,
869875 { __proto__ : null , value : [ 'bytesWritten' , 'buffer' ] , enumerable : false } ) ;
870876
871877/**
@@ -892,7 +898,7 @@ function writeSync(fd, buffer, offsetOrOptions, length, position) {
892898 offset = 0 ,
893899 length = buffer . byteLength - offset ,
894900 position = null ,
895- } = offsetOrOptions ?? ObjectCreate ( null ) ) ;
901+ } = offsetOrOptions ?? kEmptyObject ) ;
896902 }
897903 if ( position === undefined )
898904 position = null ;
@@ -955,7 +961,7 @@ function writev(fd, buffers, position, callback) {
955961 return binding . writeBuffers ( fd , buffers , position , req ) ;
956962}
957963
958- ObjectDefineProperty ( writev , internalUtil . customPromisifyArgs , {
964+ ObjectDefineProperty ( writev , kCustomPromisifyArgsSymbol , {
959965 __proto__ : null ,
960966 value : [ 'bytesWritten' , 'buffer' ] ,
961967 enumerable : false
@@ -1398,7 +1404,7 @@ function mkdirSync(path, options) {
13981404 */
13991405function readdir ( path , options , callback ) {
14001406 callback = makeCallback ( typeof options === 'function' ? options : callback ) ;
1401- options = getOptions ( options , { } ) ;
1407+ options = getOptions ( options ) ;
14021408 path = getValidatedPath ( path ) ;
14031409
14041410 const req = new FSReqCallback ( ) ;
@@ -1427,7 +1433,7 @@ function readdir(path, options, callback) {
14271433 * @returns {string | Buffer[] | Dirent[] }
14281434 */
14291435function readdirSync ( path , options ) {
1430- options = getOptions ( options , { } ) ;
1436+ options = getOptions ( options ) ;
14311437 path = getValidatedPath ( path ) ;
14321438 const ctx = { path } ;
14331439 const result = binding . readdir ( pathModule . toNamespacedPath ( path ) ,
@@ -1451,7 +1457,7 @@ function readdirSync(path, options) {
14511457function fstat ( fd , options = { bigint : false } , callback ) {
14521458 if ( typeof options === 'function' ) {
14531459 callback = options ;
1454- options = { } ;
1460+ options = kEmptyObject ;
14551461 }
14561462 fd = getValidatedFd ( fd ) ;
14571463 callback = makeStatsCallback ( callback ) ;
@@ -1475,7 +1481,7 @@ function fstat(fd, options = { bigint: false }, callback) {
14751481function lstat ( path , options = { bigint : false } , callback ) {
14761482 if ( typeof options === 'function' ) {
14771483 callback = options ;
1478- options = { } ;
1484+ options = kEmptyObject ;
14791485 }
14801486 callback = makeStatsCallback ( callback ) ;
14811487 path = getValidatedPath ( path ) ;
@@ -1498,7 +1504,7 @@ function lstat(path, options = { bigint: false }, callback) {
14981504function stat ( path , options = { bigint : false } , callback ) {
14991505 if ( typeof options === 'function' ) {
15001506 callback = options ;
1501- options = { } ;
1507+ options = kEmptyObject ;
15021508 }
15031509 callback = makeStatsCallback ( callback ) ;
15041510 path = getValidatedPath ( path ) ;
@@ -1596,7 +1602,7 @@ function statSync(path, options = { bigint: false, throwIfNoEntry: true }) {
15961602 */
15971603function readlink ( path , options , callback ) {
15981604 callback = makeCallback ( typeof options === 'function' ? options : callback ) ;
1599- options = getOptions ( options , { } ) ;
1605+ options = getOptions ( options ) ;
16001606 path = getValidatedPath ( path , 'oldPath' ) ;
16011607 const req = new FSReqCallback ( ) ;
16021608 req . oncomplete = callback ;
@@ -1611,7 +1617,7 @@ function readlink(path, options, callback) {
16111617 * @returns {string | Buffer }
16121618 */
16131619function readlinkSync ( path , options ) {
1614- options = getOptions ( options , { } ) ;
1620+ options = getOptions ( options ) ;
16151621 path = getValidatedPath ( path , 'oldPath' ) ;
16161622 const ctx = { path } ;
16171623 const result = binding . readlink ( pathModule . toNamespacedPath ( path ) ,
@@ -2282,7 +2288,7 @@ function watch(filename, options, listener) {
22822288 if ( typeof options === 'function' ) {
22832289 listener = options ;
22842290 }
2285- options = getOptions ( options , { } ) ;
2291+ options = getOptions ( options ) ;
22862292
22872293 // Don't make changes directly on options object
22882294 options = copyObject ( options ) ;
@@ -2445,16 +2451,14 @@ if (isWindows) {
24452451 } ;
24462452}
24472453
2448- const emptyObj = ObjectCreate ( null ) ;
2449-
24502454/**
24512455 * Returns the resolved pathname.
24522456 * @param {string | Buffer | URL } p
24532457 * @param {string | { encoding?: string | null; } } [options]
24542458 * @returns {string | Buffer }
24552459 */
24562460function realpathSync ( p , options ) {
2457- options = getOptions ( options , emptyObj ) ;
2461+ options = getOptions ( options ) ;
24582462 p = toPathIfFileURL ( p ) ;
24592463 if ( typeof p !== 'string' ) {
24602464 p += '' ;
@@ -2591,7 +2595,7 @@ function realpathSync(p, options) {
25912595 * @returns {string | Buffer }
25922596 */
25932597realpathSync . native = ( path , options ) => {
2594- options = getOptions ( options , { } ) ;
2598+ options = getOptions ( options ) ;
25952599 path = getValidatedPath ( path ) ;
25962600 const ctx = { path } ;
25972601 const result = binding . realpath ( path , options . encoding , undefined , ctx ) ;
@@ -2612,7 +2616,7 @@ realpathSync.native = (path, options) => {
26122616 */
26132617function realpath ( p , options , callback ) {
26142618 callback = typeof options === 'function' ? options : maybeCallback ( callback ) ;
2615- options = getOptions ( options , { } ) ;
2619+ options = getOptions ( options ) ;
26162620 p = toPathIfFileURL ( p ) ;
26172621
26182622 if ( typeof p !== 'string' ) {
@@ -2750,7 +2754,7 @@ function realpath(p, options, callback) {
27502754 */
27512755realpath . native = ( path , options , callback ) => {
27522756 callback = makeCallback ( callback || options ) ;
2753- options = getOptions ( options , { } ) ;
2757+ options = getOptions ( options ) ;
27542758 path = getValidatedPath ( path ) ;
27552759 const req = new FSReqCallback ( ) ;
27562760 req . oncomplete = callback ;
@@ -2769,7 +2773,7 @@ realpath.native = (path, options, callback) => {
27692773 */
27702774function mkdtemp ( prefix , options , callback ) {
27712775 callback = makeCallback ( typeof options === 'function' ? options : callback ) ;
2772- options = getOptions ( options , { } ) ;
2776+ options = getOptions ( options ) ;
27732777
27742778 validateString ( prefix , 'prefix' ) ;
27752779 nullCheck ( prefix , 'prefix' ) ;
@@ -2786,7 +2790,7 @@ function mkdtemp(prefix, options, callback) {
27862790 * @returns {string }
27872791 */
27882792function mkdtempSync ( prefix , options ) {
2789- options = getOptions ( options , { } ) ;
2793+ options = getOptions ( options ) ;
27902794
27912795 validateString ( prefix , 'prefix' ) ;
27922796 nullCheck ( prefix , 'prefix' ) ;
0 commit comments