4
4
'use strict' ;
5
5
6
6
const SlowBuffer = require ( 'buffer' ) . SlowBuffer ;
7
- const util = require ( 'util' ) ;
8
7
const pathModule = require ( 'path' ) ;
9
8
10
9
const binding = process . binding ( 'fs' ) ;
@@ -34,7 +33,9 @@ const O_WRONLY = constants.O_WRONLY || 0;
34
33
const isWindows = process . platform === 'win32' ;
35
34
36
35
const DEBUG = process . env . NODE_DEBUG && / f s / . test ( process . env . NODE_DEBUG ) ;
37
- const errnoException = util . _errnoException ;
36
+ const errnoException = require ( 'internal/errno_exception' ) ;
37
+ const extend = require ( 'internal/extend' ) ;
38
+ const inherits = require ( 'internal/inherits' ) ;
38
39
39
40
function throwOptionsError ( options ) {
40
41
throw new TypeError ( 'Expected options to be either an object or a string, ' +
@@ -1048,7 +1049,7 @@ function toUnixTimestamp(time) {
1048
1049
if ( typeof time === 'number' ) {
1049
1050
return time ;
1050
1051
}
1051
- if ( util . isDate ( time ) ) {
1052
+ if ( Object . prototype . toString . call ( time ) === '[object Date]' ) {
1052
1053
// convert to 123.456 UNIX timestamp
1053
1054
return time . getTime ( ) / 1000 ;
1054
1055
}
@@ -1185,7 +1186,7 @@ fs.appendFile = function(path, data, options, callback_) {
1185
1186
}
1186
1187
1187
1188
if ( ! options . flag )
1188
- options = util . _extend ( { flag : 'a' } , options ) ;
1189
+ options = extend ( { flag : 'a' } , options ) ;
1189
1190
fs . writeFile ( path , data , options , callback ) ;
1190
1191
} ;
1191
1192
@@ -1198,7 +1199,7 @@ fs.appendFileSync = function(path, data, options) {
1198
1199
throwOptionsError ( options ) ;
1199
1200
}
1200
1201
if ( ! options . flag )
1201
- options = util . _extend ( { flag : 'a' } , options ) ;
1202
+ options = extend ( { flag : 'a' } , options ) ;
1202
1203
1203
1204
fs . writeFileSync ( path , data , options ) ;
1204
1205
} ;
@@ -1219,7 +1220,7 @@ function FSWatcher() {
1219
1220
}
1220
1221
} ;
1221
1222
}
1222
- util . inherits ( FSWatcher , EventEmitter ) ;
1223
+ inherits ( FSWatcher , EventEmitter ) ;
1223
1224
1224
1225
FSWatcher . prototype . start = function ( filename , persistent , recursive ) {
1225
1226
nullCheck ( filename ) ;
@@ -1289,7 +1290,7 @@ function StatWatcher() {
1289
1290
self . emit ( 'stop' ) ;
1290
1291
} ;
1291
1292
}
1292
- util . inherits ( StatWatcher , EventEmitter ) ;
1293
+ inherits ( StatWatcher , EventEmitter ) ;
1293
1294
1294
1295
1295
1296
StatWatcher . prototype . start = function ( filename , persistent , interval ) {
@@ -1319,7 +1320,7 @@ fs.watchFile = function(filename, options, listener) {
1319
1320
} ;
1320
1321
1321
1322
if ( options !== null && typeof options === 'object' ) {
1322
- options = util . _extend ( defaults , options ) ;
1323
+ options = extend ( defaults , options ) ;
1323
1324
} else {
1324
1325
listener = options ;
1325
1326
options = defaults ;
@@ -1607,7 +1608,7 @@ fs.createReadStream = function(path, options) {
1607
1608
return new ReadStream ( path , options ) ;
1608
1609
} ;
1609
1610
1610
- util . inherits ( ReadStream , Readable ) ;
1611
+ inherits ( ReadStream , Readable ) ;
1611
1612
fs . ReadStream = ReadStream ;
1612
1613
1613
1614
function ReadStream ( path , options ) {
@@ -1779,7 +1780,7 @@ fs.createWriteStream = function(path, options) {
1779
1780
return new WriteStream ( path , options ) ;
1780
1781
} ;
1781
1782
1782
- util . inherits ( WriteStream , Writable ) ;
1783
+ inherits ( WriteStream , Writable ) ;
1783
1784
fs . WriteStream = WriteStream ;
1784
1785
function WriteStream ( path , options ) {
1785
1786
if ( ! ( this instanceof WriteStream ) )
@@ -1887,7 +1888,7 @@ function SyncWriteStream(fd, options) {
1887
1888
this . autoClose = options . autoClose === undefined ? true : options . autoClose ;
1888
1889
}
1889
1890
1890
- util . inherits ( SyncWriteStream , Stream ) ;
1891
+ inherits ( SyncWriteStream , Stream ) ;
1891
1892
1892
1893
1893
1894
// Export
0 commit comments