@@ -8,8 +8,6 @@ const fs = require('fs')
8
8
const MurmurHash3 = require ( 'imurmurhash' )
9
9
const onExit = require ( 'signal-exit' )
10
10
const path = require ( 'path' )
11
- const isTypedArray = require ( 'is-typedarray' )
12
- const typedArrayToBuffer = require ( 'typedarray-to-buffer' )
13
11
const { promisify } = require ( 'util' )
14
12
const activeFiles = { }
15
13
@@ -110,10 +108,7 @@ async function writeFileAsync (filename, data, options = {}) {
110
108
if ( options . tmpfileCreated ) {
111
109
await options . tmpfileCreated ( tmpfile )
112
110
}
113
- if ( isTypedArray ( data ) ) {
114
- data = typedArrayToBuffer ( data )
115
- }
116
- if ( Buffer . isBuffer ( data ) ) {
111
+ if ( Buffer . isBuffer ( data ) || ArrayBuffer . isView ( data ) ) {
117
112
await promisify ( fs . write ) ( fd , data , 0 , data . length , 0 )
118
113
} else if ( data != null ) {
119
114
await promisify ( fs . write ) ( fd , String ( data ) , 0 , String ( options . encoding || 'utf8' ) )
@@ -215,10 +210,7 @@ function writeFileSync (filename, data, options) {
215
210
if ( options . tmpfileCreated ) {
216
211
options . tmpfileCreated ( tmpfile )
217
212
}
218
- if ( isTypedArray ( data ) ) {
219
- data = typedArrayToBuffer ( data )
220
- }
221
- if ( Buffer . isBuffer ( data ) ) {
213
+ if ( Buffer . isBuffer ( data ) || ArrayBuffer . isView ( data ) ) {
222
214
fs . writeSync ( fd , data , 0 , data . length , 0 )
223
215
} else if ( data != null ) {
224
216
fs . writeSync ( fd , String ( data ) , 0 , String ( options . encoding || 'utf8' ) )
0 commit comments