@ -57,14 +57,14 @@ function rethrow() {
}
}
function maybeCallback ( cb ) {
function maybeCallback ( cb ) {
return util . isFunction ( cb ) ? cb : rethrow ( ) ;
return typeof cb === 'function' ? cb : rethrow ( ) ;
}
}
// Ensure that callbacks run in the global context. Only use this function
// Ensure that callbacks run in the global context. Only use this function
// for callbacks that are passed to the binding layer, callbacks that are
// for callbacks that are passed to the binding layer, callbacks that are
// invoked from JS already run in the proper scope.
// invoked from JS already run in the proper scope.
function makeCallback ( cb ) {
function makeCallback ( cb ) {
if ( ! util . isFunction ( cb ) ) {
if ( typeof cb !== 'function' ) {
return rethrow ( ) ;
return rethrow ( ) ;
}
}
@ -218,11 +218,11 @@ fs.existsSync = function(path) {
fs . readFile = function ( path , options , callback_ ) {
fs . readFile = function ( path , options , callback_ ) {
var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
if ( util . isFunction ( options ) || ! options ) {
if ( ! options || typeof options === 'function' ) {
options = { encoding : null , flag : 'r' } ;
options = { encoding : null , flag : 'r' } ;
} else if ( util . isString ( options ) ) {
} else if ( typeof options === 'string' ) {
options = { encoding : options , flag : 'r' } ;
options = { encoding : options , flag : 'r' } ;
} else if ( ! util . isObject ( options ) ) {
} else if ( typeof options !== 'object' ) {
throw new TypeError ( 'Bad arguments' ) ;
throw new TypeError ( 'Bad arguments' ) ;
}
}
@ -317,9 +317,9 @@ fs.readFile = function(path, options, callback_) {
fs . readFileSync = function ( path , options ) {
fs . readFileSync = function ( path , options ) {
if ( ! options ) {
if ( ! options ) {
options = { encoding : null , flag : 'r' } ;
options = { encoding : null , flag : 'r' } ;
} else if ( util . isString ( options ) ) {
} else if ( typeof options === 'string' ) {
options = { encoding : options , flag : 'r' } ;
options = { encoding : options , flag : 'r' } ;
} else if ( ! util . isObject ( options ) ) {
} else if ( typeof options !== 'object' ) {
throw new TypeError ( 'Bad arguments' ) ;
throw new TypeError ( 'Bad arguments' ) ;
}
}
@ -395,7 +395,7 @@ fs.readFileSync = function(path, options) {
// Used by binding.open and friends
// Used by binding.open and friends
function stringToFlags ( flag ) {
function stringToFlags ( flag ) {
// Only mess with strings
// Only mess with strings
if ( ! util . isString ( flag ) ) {
if ( typeof flag !== 'string' ) {
return flag ;
return flag ;
}
}
@ -448,9 +448,9 @@ fs.closeSync = function(fd) {
} ;
} ;
function modeNum ( m , def ) {
function modeNum ( m , def ) {
if ( util . isNumber ( m ) )
if ( typeof m === 'number' )
return m ;
return m ;
if ( util . isString ( m ) )
if ( typeof m === 'string' )
return parseInt ( m , 8 ) ;
return parseInt ( m , 8 ) ;
if ( def )
if ( def )
return modeNum ( def ) ;
return modeNum ( def ) ;
@ -479,7 +479,7 @@ fs.openSync = function(path, flags, mode) {
} ;
} ;
fs . read = function ( fd , buffer , offset , length , position , callback ) {
fs . read = function ( fd , buffer , offset , length , position , callback ) {
if ( ! util . isBuffer ( b uffer) ) {
if ( ! ( buffer instanceof B uffer) ) {
// legacy string interface (fd, length, position, encoding, callback)
// legacy string interface (fd, length, position, encoding, callback)
var cb = arguments [ 4 ] ,
var cb = arguments [ 4 ] ,
encoding = arguments [ 3 ] ;
encoding = arguments [ 3 ] ;
@ -513,7 +513,7 @@ fs.read = function(fd, buffer, offset, length, position, callback) {
fs . readSync = function ( fd , buffer , offset , length , position ) {
fs . readSync = function ( fd , buffer , offset , length , position ) {
var legacy = false ;
var legacy = false ;
if ( ! util . isBuffer ( b uffer) ) {
if ( ! ( buffer instanceof B uffer) ) {
// legacy string interface (fd, length, position, encoding, callback)
// legacy string interface (fd, length, position, encoding, callback)
legacy = true ;
legacy = true ;
var encoding = arguments [ 3 ] ;
var encoding = arguments [ 3 ] ;
@ -551,9 +551,9 @@ fs.write = function(fd, buffer, offset, length, position, callback) {
callback ( err , written || 0 , buffer ) ;
callback ( err , written || 0 , buffer ) ;
}
}
if ( util . isBuffer ( buffer ) ) {
if ( buffer instanceof Buffer ) {
// if no position is passed then assume null
// if no position is passed then assume null
if ( util . isFunction ( position ) ) {
if ( typeof position === 'function' ) {
callback = position ;
callback = position ;
position = null ;
position = null ;
}
}
@ -563,10 +563,10 @@ fs.write = function(fd, buffer, offset, length, position, callback) {
return binding . writeBuffer ( fd , buffer , offset , length , position , req ) ;
return binding . writeBuffer ( fd , buffer , offset , length , position , req ) ;
}
}
if ( util . isString ( buffer ) )
if ( typeof buffer === 'string' )
buffer += '' ;
buffer += '' ;
if ( ! util . isFunction ( position ) ) {
if ( typeof position !== 'function' ) {
if ( util . isFunction ( offset ) ) {
if ( typeof offset === 'function' ) {
position = offset ;
position = offset ;
offset = null ;
offset = null ;
} else {
} else {
@ -585,14 +585,14 @@ fs.write = function(fd, buffer, offset, length, position, callback) {
// OR
// OR
// fs.writeSync(fd, string[, position[, encoding]]);
// fs.writeSync(fd, string[, position[, encoding]]);
fs . writeSync = function ( fd , buffer , offset , length , position ) {
fs . writeSync = function ( fd , buffer , offset , length , position ) {
if ( util . isBuffer ( buffer ) ) {
if ( buffer instanceof Buffer ) {
if ( util . isUndefined ( position ) )
if ( position === undefined )
position = null ;
position = null ;
return binding . writeBuffer ( fd , buffer , offset , length , position ) ;
return binding . writeBuffer ( fd , buffer , offset , length , position ) ;
}
}
if ( ! util . isString ( buffer ) )
if ( typeof buffer !== 'string' )
buffer += '' ;
buffer += '' ;
if ( util . isUndefined ( offset ) )
if ( offset === undefined )
offset = null ;
offset = null ;
return binding . writeString ( fd , buffer , offset , length , position ) ;
return binding . writeString ( fd , buffer , offset , length , position ) ;
} ;
} ;
@ -616,15 +616,15 @@ fs.renameSync = function(oldPath, newPath) {
} ;
} ;
fs . truncate = function ( path , len , callback ) {
fs . truncate = function ( path , len , callback ) {
if ( util . isNumber ( path ) ) {
if ( typeof path === 'number' ) {
var req = new FSReqWrap ( ) ;
var req = new FSReqWrap ( ) ;
req . oncomplete = callback ;
req . oncomplete = callback ;
return fs . ftruncate ( path , len , req ) ;
return fs . ftruncate ( path , len , req ) ;
}
}
if ( util . isFunction ( len ) ) {
if ( typeof len === 'function' ) {
callback = len ;
callback = len ;
len = 0 ;
len = 0 ;
} else if ( util . isUndefined ( len ) ) {
} else if ( len === undefined ) {
len = 0 ;
len = 0 ;
}
}
@ -642,11 +642,11 @@ fs.truncate = function(path, len, callback) {
} ;
} ;
fs . truncateSync = function ( path , len ) {
fs . truncateSync = function ( path , len ) {
if ( util . isNumber ( path ) ) {
if ( typeof path === 'number' ) {
// legacy
// legacy
return fs . ftruncateSync ( path , len ) ;
return fs . ftruncateSync ( path , len ) ;
}
}
if ( util . isUndefined ( len ) ) {
if ( len === undefined ) {
len = 0 ;
len = 0 ;
}
}
// allow error to be thrown, but still close fd.
// allow error to be thrown, but still close fd.
@ -660,10 +660,10 @@ fs.truncateSync = function(path, len) {
} ;
} ;
fs . ftruncate = function ( fd , len , callback ) {
fs . ftruncate = function ( fd , len , callback ) {
if ( util . isFunction ( len ) ) {
if ( typeof len === 'function' ) {
callback = len ;
callback = len ;
len = 0 ;
len = 0 ;
} else if ( util . isUndefined ( len ) ) {
} else if ( len === undefined ) {
len = 0 ;
len = 0 ;
}
}
var req = new FSReqWrap ( ) ;
var req = new FSReqWrap ( ) ;
@ -672,7 +672,7 @@ fs.ftruncate = function(fd, len, callback) {
} ;
} ;
fs . ftruncateSync = function ( fd , len ) {
fs . ftruncateSync = function ( fd , len ) {
if ( util . isUndefined ( len ) ) {
if ( len === undefined ) {
len = 0 ;
len = 0 ;
}
}
return binding . ftruncate ( fd , len ) ;
return binding . ftruncate ( fd , len ) ;
@ -712,7 +712,7 @@ fs.fsyncSync = function(fd) {
} ;
} ;
fs . mkdir = function ( path , mode , callback ) {
fs . mkdir = function ( path , mode , callback ) {
if ( util . isFunction ( mode ) ) callback = mode ;
if ( typeof mode === 'function' ) callback = mode ;
callback = makeCallback ( callback ) ;
callback = makeCallback ( callback ) ;
if ( ! nullCheck ( path , callback ) ) return ;
if ( ! nullCheck ( path , callback ) ) return ;
var req = new FSReqWrap ( ) ;
var req = new FSReqWrap ( ) ;
@ -806,7 +806,7 @@ function preprocessSymlinkDestination(path, type, linkPath) {
}
}
fs . symlink = function ( destination , path , type_ , callback ) {
fs . symlink = function ( destination , path , type_ , callback ) {
var type = ( util . isString ( type_ ) ? type_ : null ) ;
var type = ( typeof type_ === 'string' ? type_ : null ) ;
var callback = makeCallback ( arguments [ arguments . length - 1 ] ) ;
var callback = makeCallback ( arguments [ arguments . length - 1 ] ) ;
if ( ! nullCheck ( destination , callback ) ) return ;
if ( ! nullCheck ( destination , callback ) ) return ;
@ -822,7 +822,7 @@ fs.symlink = function(destination, path, type_, callback) {
} ;
} ;
fs . symlinkSync = function ( destination , path , type ) {
fs . symlinkSync = function ( destination , path , type ) {
type = ( util . isString ( type ) ? type : null ) ;
type = ( typeof type === 'string' ? type : null ) ;
nullCheck ( destination ) ;
nullCheck ( destination ) ;
nullCheck ( path ) ;
nullCheck ( path ) ;
@ -973,7 +973,7 @@ fs.chownSync = function(path, uid, gid) {
// converts Date or number to a fractional UNIX timestamp
// converts Date or number to a fractional UNIX timestamp
function toUnixTimestamp ( time ) {
function toUnixTimestamp ( time ) {
if ( util . isNumber ( time ) ) {
if ( typeof time === 'number' ) {
return time ;
return time ;
}
}
if ( util . isDate ( time ) ) {
if ( util . isDate ( time ) ) {
@ -1043,11 +1043,11 @@ function writeAll(fd, buffer, offset, length, position, callback) {
fs . writeFile = function ( path , data , options , callback ) {
fs . writeFile = function ( path , data , options , callback ) {
var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
if ( util . isFunction ( options ) || ! options ) {
if ( ! options || typeof options === 'function' ) {
options = { encoding : 'utf8' , mode : 0o666 , flag : 'w' } ;
options = { encoding : 'utf8' , mode : 0o666 , flag : 'w' } ;
} else if ( util . isString ( options ) ) {
} else if ( typeof options === 'string' ) {
options = { encoding : options , mode : 0o666 , flag : 'w' } ;
options = { encoding : options , mode : 0o666 , flag : 'w' } ;
} else if ( ! util . isObject ( options ) ) {
} else if ( typeof options !== 'object' ) {
throw new TypeError ( 'Bad arguments' ) ;
throw new TypeError ( 'Bad arguments' ) ;
}
}
@ -1058,7 +1058,7 @@ fs.writeFile = function(path, data, options, callback) {
if ( openErr ) {
if ( openErr ) {
if ( callback ) callback ( openErr ) ;
if ( callback ) callback ( openErr ) ;
} else {
} else {
var buffer = util . isBuffer ( data ) ? data : new Buffer ( '' + data ,
var buffer = ( data instanceof Buffer ) ? data : new Buffer ( '' + data ,
options . encoding || 'utf8' ) ;
options . encoding || 'utf8' ) ;
var position = /a/ . test ( flag ) ? null : 0 ;
var position = /a/ . test ( flag ) ? null : 0 ;
writeAll ( fd , buffer , 0 , buffer . length , position , callback ) ;
writeAll ( fd , buffer , 0 , buffer . length , position , callback ) ;
@ -1069,9 +1069,9 @@ fs.writeFile = function(path, data, options, callback) {
fs . writeFileSync = function ( path , data , options ) {
fs . writeFileSync = function ( path , data , options ) {
if ( ! options ) {
if ( ! options ) {
options = { encoding : 'utf8' , mode : 0o666 , flag : 'w' } ;
options = { encoding : 'utf8' , mode : 0o666 , flag : 'w' } ;
} else if ( util . isString ( options ) ) {
} else if ( typeof options === 'string' ) {
options = { encoding : options , mode : 0o666 , flag : 'w' } ;
options = { encoding : options , mode : 0o666 , flag : 'w' } ;
} else if ( ! util . isObject ( options ) ) {
} else if ( typeof options !== 'object' ) {
throw new TypeError ( 'Bad arguments' ) ;
throw new TypeError ( 'Bad arguments' ) ;
}
}
@ -1079,7 +1079,7 @@ fs.writeFileSync = function(path, data, options) {
var flag = options . flag || 'w' ;
var flag = options . flag || 'w' ;
var fd = fs . openSync ( path , flag , options . mode ) ;
var fd = fs . openSync ( path , flag , options . mode ) ;
if ( ! util . isBuffer ( data ) ) {
if ( ! ( data instanceof Buffer ) ) {
data = new Buffer ( '' + data , options . encoding || 'utf8' ) ;
data = new Buffer ( '' + data , options . encoding || 'utf8' ) ;
}
}
var written = 0 ;
var written = 0 ;
@ -1098,11 +1098,11 @@ fs.writeFileSync = function(path, data, options) {
fs . appendFile = function ( path , data , options , callback_ ) {
fs . appendFile = function ( path , data , options , callback_ ) {
var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
var callback = maybeCallback ( arguments [ arguments . length - 1 ] ) ;
if ( util . isFunction ( options ) || ! options ) {
if ( ! options || typeof options === 'function' ) {
options = { encoding : 'utf8' , mode : 0o666 , flag : 'a' } ;
options = { encoding : 'utf8' , mode : 0o666 , flag : 'a' } ;
} else if ( util . isString ( options ) ) {
} else if ( typeof options === 'string' ) {
options = { encoding : options , mode : 0o666 , flag : 'a' } ;
options = { encoding : options , mode : 0o666 , flag : 'a' } ;
} else if ( ! util . isObject ( options ) ) {
} else if ( typeof options !== 'object' ) {
throw new TypeError ( 'Bad arguments' ) ;
throw new TypeError ( 'Bad arguments' ) ;
}
}
@ -1114,9 +1114,9 @@ fs.appendFile = function(path, data, options, callback_) {
fs . appendFileSync = function ( path , data , options ) {
fs . appendFileSync = function ( path , data , options ) {
if ( ! options ) {
if ( ! options ) {
options = { encoding : 'utf8' , mode : 0o666 , flag : 'a' } ;
options = { encoding : 'utf8' , mode : 0o666 , flag : 'a' } ;
} else if ( util . isString ( options ) ) {
} else if ( typeof options === 'string' ) {
options = { encoding : options , mode : 0o666 , flag : 'a' } ;
options = { encoding : options , mode : 0o666 , flag : 'a' } ;
} else if ( ! util . isObject ( options ) ) {
} else if ( typeof options !== 'object' ) {
throw new TypeError ( 'Bad arguments' ) ;
throw new TypeError ( 'Bad arguments' ) ;
}
}
if ( ! options . flag )
if ( ! options . flag )
@ -1165,7 +1165,7 @@ fs.watch = function(filename) {
var options ;
var options ;
var listener ;
var listener ;
if ( util . isObject ( arguments [ 1 ] ) ) {
if ( arguments [ 1 ] !== null && typeof arguments [ 1 ] === 'object' ) {
options = arguments [ 1 ] ;
options = arguments [ 1 ] ;
listener = arguments [ 2 ] ;
listener = arguments [ 2 ] ;
} else {
} else {
@ -1173,8 +1173,8 @@ fs.watch = function(filename) {
listener = arguments [ 1 ] ;
listener = arguments [ 1 ] ;
}
}
if ( util . isUndefined ( options . persistent ) ) options . persistent = true ;
if ( options . persistent === undefined ) options . persistent = true ;
if ( util . isUndefined ( options . recursive ) ) options . recursive = false ;
if ( options . recursive === undefined ) options . recursive = false ;
watcher = new FSWatcher ( ) ;
watcher = new FSWatcher ( ) ;
watcher . start ( filename , options . persistent , options . recursive ) ;
watcher . start ( filename , options . persistent , options . recursive ) ;
@ -1247,7 +1247,7 @@ fs.watchFile = function(filename) {
persistent : true
persistent : true
} ;
} ;
if ( util . isObject ( arguments [ 1 ] ) ) {
if ( arguments [ 1 ] !== null && typeof arguments [ 1 ] === 'object' ) {
options = util . _ extend ( options , arguments [ 1 ] ) ;
options = util . _ extend ( options , arguments [ 1 ] ) ;
listener = arguments [ 2 ] ;
listener = arguments [ 2 ] ;
} else {
} else {
@ -1275,7 +1275,7 @@ fs.unwatchFile = function(filename, listener) {
var stat = statWatchers [ filename ] ;
var stat = statWatchers [ filename ] ;
if ( util . isFunction ( listener ) ) {
if ( typeof listener === 'function' ) {
stat . removeListener ( 'change' , listener ) ;
stat . removeListener ( 'change' , listener ) ;
} else {
} else {
stat . removeAllListeners ( 'change' ) ;
stat . removeAllListeners ( 'change' ) ;
@ -1378,7 +1378,7 @@ fs.realpathSync = function realpathSync(p, cache) {
linkTarget = seenLinks [ id ] ;
linkTarget = seenLinks [ id ] ;
}
}
}
}
if ( util . isNull ( linkTarget ) ) {
if ( linkTarget === null ) {
fs . statSync ( base ) ;
fs . statSync ( base ) ;
linkTarget = fs . readlinkSync ( base ) ;
linkTarget = fs . readlinkSync ( base ) ;
}
}
@ -1400,7 +1400,7 @@ fs.realpathSync = function realpathSync(p, cache) {
fs . realpath = function realpath ( p , cache , cb ) {
fs . realpath = function realpath ( p , cache , cb ) {
if ( ! util . isFunction ( cb ) ) {
if ( typeof cb !== 'function' ) {
cb = maybeCallback ( cache ) ;
cb = maybeCallback ( cache ) ;
cache = null ;
cache = null ;
}
}
@ -1561,13 +1561,13 @@ function ReadStream(path, options) {
options . autoClose : true ;
options . autoClose : true ;
this . pos = undefined ;
this . pos = undefined ;
if ( ! util . isUndefined ( this . start ) ) {
if ( this . start !== undefined ) {
if ( ! util . isNumber ( this . start ) ) {
if ( typeof this . start !== 'number' ) {
throw TypeError ( 'start must be a Number' ) ;
throw TypeError ( 'start must be a Number' ) ;
}
}
if ( util . isUndefined ( this . end ) ) {
if ( this . end === undefined ) {
this . end = Infinity ;
this . end = Infinity ;
} else if ( ! util . isNumber ( this . end ) ) {
} else if ( typeof this . end !== 'number' ) {
throw TypeError ( 'end must be a Number' ) ;
throw TypeError ( 'end must be a Number' ) ;
}
}
@ -1578,7 +1578,7 @@ function ReadStream(path, options) {
this . pos = this . start ;
this . pos = this . start ;
}
}
if ( ! util . isNumber ( this . fd ) )
if ( typeof this . fd !== 'number' )
this . open ( ) ;
this . open ( ) ;
this . on ( 'end' , function ( ) {
this . on ( 'end' , function ( ) {
@ -1609,7 +1609,7 @@ ReadStream.prototype.open = function() {
} ;
} ;
ReadStream . prototype . _ read = function ( n ) {
ReadStream . prototype . _ read = function ( n ) {
if ( ! util . isNumber ( this . fd ) )
if ( typeof this . fd !== 'number' )
return this . once ( 'open' , function ( ) {
return this . once ( 'open' , function ( ) {
this . _ read ( n ) ;
this . _ read ( n ) ;
} ) ;
} ) ;
@ -1630,7 +1630,7 @@ ReadStream.prototype._read = function(n) {
var toRead = Math . min ( pool . length - pool . used , n ) ;
var toRead = Math . min ( pool . length - pool . used , n ) ;
var start = pool . used ;
var start = pool . used ;
if ( ! util . isUndefined ( this . pos ) )
if ( this . pos !== undefined )
toRead = Math . min ( this . end - this . pos + 1 , toRead ) ;
toRead = Math . min ( this . end - this . pos + 1 , toRead ) ;
// already read everything we were supposed to read!
// already read everything we were supposed to read!
@ -1643,7 +1643,7 @@ ReadStream.prototype._read = function(n) {
fs . read ( this . fd , pool , pool . used , toRead , this . pos , onread ) ;
fs . read ( this . fd , pool , pool . used , toRead , this . pos , onread ) ;
// move the pool positions, and internal position for reading.
// move the pool positions, and internal position for reading.
if ( ! util . isUndefined ( this . pos ) )
if ( this . pos !== undefined )
this . pos += toRead ;
this . pos += toRead ;
pool . used += toRead ;
pool . used += toRead ;
@ -1676,8 +1676,8 @@ ReadStream.prototype.close = function(cb) {
var self = this ;
var self = this ;
if ( cb )
if ( cb )
this . once ( 'close' , cb ) ;
this . once ( 'close' , cb ) ;
if ( this . closed || ! util . isNumber ( this . fd ) ) {
if ( this . closed || typeof this . fd !== 'number' ) {
if ( ! util . isNumber ( this . fd ) ) {
if ( typeof this . fd !== 'number' ) {
this . once ( 'open' , close ) ;
this . once ( 'open' , close ) ;
return ;
return ;
}
}
@ -1725,8 +1725,8 @@ function WriteStream(path, options) {
this . pos = undefined ;
this . pos = undefined ;
this . bytesWritten = 0 ;
this . bytesWritten = 0 ;
if ( ! util . isUndefined ( this . start ) ) {
if ( this . start !== undefined ) {
if ( ! util . isNumber ( this . start ) ) {
if ( typeof this . start !== 'number' ) {
throw TypeError ( 'start must be a Number' ) ;
throw TypeError ( 'start must be a Number' ) ;
}
}
if ( this . start < 0 ) {
if ( this . start < 0 ) {
@ -1736,7 +1736,7 @@ function WriteStream(path, options) {
this . pos = this . start ;
this . pos = this . start ;
}
}
if ( ! util . isNumber ( this . fd ) )
if ( typeof this . fd !== 'number' )
this . open ( ) ;
this . open ( ) ;
// dispose on finish.
// dispose on finish.
@ -1761,10 +1761,10 @@ WriteStream.prototype.open = function() {
WriteStream . prototype . _ write = function ( data , encoding , cb ) {
WriteStream . prototype . _ write = function ( data , encoding , cb ) {
if ( ! util . isBuffer ( data ) )
if ( ! ( data instanceof Buffer ) )
return this . emit ( 'error' , new Error ( 'Invalid data' ) ) ;
return this . emit ( 'error' , new Error ( 'Invalid data' ) ) ;
if ( ! util . isNumber ( this . fd ) )
if ( typeof this . fd !== 'number' )
return this . once ( 'open' , function ( ) {
return this . once ( 'open' , function ( ) {
this . _ write ( data , encoding , cb ) ;
this . _ write ( data , encoding , cb ) ;
} ) ;
} ) ;
@ -1779,7 +1779,7 @@ WriteStream.prototype._write = function(data, encoding, cb) {
cb ( ) ;
cb ( ) ;
} ) ;
} ) ;
if ( ! util . isUndefined ( this . pos ) )
if ( this . pos !== undefined )
this . pos += data . length ;
this . pos += data . length ;
} ;
} ;
@ -1817,10 +1817,10 @@ SyncWriteStream.prototype.write = function(data, arg1, arg2) {
// parse arguments
// parse arguments
if ( arg1 ) {
if ( arg1 ) {
if ( util . isString ( arg1 ) ) {
if ( typeof arg1 === 'string' ) {
encoding = arg1 ;
encoding = arg1 ;
cb = arg2 ;
cb = arg2 ;
} else if ( util . isFunction ( arg1 ) ) {
} else if ( typeof arg1 === 'function' ) {
cb = arg1 ;
cb = arg1 ;
} else {
} else {
throw new Error ( 'bad arg' ) ;
throw new Error ( 'bad arg' ) ;
@ -1829,7 +1829,7 @@ SyncWriteStream.prototype.write = function(data, arg1, arg2) {
assertEncoding ( encoding ) ;
assertEncoding ( encoding ) ;
// Change strings to buffers. SLOW
// Change strings to buffers. SLOW
if ( util . isString ( data ) ) {
if ( typeof data === 'string' ) {
data = new Buffer ( data , encoding ) ;
data = new Buffer ( data , encoding ) ;
}
}