Socket
Socket
Sign inDemoInstall

formdata-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formdata-polyfill - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

55

FormData.js
const map = new WeakMap
const wm = o => map.get(o)
var Fil
let type = obj => Object.prototype.toString.call(obj).slice(8, -1)
if (window.Symbol && Symbol.toStringTag) {
if (!Blob.prototype[Symbol.toStringTag]) {
Blob.prototype[Symbol.toStringTag] = 'Blob'
}
if ('File' in window && !File.prototype[Symbol.toStringTag]) {
File.prototype[Symbol.toStringTag] = 'File'
}
}
try {
new File([], '')
Fil = File
} catch(e) {
/**
* @see http://www.w3.org/TR/FileAPI/#dfn-file
* @param {!Array<string|!Blob|!ArrayBuffer>=} chunks
* @param {string=} filename
* @param {{type: (string|undefined), lastModified: (number|undefined)}=}
* opts
* @constructor
* @extends {Blob}
*/
Fil = function File(chunks, filename, opts) {
var _this = new Blob(chunks, opts)
var modified = opts && opts.lastModified !== undefined ? new Date(opts.lastModified) : new Date
} catch (a) {
window.File = function (b, d, c) {
var blob = new Blob(b, c)
var t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date
Object.defineProperties(_this, {
Object.defineProperties(blob, {
name: {
value: filename
value: d
},
lastModifiedDate: {
value: modified
value: t
},
lastModified: {
value: +modified
value: +t
},
toString: {
value() {
value: function () {
return '[object File]'

@@ -40,7 +39,9 @@ }

Object.defineProperty(_this, Symbol.toStringTag, {
value: 'File'
})
if (window.Symbol && Symbol.toStringTag) {
Object.defineProperty(blob, Symbol.toStringTag, {
value: 'File'
})
}
return _this
return blob
}

@@ -51,3 +52,3 @@ }

if (value instanceof Blob)
value = new Fil([value], filename, {
value = new File([value], filename, {
type: value.type,

@@ -327,3 +328,5 @@ lastModified: value.lastModified

*/
FormDataPolyfill.prototype[Symbol.toStringTag] = 'FormData'
if (window.Symbol && Symbol.toStringTag) {
FormDataPolyfill.prototype[Symbol.toStringTag] = 'FormData'
}

@@ -330,0 +333,0 @@ for (let [method, overide] of [

@@ -1,16 +0,17 @@

var f,h="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,d){a!=Array.prototype&&a!=Object.prototype&&(a[b]=d.value)},m="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function n(){n=function(){};m.Symbol||(m.Symbol=p)}var r=0;function p(a){return"jscomp_symbol_"+(a||"")+r++}
function t(){n();var a=m.Symbol.iterator;a||(a=m.Symbol.iterator=m.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&h(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return u(this)}});t=function(){}}function u(a){var b=0;return v(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})}function v(a){t();a={next:a};a[m.Symbol.iterator]=function(){return this};return a}function w(a){t();n();t();var b=a[Symbol.iterator];return b?b.call(a):u(a)}
function x(a){for(var b,d=[];!(b=a.next()).done;)d.push(b.value);return d}var z=new WeakMap,A;try{new File([],""),A=File}catch(a){A=function(b,d,c){b=new Blob(b,c);c=c&&void 0!==c.lastModified?new Date(c.lastModified):new Date;Object.defineProperties(b,{name:{value:d},lastModifiedDate:{value:c},lastModified:{value:+c},toString:{value:function(){return"[object File]"}}});n();Object.defineProperty(b,Symbol.toStringTag,{value:"File"});return b}}
function B(a){var b=w(a);a=b.next().value;b=b.next().value;a instanceof Blob&&(a=new A([a],b,{type:a.type,lastModified:a.lastModified}));return a}function D(a){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");return[a+""]}
function E(a,b,d){if(2>arguments.length)throw new TypeError("2 arguments required, but only "+arguments.length+" present.");return b instanceof Blob?[a+"",b,void 0!==d?d+"":"File"===Object.prototype.toString.call(b).slice(8,-1)?b.name:"Blob"]:[a+"",b+""]}
function F(a){z.set(this,Object.create(null));if(!a)return this;a=w(Array.from(a.elements));for(var b=a.next();!b.done;b=a.next()){var d=b.value,b=d.name,c=d.type,e=d.value,g=d.files,d=d.selectedOptions;if(b)if("file"===c)for(c=w(g),e=c.next();!e.done;e=c.next())this.append(b,e.value);else if("select-multiple"===c||"select-one"===c)for(c=w(Array.from(d)),e=c.next();!e.done;e=c.next())this.append(b,e.value.value);else"checkbox"===c&&this.append(b,e)}}f=F.prototype;
var f,h="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,d){a!=Array.prototype&&a!=Object.prototype&&(a[b]=d.value)},k="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function n(){n=function(){};k.Symbol||(k.Symbol=p)}var q=0;function p(a){return"jscomp_symbol_"+(a||"")+q++}
function t(){n();var a=k.Symbol.iterator;a||(a=k.Symbol.iterator=k.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&h(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return u(this)}});t=function(){}}function u(a){var b=0;return v(function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}})}function v(a){t();a={next:a};a[k.Symbol.iterator]=function(){return this};return a}function w(a){t();n();t();var b=a[Symbol.iterator];return b?b.call(a):u(a)}
function y(a){for(var b,d=[];!(b=a.next()).done;)d.push(b.value);return d}var z=new WeakMap;n();window.Symbol&&Symbol.toStringTag&&(n(),Blob.prototype[Symbol.toStringTag]||(n(),Blob.prototype[Symbol.toStringTag]="Blob"),n(),"File"in window&&!File.prototype[Symbol.toStringTag]&&(n(),File.prototype[Symbol.toStringTag]="File"));
try{new File([],"")}catch(a){window.File=function(b,d,c){b=new Blob(b,c);c=c&&void 0!==c.lastModified?new Date(c.lastModified):new Date;Object.defineProperties(b,{name:{value:d},lastModifiedDate:{value:c},lastModified:{value:+c},toString:{value:function(){return"[object File]"}}});n();window.Symbol&&Symbol.toStringTag&&(n(),Object.defineProperty(b,Symbol.toStringTag,{value:"File"}));return b}}
function A(a){var b=w(a);a=b.next().value;b=b.next().value;a instanceof Blob&&(a=new File([a],b,{type:a.type,lastModified:a.lastModified}));return a}function C(a){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");return[a+""]}
function D(a,b,d){if(2>arguments.length)throw new TypeError("2 arguments required, but only "+arguments.length+" present.");return b instanceof Blob?[a+"",b,void 0!==d?d+"":"File"===Object.prototype.toString.call(b).slice(8,-1)?b.name:"Blob"]:[a+"",b+""]}
function E(a){z.set(this,Object.create(null));if(!a)return this;a=w(Array.from(a.elements));for(var b=a.next();!b.done;b=a.next()){var d=b.value,b=d.name,c=d.type,e=d.value,g=d.files,d=d.selectedOptions;if(b)if("file"===c)for(c=w(g),e=c.next();!e.done;e=c.next())this.append(b,e.value);else if("select-multiple"===c||"select-one"===c)for(c=w(Array.from(d)),e=c.next();!e.done;e=c.next())this.append(b,e.value.value);else"checkbox"===c&&this.append(b,e)}}f=E.prototype;
f.append=function(a,b,d){var c=z.get(this);c[a]||(c[a]=[]);c[a].push([b,d])};f["delete"]=function(a){delete z.get(this)[a]};
f.entries=function(){function a(a){for(;;)switch(b){case 0:y=z.get(L);l=[];k=y;for(g in k)l.push(g);q=0;case 1:if(!(q<l.length)){b=3;break}g=l[q];if(g in k){b=4;break}b=2;break;case 4:e=w(y[g]),c=e.next();case 5:if(c.done){b=7;break}d=c.value;b=8;return{value:[g,B(d)],done:!1};case 8:if(void 0===a){b=9;break}b=-1;throw a;case 9:case 6:c=e.next();b=5;break;case 7:case 2:q++;b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,g,k,q,l,y,L=this,C={next:function(){return a(void 0)},
"throw":function(b){return a(b)},"return":function(){throw Error("Not yet implemented");}};t();C[Symbol.iterator]=function(){return this};return C};f.forEach=function(a,b){for(var d=w(this),c=d.next();!c.done;c=d.next()){var e=w(c.value),c=e.next().value,e=e.next().value;a.call(b,e,c,this)}};f.get=function(a){var b=z.get(this);return b[a]?B(b[a][0]):null};f.getAll=function(a){return(z.get(this)[a]||[]).map(B)};f.has=function(a){return a in z.get(this)};
f.keys=function(){function a(a){for(;;)switch(b){case 0:k=w(q),g=k.next();case 1:if(g.done){b=3;break}e=g.value;c=w(e);d=c.next().value;b=4;return{value:d,done:!1};case 4:if(void 0===a){b=5;break}b=-1;throw a;case 5:case 2:g=k.next();b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,g,k,q=this,l={next:function(){return a(void 0)},"throw":function(b){return a(b)},"return":function(){throw Error("Not yet implemented");}};t();l[Symbol.iterator]=function(){return this};return l};
f.entries=function(){function a(a){for(;;)switch(b){case 0:x=z.get(K);m=[];l=x;for(g in l)m.push(g);r=0;case 1:if(!(r<m.length)){b=3;break}g=m[r];if(g in l){b=4;break}b=2;break;case 4:e=w(x[g]),c=e.next();case 5:if(c.done){b=7;break}d=c.value;b=8;return{value:[g,A(d)],done:!1};case 8:if(void 0===a){b=9;break}b=-1;throw a;case 9:case 6:c=e.next();b=5;break;case 7:case 2:r++;b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,g,l,r,m,x,K=this,B={next:function(){return a(void 0)},
"throw":function(b){return a(b)},"return":function(){throw Error("Not yet implemented");}};t();B[Symbol.iterator]=function(){return this};return B};f.forEach=function(a,b){for(var d=w(this),c=d.next();!c.done;c=d.next()){var e=w(c.value),c=e.next().value,e=e.next().value;a.call(b,e,c,this)}};f.get=function(a){var b=z.get(this);return b[a]?A(b[a][0]):null};f.getAll=function(a){return(z.get(this)[a]||[]).map(A)};f.has=function(a){return a in z.get(this)};
f.keys=function(){function a(a){for(;;)switch(b){case 0:l=w(r),g=l.next();case 1:if(g.done){b=3;break}e=g.value;c=w(e);d=c.next().value;b=4;return{value:d,done:!1};case 4:if(void 0===a){b=5;break}b=-1;throw a;case 5:case 2:g=l.next();b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,g,l,r=this,m={next:function(){return a(void 0)},"throw":function(b){return a(b)},"return":function(){throw Error("Not yet implemented");}};t();m[Symbol.iterator]=function(){return this};return m};
f.set=function(a,b,d){z.get(this)[a]=[[b,d]]};
f.values=function(){function a(a){for(;;)switch(b){case 0:k=w(q),g=k.next();case 1:if(g.done){b=3;break}e=g.value;c=w(e);c.next();d=c.next().value;b=4;return{value:d,done:!1};case 4:if(void 0===a){b=5;break}b=-1;throw a;case 5:case 2:g=k.next();b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,g,k,q=this,l={next:function(){return a(void 0)},"throw":function(b){return a(b)},"return":function(){throw Error("Not yet implemented");}};t();l[Symbol.iterator]=function(){return this};
return l};f.stream=function(){try{return this._blob().stream()}catch(a){throw Error("Include https://github.com/jimmywarting/Screw-FileReader for streaming support");}};F.prototype._asNative=function(){for(var a=new FormData,b=w(this),d=b.next();!d.done;d=b.next()){var c=w(d.value),d=c.next().value,c=c.next().value;a.append(d,c)}return a};
F.prototype._blob=function(){for(var a="----formdata-polyfill-"+Math.random(),b=[],d=w(this),c=d.next();!c.done;c=d.next()){var e=w(c.value),c=e.next().value,e=e.next().value;b.push("--"+a+"\r\n");e instanceof Blob?b.push('Content-Disposition: form-data; name="'+c+'"; filename="'+e.name+'"\r\n',"Content-Type: "+e.type+"\r\n\r\n",e,"\r\n"):b.push('Content-Disposition: form-data; name="'+c+'"\r\n\r\n'+e+"\r\n")}b.push("--"+a+"--");return new Blob(b,{type:"multipart/form-data; boundary="+a})};n();t();
F.prototype[Symbol.iterator]=function(){return this.entries()};F.prototype.toString=function(){return"[object FormData]"};n();F.prototype[Symbol.toStringTag]="FormData";
for(var G={},H=w([["append",E],["delete",D],["get",D],["getAll",D],["has",D],["set",E]]),I=H.next();!I.done;G={a:G.a,b:G.b},I=H.next()){var J=w(I.value),K=J.next().value;G.b=J.next().value;G.a=F.prototype[K];F.prototype[K]=function(a){return function(){return a.a.apply(this,a.b.apply(null,[].concat(arguments instanceof Array?arguments:x(w(arguments)))))}}(G)}module.exports=F;
f.values=function(){function a(a){for(;;)switch(b){case 0:l=w(r),g=l.next();case 1:if(g.done){b=3;break}e=g.value;c=w(e);c.next();d=c.next().value;b=4;return{value:d,done:!1};case 4:if(void 0===a){b=5;break}b=-1;throw a;case 5:case 2:g=l.next();b=1;break;case 3:b=-1;default:return{value:void 0,done:!0}}}var b=0,d,c,e,g,l,r=this,m={next:function(){return a(void 0)},"throw":function(b){return a(b)},"return":function(){throw Error("Not yet implemented");}};t();m[Symbol.iterator]=function(){return this};
return m};f.stream=function(){try{return this._blob().stream()}catch(a){throw Error("Include https://github.com/jimmywarting/Screw-FileReader for streaming support");}};E.prototype._asNative=function(){for(var a=new FormData,b=w(this),d=b.next();!d.done;d=b.next()){var c=w(d.value),d=c.next().value,c=c.next().value;a.append(d,c)}return a};
E.prototype._blob=function(){for(var a="----formdata-polyfill-"+Math.random(),b=[],d=w(this),c=d.next();!c.done;c=d.next()){var e=w(c.value),c=e.next().value,e=e.next().value;b.push("--"+a+"\r\n");e instanceof Blob?b.push('Content-Disposition: form-data; name="'+c+'"; filename="'+e.name+'"\r\n',"Content-Type: "+e.type+"\r\n\r\n",e,"\r\n"):b.push('Content-Disposition: form-data; name="'+c+'"\r\n\r\n'+e+"\r\n")}b.push("--"+a+"--");return new Blob(b,{type:"multipart/form-data; boundary="+a})};n();t();
E.prototype[Symbol.iterator]=function(){return this.entries()};E.prototype.toString=function(){return"[object FormData]"};n();window.Symbol&&Symbol.toStringTag&&(n(),E.prototype[Symbol.toStringTag]="FormData");
for(var F={},G=w([["append",D],["delete",C],["get",C],["getAll",C],["has",C],["set",D]]),H=G.next();!H.done;F={a:F.a,b:F.b},H=G.next()){var I=w(H.value),J=I.next().value;F.b=I.next().value;F.a=E.prototype[J];E.prototype[J]=function(a){return function(){return a.a.apply(this,a.b.apply(null,[].concat(arguments instanceof Array?arguments:y(w(arguments)))))}}(F)}module.exports=E;
{
"name": "formdata-polyfill",
"version": "2.0.1",
"version": "2.0.2",
"description": "HTML5 `FormData` polyfill for Browsers.",

@@ -5,0 +5,0 @@ "main": "formdata.min.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