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

maltypart

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maltypart - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

2

dist/maltypart.js

@@ -219,3 +219,3 @@ /** Maltypart is a simple multipart builder.

file.name,
headers
headers || file.headers
), replace!==false);

@@ -222,0 +222,0 @@ if (typeof callback==='function') {

@@ -1,2 +0,2 @@

/*! maltypart 1.4.0 */
!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof module&&module.exports?module.exports=b():a.maltypart=b()}(this,function(){function a(a,b,c){this.fields={},"function"==typeof b&&(c=b,b=null),a&&this.append(a,c),this.setBoundary(b)}function b(a,b,c,d){this.data=a,this.contentType=b,this.filename=c,this.headers=d}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(){return Math.random().toString(36).substring(2)+(++f).toString(36)}function e(a){for(var b="",c=new Uint8Array(a),d=0;d<c.byteLength;d++)b+=String.fromCharCode(c[d]);return b}var f=0;return a.prototype={constructor:a,availableTypes:["multipart","form-encoded"],setType:function(a){return this.typeOverride=-1!==this.availableTypes.indexOf(a)?a:null,this},getType:function(){var a=this.typeOverride;if(-1!==this.availableTypes.indexOf(a))return a;for(var b in this.fields)if(this.fields.hasOwnProperty(b)&&this.fields[b].contentType)return"multipart";return"form-encoded"},append:function(a,b,d){var e,f,g,h,i;if("string"==typeof a&&arguments.length>=2)return this.setField.apply(this,arguments);if("function"==typeof b&&(g=d,d=b,b=g),"function"==typeof d&&(h=1,i=function(){--h||d()}),c(a))for(g=0;g<a.length;g++)f=a[g],h++,this.setField(f.name,f.value,b!==!1,null,i);else for(e in a)if(a.hasOwnProperty(e))if(f=a[e],c(f))for(g=0;g<f.length;g++)h++,this.setField(e,f[g],b===!0,null,i);else h++,this.setField(e,f,b!==!1,null,i);return h&&i(),this},setField:function(a,d,e,f,g){var h=this.fields;return a+="",window.File&&d instanceof window.File||window.Blob&&d instanceof window.Blob?this.setFileField.apply(this,arguments):("function"==typeof e&&(g=e,e=!0),d&&d.nodeType&&d.nodeName&&d.getAttribute?d=d.value:c(d)||d&&(d instanceof b||d.contentType&&d.data)||(d+=""),a.match(/\[\]$/g)&&(e=!1),e===!1&&h.hasOwnProperty(a)?(c(h[a])||(h[a]=[h[a]]),h[a].push(d)):h[a]=d,"function"==typeof g&&g(),this)},setFileField:function(a,c,d,f,g){var h=this,i=new FileReader;return"function"==typeof d&&(g=d,d=!0),i.onloadend=function(){h.setField(a,new b(e(i.result),c.type,c.name,f),d!==!1),"function"==typeof g&&g(),c=g=h=i=null},i.readAsArrayBuffer(c),this},setBoundary:function(a){return this.boundary=(a||d())+"",this},toString:function(a){var b,d,e,f,g,h,i,j,k,l=this.getType(),m="";this.boundary||this.setBoundary(),a&&this.append(a);for(d in this.fields)if(this.fields.hasOwnProperty(d))for(e=this.fields[d],b=c(e)?e:[e],i=0;i<b.length;i++){if(h=b[i],"multipart"===l){if(j=h.headers,f=null,h.contentType&&(f=h.contentType,h=h.data),g="--"+this.boundary+'\r\nContent-Disposition: form-data; name="'+d+'"',b[i].filename&&(g+='; filename="'+b[i].filename+'"'),g+="\r\n",f&&(g+="Content-type: "+f+"\r\n"),j)for(k in j)j.hasOwnProperty(k)&&(g+=k+": "+j[k]+"\r\n");g+="\r\n"+h+"\r\n"}else"form-encoded"===l&&(g=encodeURIComponent(d)+"="+encodeURIComponent(h)+"&");m+=g}return"multipart"===l?m+="--"+this.boundary+"--\r\n":"form-encoded"===l&&(m=m.substring(0,m.length-1)),m},getData:function(){var a,b,c=this.toString();if("multipart"===this.getType()){a=c.length,b=new Uint8Array(a);for(var d=0;a>d;d++)b[d]=255&c.charCodeAt(d);return b}return c},getContentType:function(a){var b=this.getType();return"multipart"===b?"multipart/form-data; "+(a?"charset=utf-8; ":"")+"boundary="+this.boundary:"application/x-www-form-encoded"}},{RequestBody:a,RequestField:b}});
/*! maltypart 1.5.0 */
!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof module&&module.exports?module.exports=b():a.maltypart=b()}(this,function(){function a(a,b,c){this.fields={},"function"==typeof b&&(c=b,b=null),a&&this.append(a,c),this.setBoundary(b)}function b(a,b,c,d){this.data=a,this.contentType=b,this.filename=c,this.headers=d}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(){return Math.random().toString(36).substring(2)+(++f).toString(36)}function e(a){for(var b="",c=new Uint8Array(a),d=0;d<c.byteLength;d++)b+=String.fromCharCode(c[d]);return b}var f=0;return a.prototype={constructor:a,availableTypes:["multipart","form-encoded"],setType:function(a){return this.typeOverride=-1!==this.availableTypes.indexOf(a)?a:null,this},getType:function(){var a=this.typeOverride;if(-1!==this.availableTypes.indexOf(a))return a;for(var b in this.fields)if(this.fields.hasOwnProperty(b)&&this.fields[b].contentType)return"multipart";return"form-encoded"},append:function(a,b,d){var e,f,g,h,i;if("string"==typeof a&&arguments.length>=2)return this.setField.apply(this,arguments);if("function"==typeof b&&(g=d,d=b,b=g),"function"==typeof d&&(h=1,i=function(){--h||d()}),c(a))for(g=0;g<a.length;g++)f=a[g],h++,this.setField(f.name,f.value,b!==!1,null,i);else for(e in a)if(a.hasOwnProperty(e))if(f=a[e],c(f))for(g=0;g<f.length;g++)h++,this.setField(e,f[g],b===!0,null,i);else h++,this.setField(e,f,b!==!1,null,i);return h&&i(),this},setField:function(a,d,e,f,g){var h=this.fields;return a+="",window.File&&d instanceof window.File||window.Blob&&d instanceof window.Blob?this.setFileField.apply(this,arguments):("function"==typeof e&&(g=e,e=!0),d&&d.nodeType&&d.nodeName&&d.getAttribute?d=d.value:c(d)||d&&(d instanceof b||d.contentType&&d.data)||(d+=""),a.match(/\[\]$/g)&&(e=!1),e===!1&&h.hasOwnProperty(a)?(c(h[a])||(h[a]=[h[a]]),h[a].push(d)):h[a]=d,"function"==typeof g&&g(),this)},setFileField:function(a,c,d,f,g){var h=this,i=new FileReader;return"function"==typeof d&&(g=d,d=!0),i.onloadend=function(){h.setField(a,new b(e(i.result),c.type,c.name,f||c.headers),d!==!1),"function"==typeof g&&g(),c=g=h=i=null},i.readAsArrayBuffer(c),this},setBoundary:function(a){return this.boundary=(a||d())+"",this},toString:function(a){var b,d,e,f,g,h,i,j,k,l=this.getType(),m="";this.boundary||this.setBoundary(),a&&this.append(a);for(d in this.fields)if(this.fields.hasOwnProperty(d))for(e=this.fields[d],b=c(e)?e:[e],i=0;i<b.length;i++){if(h=b[i],"multipart"===l){if(j=h.headers,f=null,h.contentType&&(f=h.contentType,h=h.data),g="--"+this.boundary+'\r\nContent-Disposition: form-data; name="'+d+'"',b[i].filename&&(g+='; filename="'+b[i].filename+'"'),g+="\r\n",f&&(g+="Content-type: "+f+"\r\n"),j)for(k in j)j.hasOwnProperty(k)&&(g+=k+": "+j[k]+"\r\n");g+="\r\n"+h+"\r\n"}else"form-encoded"===l&&(g=encodeURIComponent(d)+"="+encodeURIComponent(h)+"&");m+=g}return"multipart"===l?m+="--"+this.boundary+"--\r\n":"form-encoded"===l&&(m=m.substring(0,m.length-1)),m},getData:function(){var a,b,c=this.toString();if("multipart"===this.getType()){a=c.length,b=new Uint8Array(a);for(var d=0;a>d;d++)b[d]=255&c.charCodeAt(d);return b}return c},getContentType:function(a){var b=this.getType();return"multipart"===b?"multipart/form-data; "+(a?"charset=utf-8; ":"")+"boundary="+this.boundary:"application/x-www-form-encoded"}},{RequestBody:a,RequestField:b}});
{
"name": "maltypart",
"version": "1.4.0",
"version": "1.5.0",
"description": "Maltypart is a simple multipart request builder.",

@@ -5,0 +5,0 @@ "main": "dist/maltypart.js",

@@ -219,3 +219,3 @@ /** Maltypart is a simple multipart builder.

file.name,
headers
headers || file.headers
), replace!==false);

@@ -222,0 +222,0 @@ if (typeof callback==='function') {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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