blob-polyfill
Advanced tools
Comparing version 5.0.20210201 to 6.0.20211015
55
Blob.js
@@ -43,3 +43,2 @@ /* Blob.js | ||
var blobSupportsArrayBufferView = false; | ||
var arrayBufferSupported = !!global.ArrayBuffer; | ||
var blobBuilderSupported = BlobBuilder | ||
@@ -259,5 +258,2 @@ && BlobBuilder.prototype.append | ||
function FakeBlobBuilder () { | ||
function isDataView (obj) { | ||
return obj && Object.prototype.isPrototypeOf.call(DataView, obj); | ||
} | ||
function bufferClone (buf) { | ||
@@ -312,20 +308,35 @@ var view = new Array(buf.byteLength); | ||
if (arrayBufferSupported) { | ||
var viewClasses = [ | ||
"[object Int8Array]", | ||
"[object Uint8Array]", | ||
"[object Uint8ClampedArray]", | ||
"[object Int16Array]", | ||
"[object Uint16Array]", | ||
"[object Int32Array]", | ||
"[object Uint32Array]", | ||
"[object Float32Array]", | ||
"[object Float64Array]" | ||
]; | ||
function getObjectTypeName (o) { | ||
return Object.prototype.toString.call(o).slice(8, -1); | ||
} | ||
var isArrayBufferView = ArrayBuffer.isView || function (obj) { | ||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1; | ||
}; | ||
function isPrototypeOf(c, o) { | ||
return typeof c === "object" && Object.prototype.isPrototypeOf.call(c.prototype, o); | ||
} | ||
function isDataView (o) { | ||
return getObjectTypeName(o) === "DataView" || isPrototypeOf(global.DataView, o); | ||
} | ||
var arrayBufferClassNames = [ | ||
"Int8Array", | ||
"Uint8Array", | ||
"Uint8ClampedArray", | ||
"Int16Array", | ||
"Uint16Array", | ||
"Int32Array", | ||
"Uint32Array", | ||
"Float32Array", | ||
"Float64Array", | ||
"ArrayBuffer" | ||
]; | ||
function includes(a, v) { | ||
return a.indexOf(v) !== -1; | ||
} | ||
function isArrayBuffer(o) { | ||
return includes(arrayBufferClassNames, getObjectTypeName(o)) || isPrototypeOf(global.ArrayBuffer, o); | ||
} | ||
function concatTypedarrays (chunks) { | ||
@@ -358,6 +369,6 @@ var size = 0; | ||
chunks[i] = textEncode(chunk); | ||
} else if (arrayBufferSupported && (Object.prototype.isPrototypeOf.call(ArrayBuffer, chunk) || isArrayBufferView(chunk))) { | ||
} else if (isDataView(chunk)) { | ||
chunks[i] = bufferClone(chunk.buffer); | ||
} else if (isArrayBuffer(chunk)) { | ||
chunks[i] = bufferClone(chunk); | ||
} else if (arrayBufferSupported && isDataView(chunk)) { | ||
chunks[i] = bufferClone(chunk.buffer); | ||
} else { | ||
@@ -364,0 +375,0 @@ chunks[i] = textEncode(String(chunk)); |
{ | ||
"name": "blob-polyfill", | ||
"version": "5.0.20210201", | ||
"version": "6.0.20211015", | ||
"homepage": "https://github.com/bjornstar/blob-polyfill", | ||
@@ -5,0 +5,0 @@ "authors": [ |
# `blob-polyfill` CHANGELOG | ||
## v6.0.20211015 | ||
* [Blob.js] Check object class names when determining Object types (@coclauso) | ||
* [Blob.js] Reduce redundancies in getting class names and prototype checks (@bjornstar) | ||
* [test] Add a test for round tripping data in ArrayBuffers (@coclauso) | ||
## v5.0.20210201 | ||
@@ -4,0 +9,0 @@ * [Blob.js] Blob.arrayBuffer() should return a promise that resolves with an ArrayBuffer (@bjornstar) |
{ | ||
"name": "blob-polyfill", | ||
"version": "5.0.20210201", | ||
"version": "6.0.20211015", | ||
"description": "Blob.js implements the W3C Blob interface in browsers that do not natively support it.", | ||
@@ -5,0 +5,0 @@ "main": "Blob.js", |
25680
632