@@ -39,7 +39,6 @@ const {
3939 ReflectApply,
4040 SafeMap,
4141 SafeSet,
42- String,
4342 StringPrototypeCharCodeAt,
4443 StringPrototypeIndexOf,
4544 StringPrototypeSlice,
@@ -84,7 +83,6 @@ const { FSReqCallback } = binding;
8483const { toPathIfFileURL } = require ( 'internal/url' ) ;
8584const {
8685 customPromisifyArgs : kCustomPromisifyArgsSymbol ,
87- deprecate,
8886 kEmptyObject,
8987 promisify : {
9088 custom : kCustomPromisifiedSymbol ,
@@ -123,7 +121,6 @@ const {
123121 validateRmOptionsSync,
124122 validateRmdirOptions,
125123 validateStringAfterArrayBufferView,
126- validatePrimitiveStringAfterArrayBufferView,
127124 warnOnNonPortableTemplate
128125} = require ( 'internal/fs/utils' ) ;
129126const {
@@ -171,11 +168,6 @@ const isWindows = process.platform === 'win32';
171168const isOSX = process . platform === 'darwin' ;
172169
173170
174- const showStringCoercionDeprecation = deprecate (
175- ( ) => { } ,
176- 'Implicit coercion of objects with own toString property is deprecated.' ,
177- 'DEP0162'
178- ) ;
179171function showTruncateDeprecation ( ) {
180172 if ( truncateWarn ) {
181173 process . emitWarning (
@@ -813,7 +805,7 @@ function readvSync(fd, buffers, position) {
813805/**
814806 * Writes `buffer` to the specified `fd` (file descriptor).
815807 * @param {number } fd
816- * @param {Buffer | TypedArray | DataView | string | object } buffer
808+ * @param {Buffer | TypedArray | DataView | string } buffer
817809 * @param {number | object } [offsetOrOptions]
818810 * @param {number } [length]
819811 * @param {number | null } [position]
@@ -861,9 +853,6 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
861853 }
862854
863855 validateStringAfterArrayBufferView ( buffer , 'buffer' ) ;
864- if ( typeof buffer !== 'string' ) {
865- showStringCoercionDeprecation ( ) ;
866- }
867856
868857 if ( typeof position !== 'function' ) {
869858 if ( typeof offset === 'function' ) {
@@ -875,7 +864,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
875864 length = 'utf8' ;
876865 }
877866
878- const str = String ( buffer ) ;
867+ const str = buffer ;
879868 validateEncoding ( str , length ) ;
880869 callback = maybeCallback ( position ) ;
881870
@@ -926,7 +915,7 @@ function writeSync(fd, buffer, offsetOrOptions, length, position) {
926915 result = binding . writeBuffer ( fd , buffer , offset , length , position ,
927916 undefined , ctx ) ;
928917 } else {
929- validatePrimitiveStringAfterArrayBufferView ( buffer , 'buffer' ) ;
918+ validateStringAfterArrayBufferView ( buffer , 'buffer' ) ;
930919 validateEncoding ( buffer , length ) ;
931920
932921 if ( offset === undefined )
@@ -2154,7 +2143,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, signal, callback) {
21542143/**
21552144 * Asynchronously writes data to the file.
21562145 * @param {string | Buffer | URL | number } path
2157- * @param {string | Buffer | TypedArray | DataView | object } data
2146+ * @param {string | Buffer | TypedArray | DataView } data
21582147 * @param {{
21592148 * encoding?: string | null;
21602149 * mode?: number;
@@ -2171,10 +2160,7 @@ function writeFile(path, data, options, callback) {
21712160
21722161 if ( ! isArrayBufferView ( data ) ) {
21732162 validateStringAfterArrayBufferView ( data , 'data' ) ;
2174- if ( typeof data !== 'string' ) {
2175- showStringCoercionDeprecation ( ) ;
2176- }
2177- data = Buffer . from ( String ( data ) , options . encoding || 'utf8' ) ;
2163+ data = Buffer . from ( data , options . encoding || 'utf8' ) ;
21782164 }
21792165
21802166 if ( isFd ( path ) ) {
@@ -2201,7 +2187,7 @@ function writeFile(path, data, options, callback) {
22012187/**
22022188 * Synchronously writes data to the file.
22032189 * @param {string | Buffer | URL | number } path
2204- * @param {string | Buffer | TypedArray | DataView | object } data
2190+ * @param {string | Buffer | TypedArray | DataView } data
22052191 * @param {{
22062192 * encoding?: string | null;
22072193 * mode?: number;
@@ -2214,10 +2200,7 @@ function writeFileSync(path, data, options) {
22142200
22152201 if ( ! isArrayBufferView ( data ) ) {
22162202 validateStringAfterArrayBufferView ( data , 'data' ) ;
2217- if ( typeof data !== 'string' ) {
2218- showStringCoercionDeprecation ( ) ;
2219- }
2220- data = Buffer . from ( String ( data ) , options . encoding || 'utf8' ) ;
2203+ data = Buffer . from ( data , options . encoding || 'utf8' ) ;
22212204 }
22222205
22232206 const flag = options . flag || 'w' ;
0 commit comments