Blob.js
Blob.js copied to clipboard
Fix existing problems
require('./Blob')
const arr = ['str']
new Blob(arr)
console.log(arr);
// The original array has been modified,Final output [ Uint8Array(3) [ 115, 116, 114 ] ]
// Expected results: ['str']
const dataView = new DataView(new Uint8Array([1,2,3]).buffer)
const blob = new Blob([dataView])
blob.arrayBuffer().then(buffer => {
console.log(buffer);
// Final output: [ 0, 0, 0 ]
// Expected results: [ 1, 2, 3 ]
})
use the ArrayBuffer.isView method to check that the DataView is true. Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView