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

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 3.0.1 to 3.0.2

build.js

16

FormData.js

@@ -133,3 +133,3 @@ // ==ClosureCompiler==

for (let opt of arrayFrom(elm.selectedOptions))
this.append(opt.name, opt.value)
this.append(elm.name, opt.value)
else if (elm.type === 'checkbox' || elm.type === 'radio') {

@@ -348,3 +348,3 @@ if (elm.checked) this.append(elm.name, elm.value)

for (let [method, decorator] of [
const decorations = [
['append', normalizeArgs],

@@ -356,8 +356,10 @@ ['delete', stringify],

['set', normalizeArgs]
]) {
let orig = FormDataPolyfill.prototype[method]
FormDataPolyfill.prototype[method] = function() {
return orig.apply(this, decorator(...arguments))
]
decorations.forEach(arr => {
const orig = FormDataPolyfill.prototype[arr[0]]
FormDataPolyfill.prototype[arr[0]] = function() {
return orig.apply(this, arr[1](arrayFrom(arguments)))
}
}
})

@@ -364,0 +366,0 @@ // Patch xhr's send method to call _blob transparently

@@ -1,16 +0,13 @@

var g,l="function"==typeof Object.defineProperties?Object.defineProperty:function(b,a,c){b!=Array.prototype&&b!=Object.prototype&&(b[a]=c.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 p=function(){var b=0;return function(a){return"jscomp_symbol_"+(a||"")+b++}}();
function r(){n();var b=m.Symbol.iterator;b||(b=m.Symbol.iterator=m.Symbol("iterator"));"function"!=typeof Array.prototype[b]&&l(Array.prototype,b,{configurable:!0,writable:!0,value:function(){return t(this)}});r=function(){}}function t(b){var a=0;return v(function(){return a<b.length?{done:!1,value:b[a++]}:{done:!0}})}function v(b){r();b={next:b};b[m.Symbol.iterator]=function(){return this};return b}function w(b){r();n();r();var a=b[Symbol.iterator];return a?a.call(b):t(b)}
function x(b){for(var a,c=[];!(a=b.next()).done;)c.push(a.value);return c}function z(b,a){return Object.prototype.hasOwnProperty.call(b,a)}function A(b,a){if(a){var c=m;b=b.split(".");for(var d=0;d<b.length-1;d++){var e=b[d];e in c||(c[e]={});c=c[e]}b=b[b.length-1];d=c[b];a=a(d);a!=d&&null!=a&&l(c,b,{configurable:!0,writable:!0,value:a})}}
A("WeakMap",function(b){function a(a){this.a=(f+=Math.random()+1).toString();if(a){n();r();a=w(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}}function c(a){z(a,e)||l(a,e,{value:{}})}function d(a){var b=Object[a];b&&(Object[a]=function(a){c(a);return b(a)})}if(function(){if(!b||!Object.seal)return!1;try{var a=Object.seal({}),c=Object.seal({}),d=new b([[a,2],[c,3]]);if(2!=d.get(a)||3!=d.get(c))return!1;d.delete(a);d.set(c,4);return!d.has(a)&&4==d.get(c)}catch(y){return!1}}())return b;
var e="$jscomp_hidden_"+Math.random().toString().substring(2);d("freeze");d("preventExtensions");d("seal");var f=0;a.prototype.set=function(a,b){c(a);if(!z(a,e))throw Error("WeakMap key fail: "+a);a[e][this.a]=b;return this};a.prototype.get=function(a){return z(a,e)?a[e][this.a]:void 0};a.prototype.has=function(a){return z(a,e)&&z(a[e],this.a)};a.prototype.delete=function(a){return z(a,e)&&z(a[e],this.a)?delete a[e][this.a]:!1};return a});
A("Array.from",function(b){return b?b:function(a,b,d){r();b=null!=b?b:function(a){return a};var c=[],f=a[Symbol.iterator];if("function"==typeof f)for(a=f.call(a);!(f=a.next()).done;)c.push(b.call(d,f.value));else{f=a.length;for(var h=0;h<f;h++)c.push(b.call(d,a[h]))}return c}});
if(!window.FormData||!window.FormData.prototype.keys){var B=function(b,a,c){if(2>arguments.length)throw new TypeError("2 arguments required, but only "+arguments.length+" present.");return a instanceof Blob?[b+"",a,void 0!==c?c+"":"File"===Object.prototype.toString.call(a).slice(8,-1)?a.name:"Blob"]:[b+"",a+""]},C=function(b){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");return[b+""]},D=function(b){var a=w(b);b=a.next().value;a=a.next().value;b instanceof Blob&&
(b=new File([b],a,{type:b.type,lastModified:b.lastModified}));return b},E=window.FormData,F=window.XMLHttpRequest.prototype.send,G=window.Request&&window.fetch;n();var H=window.Symbol&&Symbol.toStringTag,I=new WeakMap,J=Array.from||function(b){return[].slice.call(b)};H&&(Blob.prototype[H]||(Blob.prototype[H]="Blob"),"File"in window&&!File.prototype[H]&&(File.prototype[H]="File"));try{new File([],"")}catch(b){window.File=function(a,c,d){a=new Blob(a,d);d=d&&void 0!==d.lastModified?new Date(d.lastModified):
new Date;Object.defineProperties(a,{name:{value:c},lastModifiedDate:{value:d},lastModified:{value:+d},toString:{value:function(){return"[object File]"}}});H&&Object.defineProperty(a,H,{value:"File"});return a}}var K=function(b){I.set(this,Object.create(null));if(!b)return this;b=w(J(b.elements));for(var a=b.next();!a.done;a=b.next())if(a=a.value,a.name&&!a.disabled)if("file"===a.type)for(var c=w(a.files),d=c.next();!d.done;d=c.next())this.b(a.name,d.value);else if("select-multiple"===a.type||"select-one"===
a.type)for(a=w(J(a.selectedOptions)),c=a.next();!c.done;c=a.next())c=c.value,this.b(c.name,c.value);else"checkbox"===a.type||"radio"===a.type?a.checked&&this.b(a.name,a.value):this.b(a.name,a.value)};g=K.prototype;g.b=function(b,a){var c=I.get(this);c[b]||(c[b]=[]);c[b].push([a,void 0])};g.entries=function(){function b(b,u,Q){for(;;)switch(a){case 0:y=I.get(R);k=[];h=y;for(f in h)k.push(f);q=0;case 1:if(!(q<k.length)){a=3;break}f=k[q];if(f in h){a=4;break}a=2;break;case 4:e=w(y[f]),d=e.next();case 5:if(d.done){a=
7;break}c=d.value;a=8;return{value:[f,D(c)],done:!1};case 8:if(1!=b){a=9;break}a=-1;throw Q;case 9:case 6:d=e.next();a=5;break;case 7:case 2:q++;a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,c,d,e,f,h,q,k,y,R=this,u={next:function(a){return b(0,a,void 0)},throw:function(a){return b(1,void 0,a)},return:function(){throw Error("Not yet implemented");}};r();u[Symbol.iterator]=function(){return this};return u};g.get=function(b){var a=I.get(this);return a[b]?D(a[b][0]):null};g.has=
function(b){return b in I.get(this)};g.keys=function(){function b(b,k,u){for(;;)switch(a){case 0:h=w(q),f=h.next();case 1:if(f.done){a=3;break}e=f.value;d=w(e);c=d.next().value;a=4;return{value:c,done:!1};case 4:if(1!=b){a=5;break}a=-1;throw u;case 5:case 2:f=h.next();a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,c,d,e,f,h,q=this,k={next:function(a){return b(0,a,void 0)},throw:function(a){return b(1,void 0,a)},return:function(){throw Error("Not yet implemented");}};r();k[Symbol.iterator]=
function(){return this};return k};g.set=function(b,a,c){I.get(this)[b]=[[a,c]]};g.values=function(){function b(b,k,u){for(;;)switch(a){case 0:h=w(q),f=h.next();case 1:if(f.done){a=3;break}e=f.value;d=w(e);d.next();c=d.next().value;a=4;return{value:c,done:!1};case 4:if(1!=b){a=5;break}a=-1;throw u;case 5:case 2:f=h.next();a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,c,d,e,f,h,q=this,k={next:function(a){return b(0,a,void 0)},throw:function(a){return b(1,void 0,a)},return:function(){throw Error("Not yet implemented");
}};r();k[Symbol.iterator]=function(){return this};return k};K.prototype._asNative=function(){for(var b=new E,a=w(this),c=a.next();!c.done;c=a.next()){var d=w(c.value);c=d.next().value;d=d.next().value;b.append(c,d)}return b};K.prototype._blob=function(){for(var b="----formdata-polyfill-"+Math.random(),a=[],c=w(this),d=c.next();!d.done;d=c.next()){var e=w(d.value);d=e.next().value;e=e.next().value;a.push("--"+b+"\r\n");e instanceof Blob?a.push('Content-Disposition: form-data; name="'+d+'"; filename="'+
e.name+'"\r\n',"Content-Type: "+(e.type||"application/octet-stream")+"\r\n\r\n",e,"\r\n"):a.push('Content-Disposition: form-data; name="'+d+'"\r\n\r\n'+e+"\r\n")}a.push("--"+b+"--");return new Blob(a,{type:"multipart/form-data; boundary="+b})};n();r();K.prototype[Symbol.iterator]=function(){return this.entries()};K.prototype.toString=function(){return"[object FormData]"};H&&(K.prototype[H]="FormData");for(var L={},M=w([["append",B],["delete",C],["get",C],["getAll",C],["has",C],["set",B]]),N=M.next();!N.done;L=
{f:L.f,c:L.c},N=M.next()){var O=w(N.value),P=O.next().value;L.c=O.next().value;L.f=K.prototype[P];K.prototype[P]=function(b){return function(){return b.f.apply(this,b.c.apply(null,[].concat(arguments instanceof Array?arguments:x(w(arguments)))))}}(L)}XMLHttpRequest.prototype.send=function(b){F.call(this,b instanceof K?b._blob():b)};if(G){var S=window.fetch;window.fetch=function(b,a){a&&a.body&&a.body instanceof K&&(a.body=a.body._blob());return S(b,a)}}window.FormData=K};
var g,k="function"==typeof Object.defineProperties?Object.defineProperty:function(b,a,d){b!=Array.prototype&&b!=Object.prototype&&(b[a]=d.value)},l="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function n(){n=function(){};l.Symbol||(l.Symbol=p)}var p=function(){var b=0;return function(a){return"jscomp_symbol_"+(a||"")+b++}}();
function q(){n();var b=l.Symbol.iterator;b||(b=l.Symbol.iterator=l.Symbol("iterator"));"function"!=typeof Array.prototype[b]&&k(Array.prototype,b,{configurable:!0,writable:!0,value:function(){return u(this)}});q=function(){}}function u(b){var a=0;return v(function(){return a<b.length?{done:!1,value:b[a++]}:{done:!0}})}function v(b){q();b={next:b};b[l.Symbol.iterator]=function(){return this};return b}function w(b){q();n();q();var a=b[Symbol.iterator];return a?a.call(b):u(b)}
if(!window.FormData||!window.FormData.prototype.keys){var x=function(b,a,d){if(2>arguments.length)throw new TypeError("2 arguments required, but only "+arguments.length+" present.");return a instanceof Blob?[b+"",a,void 0!==d?d+"":"File"===Object.prototype.toString.call(a).slice(8,-1)?a.name:"Blob"]:[b+"",a+""]},y=function(b){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");return[b+""]},A=function(b){var a=w(b);b=a.next().value;a=a.next().value;b instanceof Blob&&
(b=new File([b],a,{type:b.type,lastModified:b.lastModified}));return b},B=window.FormData,C=window.XMLHttpRequest.prototype.send,D=window.Request&&window.fetch;n();var E=window.Symbol&&Symbol.toStringTag,F=new WeakMap,G=Array.from||function(b){return[].slice.call(b)};E&&(Blob.prototype[E]||(Blob.prototype[E]="Blob"),"File"in window&&!File.prototype[E]&&(File.prototype[E]="File"));try{new File([],"")}catch(b){window.File=function(a,d,c){a=new Blob(a,c);c=c&&void 0!==c.lastModified?new Date(c.lastModified):
new Date;Object.defineProperties(a,{name:{value:d},lastModifiedDate:{value:c},lastModified:{value:+c},toString:{value:function(){return"[object File]"}}});E&&Object.defineProperty(a,E,{value:"File"});return a}}var H=function(b){F.set(this,Object.create(null));if(!b)return this;b=w(G(b.elements));for(var a=b.next();!a.done;a=b.next())if(a=a.value,a.name&&!a.disabled)if("file"===a.type)for(var d=w(a.files),c=d.next();!c.done;c=d.next())this.append(a.name,c.value);else if("select-multiple"===a.type||
"select-one"===a.type)for(d=w(G(a.selectedOptions)),c=d.next();!c.done;c=d.next())this.append(a.name,c.value.value);else"checkbox"===a.type||"radio"===a.type?a.checked&&this.append(a.name,a.value):this.append(a.name,a.value)};g=H.prototype;g.append=function(b,a,d){var c=F.get(this);c[b]||(c[b]=[]);c[b].push([a,d])};g["delete"]=function(b){delete F.get(this)[b]};g.entries=function(){function b(b,t,I){for(;;)switch(a){case 0:z=F.get(J);h=[];m=z;for(f in m)h.push(f);r=0;case 1:if(!(r<h.length)){a=3;
break}f=h[r];if(f in m){a=4;break}a=2;break;case 4:e=w(z[f]),c=e.next();case 5:if(c.done){a=7;break}d=c.value;a=8;return{value:[f,A(d)],done:!1};case 8:if(1!=b){a=9;break}a=-1;throw I;case 9:case 6:c=e.next();a=5;break;case 7:case 2:r++;a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,d,c,e,f,m,r,h,z,J=this,t={next:function(a){return b(0,a,void 0)},"throw":function(a){return b(1,void 0,a)},"return":function(){throw Error("Not yet implemented");}};q();t[Symbol.iterator]=function(){return this};
return t};g.forEach=function(b,a){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;b.call(a,e,c,this)}};g.get=function(b){var a=F.get(this);return a[b]?A(a[b][0]):null};g.getAll=function(b){return(F.get(this)[b]||[]).map(A)};g.has=function(b){return b in F.get(this)};g.keys=function(){function b(b,h,t){for(;;)switch(a){case 0:m=w(r),f=m.next();case 1:if(f.done){a=3;break}e=f.value;c=w(e);d=c.next().value;a=4;return{value:d,done:!1};case 4:if(1!=b){a=
5;break}a=-1;throw t;case 5:case 2:f=m.next();a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,d,c,e,f,m,r=this,h={next:function(a){return b(0,a,void 0)},"throw":function(a){return b(1,void 0,a)},"return":function(){throw Error("Not yet implemented");}};q();h[Symbol.iterator]=function(){return this};return h};g.set=function(b,a,d){F.get(this)[b]=[[a,d]]};g.values=function(){function b(b,h,t){for(;;)switch(a){case 0:m=w(r),f=m.next();case 1:if(f.done){a=3;break}e=f.value;c=w(e);
c.next();d=c.next().value;a=4;return{value:d,done:!1};case 4:if(1!=b){a=5;break}a=-1;throw t;case 5:case 2:f=m.next();a=1;break;case 3:a=-1;default:return{value:void 0,done:!0}}}var a=0,d,c,e,f,m,r=this,h={next:function(a){return b(0,a,void 0)},"throw":function(a){return b(1,void 0,a)},"return":function(){throw Error("Not yet implemented");}};q();h[Symbol.iterator]=function(){return this};return h};H.prototype._asNative=function(){for(var b=new B,a=w(this),d=a.next();!d.done;d=a.next()){var c=w(d.value);
d=c.next().value;c=c.next().value;b.append(d,c)}return b};H.prototype._blob=function(){for(var b="----formdata-polyfill-"+Math.random(),a=[],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.push("--"+b+"\r\n");e instanceof Blob?a.push('Content-Disposition: form-data; name="'+c+'"; filename="'+e.name+'"\r\n',"Content-Type: "+(e.type||"application/octet-stream")+"\r\n\r\n",e,"\r\n"):a.push('Content-Disposition: form-data; name="'+c+'"\r\n\r\n'+e+"\r\n")}a.push("--"+
b+"--");return new Blob(a,{type:"multipart/form-data; boundary="+b})};n();q();H.prototype[Symbol.iterator]=function(){return this.entries()};H.prototype.toString=function(){return"[object FormData]"};E&&(H.prototype[E]="FormData");[["append",x],["delete",y],["get",y],["getAll",y],["has",y],["set",x]].forEach(function(b){var a=H.prototype[b[0]];H.prototype[b[0]]=function(){return a.apply(this,b[1](G(arguments)))}});XMLHttpRequest.prototype.send=function(b){C.call(this,b instanceof H?b._blob():b)};
if(D){var K=window.fetch;window.fetch=function(b,a){a&&a.body&&a.body instanceof H&&(a.body=a.body._blob());return K(b,a)}}window.FormData=H};
{
"name": "formdata-polyfill",
"version": "3.0.1",
"version": "3.0.2",
"description": "HTML5 `FormData` polyfill for Browsers.",
"main": "formdata.min.js",
"scripts": {
"build": "google-closure-compiler --compilation_level ADVANCED --js_output_file formdata.min.js FormData.js",
"build": "node build",
"prepare": "npm run build",

@@ -26,6 +26,3 @@ "test": "echo \"Error: no test\" && exit 1"

},
"homepage": "https://github.com/jimmywarting/FormData#readme",
"devDependencies": {
"google-closure-compiler": "^20171112.0.0"
}
"homepage": "https://github.com/jimmywarting/FormData#readme"
}
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