Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blob-polyfill

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blob-polyfill - npm Package Compare versions

Comparing version 7.0.20220408 to 8.0.20240630

209

Blob.js

@@ -11,2 +11,36 @@ /* Blob.js

function array2base64 (input) {
var byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var output = [];
for (var i = 0; i < input.length; i += 3) {
var byte1 = input[i];
var haveByte2 = i + 1 < input.length;
var byte2 = haveByte2 ? input[i + 1] : 0;
var haveByte3 = i + 2 < input.length;
var byte3 = haveByte3 ? input[i + 2] : 0;
var outByte1 = byte1 >> 2;
var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
var outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
var outByte4 = byte3 & 0x3F;
if (!haveByte3) {
outByte4 = 64;
if (!haveByte2) {
outByte3 = 64;
}
}
output.push(
byteToCharMap[outByte1], byteToCharMap[outByte2],
byteToCharMap[outByte3], byteToCharMap[outByte4]
);
}
return output.join("");
}
(function(global) {

@@ -97,4 +131,4 @@ (function (factory) {

if (global.Blob) {
BlobBuilderConstructor.prototype = Blob.prototype;
BlobConstructor.prototype = Blob.prototype;
BlobBuilderConstructor.prototype = global.Blob.prototype;
BlobConstructor.prototype = global.Blob.prototype;
}

@@ -268,36 +302,3 @@

}
function array2base64 (input) {
var byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
var output = [];
for (var i = 0; i < input.length; i += 3) {
var byte1 = input[i];
var haveByte2 = i + 1 < input.length;
var byte2 = haveByte2 ? input[i + 1] : 0;
var haveByte3 = i + 2 < input.length;
var byte3 = haveByte3 ? input[i + 2] : 0;
var outByte1 = byte1 >> 2;
var outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
var outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
var outByte4 = byte3 & 0x3F;
if (!haveByte3) {
outByte4 = 64;
if (!haveByte2) {
outByte3 = 64;
}
}
output.push(
byteToCharMap[outByte1], byteToCharMap[outByte2],
byteToCharMap[outByte3], byteToCharMap[outByte4]
);
}
return output.join("");
}
var create = Object.create || function (a) {

@@ -390,2 +391,3 @@ function c () {}

}
Blob.isPolyfill = true;

@@ -422,2 +424,3 @@ Blob.prototype.arrayBuffer = function () {

File.isPolyfill = true;
File.prototype = create(Blob.prototype);

@@ -439,65 +442,5 @@ File.prototype.constructor = File;

/********************************************************/
/* FileReader constructor */
/* URL */
/********************************************************/
function FileReader () {
if (!(this instanceof FileReader)) {
throw new TypeError("Failed to construct 'FileReader': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
var delegate = document.createDocumentFragment();
this.addEventListener = delegate.addEventListener;
this.dispatchEvent = function (evt) {
var local = this["on" + evt.type];
if (typeof local === "function") local(evt);
delegate.dispatchEvent(evt);
};
this.removeEventListener = delegate.removeEventListener;
}
function _read (fr, blob, kind) {
if (!(blob instanceof Blob)) {
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
}
fr.result = "";
setTimeout(function () {
this.readyState = FileReader.LOADING;
fr.dispatchEvent(new Event("load"));
fr.dispatchEvent(new Event("loadend"));
});
}
FileReader.EMPTY = 0;
FileReader.LOADING = 1;
FileReader.DONE = 2;
FileReader.prototype.error = null;
FileReader.prototype.onabort = null;
FileReader.prototype.onerror = null;
FileReader.prototype.onload = null;
FileReader.prototype.onloadend = null;
FileReader.prototype.onloadstart = null;
FileReader.prototype.onprogress = null;
FileReader.prototype.readAsDataURL = function (blob) {
_read(this, blob, "readAsDataURL");
this.result = "data:" + blob.type + ";base64," + array2base64(blob._buffer);
};
FileReader.prototype.readAsText = function (blob) {
_read(this, blob, "readAsText");
this.result = textDecode(blob._buffer);
};
FileReader.prototype.readAsArrayBuffer = function (blob) {
_read(this, blob, "readAsText");
// return ArrayBuffer when possible
this.result = (blob._buffer.buffer || blob._buffer).slice();
};
FileReader.prototype.abort = function () {};
/********************************************************/
/* URL */
/********************************************************/
URL.createObjectURL = function (blob) {

@@ -508,2 +451,3 @@ return blob instanceof Blob

};
URL.createObjectURL.isPolyfill = true;

@@ -513,2 +457,3 @@ URL.revokeObjectURL = function (url) {

};
URL.revokeObjectURL.isPolyfill = true;

@@ -532,8 +477,6 @@ /********************************************************/

exports.File = File;
exports.FileReader = FileReader;
exports.URL = URL;
}
function fixFileAndXHR () {
var isIE = !!global.ActiveXObject || (
var isIE = !!global.ActiveXObject || (typeof document !== "undefined" &&
"-ms-scroll-limit" in document.documentElement.style &&

@@ -561,3 +504,2 @@ "-ms-ime-align" in document.documentElement.style

exports.File = global.File;
exports.FileReader = global.FileReader;
} catch (e) {

@@ -576,3 +518,3 @@ try {

} catch (e) {
exports.File = function (b, d, c) {
exports.File = function File(b, d, c) {
var blob = new Blob(b, c);

@@ -595,2 +537,3 @@ var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date();

}
exports.File.isPolyfill = true;
}

@@ -609,2 +552,66 @@ }

/********************************************************/
/* FileReader constructor */
/********************************************************/
function FileReader () {
if (!(this instanceof FileReader)) {
throw new TypeError("Failed to construct 'FileReader': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
var delegate = document.createDocumentFragment();
this.addEventListener = delegate.addEventListener;
this.dispatchEvent = function (evt) {
var local = this["on" + evt.type];
if (typeof local === "function") local(evt);
delegate.dispatchEvent(evt);
};
this.removeEventListener = delegate.removeEventListener;
}
function _read (fr, blob, kind) {
if (!(blob instanceof exports.Blob)) {
throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
}
fr.result = "";
setTimeout(function () {
this.readyState = FileReader.LOADING;
fr.dispatchEvent(new Event("load"));
fr.dispatchEvent(new Event("loadend"));
});
}
FileReader.EMPTY = 0;
FileReader.LOADING = 1;
FileReader.DONE = 2;
FileReader.prototype.error = null;
FileReader.prototype.onabort = null;
FileReader.prototype.onerror = null;
FileReader.prototype.onload = null;
FileReader.prototype.onloadend = null;
FileReader.prototype.onloadstart = null;
FileReader.prototype.onprogress = null;
FileReader.prototype.readAsDataURL = function (blob) {
_read(this, blob, "readAsDataURL");
this.result = "data:" + blob.type + ";base64," + array2base64(blob._buffer);
};
FileReader.prototype.readAsText = function (blob) {
_read(this, blob, "readAsText");
this.result = textDecode(blob._buffer);
};
FileReader.prototype.readAsArrayBuffer = function (blob) {
_read(this, blob, "readAsText");
// return ArrayBuffer when possible
this.result = (blob._buffer.buffer || blob._buffer).slice();
};
FileReader.prototype.abort = function () {};
exports.FileReader = global.FileReader || FileReader;
exports.URL = global.URL || URL;
if (strTag) {

@@ -611,0 +618,0 @@ if (!exports.File.prototype[strTag]) exports.File.prototype[strTag] = "File";

# `blob-polyfill` CHANGELOG
## v8.0.20240630
* [Blob.js] Change Blob.prototype to global.Blob.prototype (@tmisirpash)
* [Blob.js] Make it work in environments where global.Blob exists, but global.FileReader does not (@bjornstar)
* [Blob.js] Add `isPolyfill` property to the polyfilled versions so we can differentiate them (@bjornstar)
* [test] Unskip tests and update to work in environments with global.Blob & global.File & global.URL (@bjornstar)
* [.github] Update action versions and test node v12-v22 (@bjornstar)
## v7.0.20220408

@@ -4,0 +11,0 @@ * [Blob.js] Do not modify array that is passed into constructor (@zyrong)

{
"name": "blob-polyfill",
"version": "7.0.20220408",
"version": "8.0.20240630",
"description": "Blob.js implements the W3C Blob interface in browsers that do not natively support it.",

@@ -5,0 +5,0 @@ "main": "Blob.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc