@@ -8,8 +8,6 @@ const fs = require('fs')
88const MurmurHash3 = require ( 'imurmurhash' )
99const onExit = require ( 'signal-exit' )
1010const path = require ( 'path' )
11- const isTypedArray = require ( 'is-typedarray' )
12- const typedArrayToBuffer = require ( 'typedarray-to-buffer' )
1311const { promisify } = require ( 'util' )
1412const activeFiles = { }
1513
@@ -110,10 +108,7 @@ async function writeFileAsync (filename, data, options = {}) {
110108 if ( options . tmpfileCreated ) {
111109 await options . tmpfileCreated ( tmpfile )
112110 }
113- if ( isTypedArray ( data ) ) {
114- data = typedArrayToBuffer ( data )
115- }
116- if ( Buffer . isBuffer ( data ) ) {
111+ if ( Buffer . isBuffer ( data ) || ArrayBuffer . isView ( data ) ) {
117112 await promisify ( fs . write ) ( fd , data , 0 , data . length , 0 )
118113 } else if ( data != null ) {
119114 await promisify ( fs . write ) ( fd , String ( data ) , 0 , String ( options . encoding || 'utf8' ) )
@@ -215,10 +210,7 @@ function writeFileSync (filename, data, options) {
215210 if ( options . tmpfileCreated ) {
216211 options . tmpfileCreated ( tmpfile )
217212 }
218- if ( isTypedArray ( data ) ) {
219- data = typedArrayToBuffer ( data )
220- }
221- if ( Buffer . isBuffer ( data ) ) {
213+ if ( Buffer . isBuffer ( data ) || ArrayBuffer . isView ( data ) ) {
222214 fs . writeSync ( fd , data , 0 , data . length , 0 )
223215 } else if ( data != null ) {
224216 fs . writeSync ( fd , String ( data ) , 0 , String ( options . encoding || 'utf8' ) )
0 commit comments