Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "maltypart", | ||
"description": "Maltypart is a simple multipart request builder.", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"authors": [ | ||
"Jason Miller <jasonmiller@synacor.com>" | ||
], | ||
"main": "maltypart.js", | ||
"main": "dist/maltypart.js", | ||
"moduleType": [ | ||
@@ -10,0 +10,0 @@ "amd", |
@@ -1,2 +0,2 @@ | ||
/*! maltypart 1.2.2 */ | ||
/*! maltypart 1.2.3 */ | ||
!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){this.fields={},a&&this.append(a),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){var d,e;if("string"==typeof a&&arguments.length>=2)this.setField.apply(this,arguments);else if(c(a))for(e=0;e<a.length;e++)this.setField(a[e].name,a[e].value,b);else for(d in a)a.hasOwnProperty(d)&&this.setField(d,a[d],b);return this},setField:function(a,d,e){var f=this.fields;return a+="",window.File&&d instanceof window.File||window.Blob&&d instanceof window.Blob?this.setFileField.apply(this,arguments):(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&&f.hasOwnProperty(a)?(c(f[a])||(f[a]=[f[a]]),f[a].push(d)):f[a]=d,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}}); |
{ | ||
"name": "maltypart", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Maltypart is a simple multipart request builder.", | ||
"main": "maltypart.js", | ||
"main": "dist/maltypart.js", | ||
"scripts": { | ||
@@ -7,0 +7,0 @@ "build": "grunt", |
Maltypart [![NPM Version](http://img.shields.io/npm/v/maltypart.svg?style=flat)](https://www.npmjs.org/package/maltypart) [![Bower Version](http://img.shields.io/bower/v/maltypart.svg?style=flat)](http://bower.io/search/?q=maltypart) | ||
========= | ||
[![Join the chat at https://gitter.im/synacorinc/maltypart](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/synacorinc/maltypart?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
![Maltypart](logo.png) | ||
@@ -5,0 +7,0 @@ |
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
697912
159