Comparing version 0.1.11 to 0.2.0
123
index.js
@@ -30,3 +30,3 @@ /** | ||
* Initialize our Rest Container | ||
* | ||
* | ||
* @type {Object} | ||
@@ -39,3 +39,3 @@ */ | ||
* Container to hold headers with lowercased field-names. | ||
* | ||
* | ||
* @type {Object} | ||
@@ -48,3 +48,3 @@ * @private | ||
* Container to hold multipart form data for processing upon request. | ||
* | ||
* | ||
* @type {Array} | ||
@@ -57,3 +57,3 @@ * @private | ||
* Container to hold form data for processing upon request. | ||
* | ||
* | ||
* @type {Array} | ||
@@ -66,3 +66,3 @@ * @private | ||
* Request option container for details about the request. | ||
* | ||
* | ||
* @type {Object} | ||
@@ -73,3 +73,3 @@ */ | ||
* Url obtained from request method arguments. | ||
* | ||
* | ||
* @type {String} | ||
@@ -81,3 +81,3 @@ */ | ||
* Method obtained from request method arguments. | ||
* | ||
* | ||
* @type {String} | ||
@@ -89,3 +89,3 @@ */ | ||
* List of headers with case-sensitive fields. | ||
* | ||
* | ||
* @type {Object} | ||
@@ -100,4 +100,4 @@ */ | ||
* Behaves much like form fields in HTML. | ||
* | ||
* @param {String} name | ||
* | ||
* @param {String} name | ||
* @param {String} value | ||
@@ -108,3 +108,3 @@ * @return {Object} | ||
if (is(name).a(Object)) { | ||
for (var key in name) | ||
for (var key in name) | ||
$this.attach(key, name[key]); | ||
@@ -124,3 +124,3 @@ } else { | ||
* Attaches a file to the multipart-form request. | ||
* | ||
* | ||
* @param {String} name | ||
@@ -132,3 +132,3 @@ * @param {String|Object} path | ||
if (is(name).a(Object)) { | ||
for (var key in name) | ||
for (var key in name) | ||
$this.attach(key, name[key]); | ||
@@ -151,3 +151,3 @@ } else { | ||
* Supports user, password to reflect SuperAgent | ||
* | ||
* | ||
* @param {String|Object} user | ||
@@ -170,3 +170,3 @@ * @param {String} password | ||
* Sets header field to value | ||
* | ||
* | ||
* @param {String} field Header field | ||
@@ -191,3 +191,3 @@ * @param {String} value Header field value | ||
* Append query string to request uri. | ||
* | ||
* | ||
* @param {String|Object} value | ||
@@ -206,3 +206,3 @@ * @return {Object} | ||
* Set _content-type_ header with type passed through `mime.lookup()` when necessary. | ||
* | ||
* | ||
* @param {String} type | ||
@@ -212,6 +212,6 @@ * @return {Object} | ||
type: function (type) { | ||
$this.header('Content-Type', does(type).contain('/') | ||
$this.header('Content-Type', does(type).contain('/') | ||
? type | ||
: mime.lookup(type)); | ||
return $this; | ||
return $this; | ||
}, | ||
@@ -222,8 +222,8 @@ | ||
* | ||
* Determines type whether `form` or `json`. | ||
* Determines type whether `form` or `json`. | ||
* For other types use `.type()` to set the _content-type_. | ||
* | ||
* If type is _application/x-www-form-urlencoded_ data will be appended to the | ||
* If type is _application/x-www-form-urlencoded_ data will be appended to the | ||
* previously set body data. | ||
* | ||
* | ||
* @param {Mixed} data | ||
@@ -289,3 +289,3 @@ * @return {Object} | ||
* }).end(function (response) {}); | ||
* | ||
* | ||
* @param {Object|String} options When an Object, headers should be placed directly on the object, | ||
@@ -296,3 +296,3 @@ * not under a child property. | ||
part: function (options) { | ||
if (!$this.options.multipart) | ||
if (!$this.options.multipart) | ||
$this.options.multipart = []; | ||
@@ -305,3 +305,3 @@ | ||
} else { | ||
if (is(options.body).a(Object)) | ||
if (is(options.body).a(Object)) | ||
options.body = Request.serializers.json(options.body); | ||
@@ -319,8 +319,8 @@ } | ||
}, | ||
/** | ||
* Finalize and send the request, after a response has been recieved do some additional post-processing | ||
* that request fails to do (this section mimics superagent style response). | ||
* | ||
* @param {Function} callback | ||
* | ||
* @param {Function} callback | ||
* @return {Object} | ||
@@ -421,3 +421,3 @@ */ | ||
// Response | ||
result.raw_body = body; | ||
@@ -427,3 +427,3 @@ result.headers = response.headers; | ||
// Handle Response Body | ||
if (body) { | ||
@@ -518,3 +518,3 @@ type = Unirest.type(result.headers['content-type'], true); | ||
* Alias for _.header_ | ||
* | ||
* | ||
* @type {Function} | ||
@@ -526,3 +526,3 @@ */ | ||
* Alias for _.end_ | ||
* | ||
* | ||
* @type {Function} | ||
@@ -535,6 +535,6 @@ */ | ||
* Aliases for _.end_ | ||
* | ||
* | ||
* @type {Object} | ||
*/ | ||
$this.as = { | ||
@@ -545,3 +545,3 @@ json: $this.end, | ||
}; | ||
// Iterates over a list of option methods to generate the chaining | ||
@@ -552,3 +552,3 @@ // style of use you see in Superagent and jQuery. | ||
var reference = null; | ||
if (option.indexOf(':') != -1) { | ||
@@ -559,3 +559,3 @@ option = option.split(':'); | ||
} | ||
(function (name, ref) { | ||
@@ -585,3 +585,3 @@ $this[name] = function (arg) { | ||
* Mime-type lookup / parser. | ||
* | ||
* | ||
* @param {String} type | ||
@@ -598,3 +598,3 @@ * @param {Boolean} parse Should we parse? | ||
* Parse header parameters. | ||
* | ||
* | ||
* @param {String} str | ||
@@ -616,3 +616,3 @@ * @return {Object} | ||
* Utility method to trim strings. | ||
* | ||
* | ||
* @type {String} | ||
@@ -626,3 +626,3 @@ */ | ||
* Parser methods for different data types. | ||
* | ||
* | ||
* @type {Object} | ||
@@ -657,3 +657,3 @@ */ | ||
* Serialization methods for different data types. | ||
* | ||
* | ||
* @type {Object} | ||
@@ -663,3 +663,3 @@ */ | ||
form: function (obj, parent) { | ||
if (!is(obj).a(Object) && !is(obj).a(Array)) | ||
if (!is(obj).a(Object) && !is(obj).a(Array)) | ||
return obj; | ||
@@ -685,3 +685,3 @@ | ||
* Unirest Request Utility Methods | ||
* | ||
* | ||
* @type {Object} | ||
@@ -706,3 +706,3 @@ */ | ||
* Unirest Response Utility Methods | ||
* | ||
* | ||
* @type {Object} | ||
@@ -723,3 +723,3 @@ */ | ||
, val; | ||
// Trailing CLRF | ||
@@ -750,10 +750,11 @@ lines.pop(); | ||
* Expose cookie store (tough-cookie) | ||
* | ||
* | ||
* @return {Function} Cookie Store | ||
*/ | ||
Unirest.jar = function (options) { | ||
options = options || {}; | ||
var jar = Unirest.request.jar(); | ||
// Because Requests aliases toughcookie rather than returning. | ||
if (options.store) { | ||
@@ -775,3 +776,3 @@ jar._jar.store = options.store; | ||
* Enum Structures | ||
* | ||
* | ||
* @type {Object} | ||
@@ -790,8 +791,8 @@ */ | ||
methods: [ | ||
methods: [ | ||
'GET', | ||
'HEAD', | ||
'PUT', | ||
'POST', | ||
'PATCH', | ||
'PUT', | ||
'POST', | ||
'PATCH', | ||
'DELETE', | ||
@@ -801,5 +802,5 @@ 'OPTIONS' | ||
options: [ | ||
'uri:url', 'redirects:maxRedirects', 'redirect:followRedirect', 'url', 'method', 'qs', 'form', 'json', 'multipart', | ||
'followRedirect', 'followAllRedirects', 'maxRedirects', 'encoding', 'pool', 'timeout', 'proxy', 'oauth', 'hawk', | ||
options: [ | ||
'uri:url', 'redirects:maxRedirects', 'redirect:followRedirect', 'url', 'method', 'qs', 'form', 'json', 'multipart', | ||
'followRedirect', 'followAllRedirects', 'maxRedirects', 'encoding', 'pool', 'timeout', 'proxy', 'oauth', 'hawk', | ||
'ssl:strictSSL', 'strictSSL', 'jar', 'cookies:jar', 'aws', 'httpSignature', 'localAddress', 'ip:localAddress', 'secureProtocol' | ||
@@ -822,3 +823,3 @@ ] | ||
* Simple Utility Methods for checking information about a value. | ||
* | ||
* | ||
* @param {Mixed} value Could be anything. | ||
@@ -828,3 +829,3 @@ * @return {Object} | ||
function is (value) { | ||
return { | ||
return { | ||
a: function (check) { | ||
@@ -840,3 +841,3 @@ if (check.prototype) check = check.prototype.constructor.name; | ||
* Simple Utility Methods for checking information about a value. | ||
* | ||
* | ||
* @param {Mixed} value Could be anything. | ||
@@ -846,4 +847,4 @@ * @return {Object} | ||
function does (value) { | ||
var arrayIndexOf = (Array.indexOf ? function (arr, obj, from) { | ||
return arr.indexOf(obj, from); | ||
var arrayIndexOf = (Array.indexOf ? function (arr, obj, from) { | ||
return arr.indexOf(obj, from); | ||
} : function (arr, obj, from) { | ||
@@ -850,0 +851,0 @@ var l = arr.length, i = from ? parseInt((1*from) + (from<0 ? l:0), 10) : 0; i = i<0 ? 0 : i; |
{ | ||
"name": "unirest", | ||
"version": "0.1.11", | ||
"version": "0.2.0", | ||
"description": "Lightweight HTTP Request library.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
797
47397