@@ -39,7 +39,6 @@ const {
39
39
ReflectApply,
40
40
SafeMap,
41
41
SafeSet,
42
- String,
43
42
StringPrototypeCharCodeAt,
44
43
StringPrototypeIndexOf,
45
44
StringPrototypeSlice,
@@ -84,7 +83,6 @@ const { FSReqCallback } = binding;
84
83
const { toPathIfFileURL } = require ( 'internal/url' ) ;
85
84
const {
86
85
customPromisifyArgs : kCustomPromisifyArgsSymbol ,
87
- deprecate,
88
86
kEmptyObject,
89
87
promisify : {
90
88
custom : kCustomPromisifiedSymbol ,
@@ -123,7 +121,6 @@ const {
123
121
validateRmOptionsSync,
124
122
validateRmdirOptions,
125
123
validateStringAfterArrayBufferView,
126
- validatePrimitiveStringAfterArrayBufferView,
127
124
warnOnNonPortableTemplate
128
125
} = require ( 'internal/fs/utils' ) ;
129
126
const {
@@ -171,11 +168,6 @@ const isWindows = process.platform === 'win32';
171
168
const isOSX = process . platform === 'darwin' ;
172
169
173
170
174
- const showStringCoercionDeprecation = deprecate (
175
- ( ) => { } ,
176
- 'Implicit coercion of objects with own toString property is deprecated.' ,
177
- 'DEP0162'
178
- ) ;
179
171
function showTruncateDeprecation ( ) {
180
172
if ( truncateWarn ) {
181
173
process . emitWarning (
@@ -813,7 +805,7 @@ function readvSync(fd, buffers, position) {
813
805
/**
814
806
* Writes `buffer` to the specified `fd` (file descriptor).
815
807
* @param {number } fd
816
- * @param {Buffer | TypedArray | DataView | string | object } buffer
808
+ * @param {Buffer | TypedArray | DataView | string } buffer
817
809
* @param {number | object } [offsetOrOptions]
818
810
* @param {number } [length]
819
811
* @param {number | null } [position]
@@ -861,9 +853,6 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
861
853
}
862
854
863
855
validateStringAfterArrayBufferView ( buffer , 'buffer' ) ;
864
- if ( typeof buffer !== 'string' ) {
865
- showStringCoercionDeprecation ( ) ;
866
- }
867
856
868
857
if ( typeof position !== 'function' ) {
869
858
if ( typeof offset === 'function' ) {
@@ -875,7 +864,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
875
864
length = 'utf8' ;
876
865
}
877
866
878
- const str = String ( buffer ) ;
867
+ const str = buffer ;
879
868
validateEncoding ( str , length ) ;
880
869
callback = maybeCallback ( position ) ;
881
870
@@ -926,7 +915,7 @@ function writeSync(fd, buffer, offsetOrOptions, length, position) {
926
915
result = binding . writeBuffer ( fd , buffer , offset , length , position ,
927
916
undefined , ctx ) ;
928
917
} else {
929
- validatePrimitiveStringAfterArrayBufferView ( buffer , 'buffer' ) ;
918
+ validateStringAfterArrayBufferView ( buffer , 'buffer' ) ;
930
919
validateEncoding ( buffer , length ) ;
931
920
932
921
if ( offset === undefined )
@@ -2154,7 +2143,7 @@ function writeAll(fd, isUserFd, buffer, offset, length, signal, callback) {
2154
2143
/**
2155
2144
* Asynchronously writes data to the file.
2156
2145
* @param {string | Buffer | URL | number } path
2157
- * @param {string | Buffer | TypedArray | DataView | object } data
2146
+ * @param {string | Buffer | TypedArray | DataView } data
2158
2147
* @param {{
2159
2148
* encoding?: string | null;
2160
2149
* mode?: number;
@@ -2171,10 +2160,7 @@ function writeFile(path, data, options, callback) {
2171
2160
2172
2161
if ( ! isArrayBufferView ( data ) ) {
2173
2162
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' ) ;
2178
2164
}
2179
2165
2180
2166
if ( isFd ( path ) ) {
@@ -2201,7 +2187,7 @@ function writeFile(path, data, options, callback) {
2201
2187
/**
2202
2188
* Synchronously writes data to the file.
2203
2189
* @param {string | Buffer | URL | number } path
2204
- * @param {string | Buffer | TypedArray | DataView | object } data
2190
+ * @param {string | Buffer | TypedArray | DataView } data
2205
2191
* @param {{
2206
2192
* encoding?: string | null;
2207
2193
* mode?: number;
@@ -2214,10 +2200,7 @@ function writeFileSync(path, data, options) {
2214
2200
2215
2201
if ( ! isArrayBufferView ( data ) ) {
2216
2202
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' ) ;
2221
2204
}
2222
2205
2223
2206
const flag = options . flag || 'w' ;
0 commit comments