Blob.js icon indicating copy to clipboard operation
Blob.js copied to clipboard

Fix existing problems

Open zyrong opened this issue 3 years ago • 0 comments

  1. fix: new Blob(chunks); chunks exists references modify problem
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']
  1. fix: ArrayBuffer.isView judge DataView Existing problems
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

zyrong avatar Apr 03 '22 09:04 zyrong