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

http-client

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-client - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

42

CHANGES.md

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

## [4.0.0-0]
## [v4.0.1]
- Renamed `handleResponse` to `onResponse`
- Fixed logic error with response handlers
[v4.0.1]: https://github.com/mjackson/http-client/compare/v4.0.0...v4.0.1
## [v4.0.0]
> Apr 28, 2015
- Updated docs
[4.0.0]: https://github.com/mjackson/http-client/compare/v4.0.0-0...v4.0.0
## [v4.0.0-0]
> Apr 27, 2016

@@ -13,5 +27,5 @@

[4.0.0-0]: https://github.com/mjackson/http-client/compare/v3.1.0...v4.0.0-0
[v4.0.0-0]: https://github.com/mjackson/http-client/compare/v3.1.0...v4.0.0-0
## [3.1.0]
## [v3.1.0]
> Mar 28, 2016

@@ -21,5 +35,5 @@

[3.1.0]: https://github.com/mjackson/http-client/compare/v3.0.0...v3.1.0
[v3.1.0]: https://github.com/mjackson/http-client/compare/v3.0.0...v3.1.0
## [3.0.0]
## [v3.0.0]
> Mar 22, 2016

@@ -29,5 +43,5 @@

[3.0.0]: https://github.com/mjackson/http-client/compare/v2.4.2...v3.0.0
[v3.0.0]: https://github.com/mjackson/http-client/compare/v2.4.2...v3.0.0
## [2.4.2]
## [v2.4.2]
> Mar 22, 2016

@@ -37,5 +51,5 @@

[2.4.2]: https://github.com/mjackson/http-client/compare/v2.4.0...v2.4.2
[v2.4.2]: https://github.com/mjackson/http-client/compare/v2.4.0...v2.4.2
## [2.4.0]
## [v2.4.0]
> Mar 18, 2016

@@ -46,5 +60,5 @@

[2.4.0]: https://github.com/mjackson/http-client/compare/v2.3.0...v2.4.0
[v2.4.0]: https://github.com/mjackson/http-client/compare/v2.3.0...v2.4.0
## [2.3.0]
## [v2.3.0]
> Mar 14, 2016

@@ -56,5 +70,5 @@

[2.3.0]: https://github.com/mjackson/http-client/compare/v2.2.1...v2.3.0
[v2.3.0]: https://github.com/mjackson/http-client/compare/v2.2.1...v2.3.0
## [2.2.1]
## [v2.2.1]
> Mar 13, 2016

@@ -65,2 +79,2 @@

[2.2.1]: https://github.com/mjackson/http-client/compare/v2.2.0...v2.2.1
[v2.2.1]: https://github.com/mjackson/http-client/compare/v2.2.0...v2.2.1

@@ -6,3 +6,3 @@ 'use strict';

});
exports.requestInfo = exports.parseJSON = exports.parseText = exports.handleResponse = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.createFetch = exports.createStack = exports.fetch = exports.enhanceFetch = undefined;
exports.requestInfo = exports.parseJSON = exports.parseText = exports.handleResponse = exports.onResponse = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.createFetch = exports.createStack = exports.fetch = exports.enhanceFetch = undefined;

@@ -33,3 +33,5 @@ var _queryString = require('query-string');

return fetch(input, options).then(function (response) {
return options.responseHandlers ? enhanceResponse(response, options.responseHandlers) : response;
var responseHandlers = options.responseHandlers;
return responseHandlers && responseHandlers.length ? enhanceResponse(response, responseHandlers) : response;
});

@@ -126,4 +128,4 @@ };

*/
var accept = exports.accept = function accept(contentType) {
return header('Accept', contentType);
var accept = exports.accept = function accept(value) {
return header('Accept', value);
};

@@ -195,3 +197,3 @@

*/
var handleResponse = exports.handleResponse = function handleResponse(handler) {
var onResponse = exports.onResponse = function onResponse(handler) {
return function (fetch, input) {

@@ -205,2 +207,5 @@ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

// Deprecated.
var handleResponse = exports.handleResponse = onResponse;
/**

@@ -211,3 +216,3 @@ * Adds the text of the response to response[propertyName].

var propertyName = arguments.length <= 0 || arguments[0] === undefined ? 'textString' : arguments[0];
return handleResponse(function (response) {
return onResponse(function (response) {
return response.text().then(function (value) {

@@ -225,3 +230,3 @@ response[propertyName] = value;

var propertyName = arguments.length <= 0 || arguments[0] === undefined ? 'jsonData' : arguments[0];
return handleResponse(function (response) {
return onResponse(function (response) {
return response.json().then(function (value) {

@@ -228,0 +233,0 @@ response[propertyName] = value;

{
"name": "http-client",
"version": "4.0.0",
"version": "4.0.1",
"description": "Compose HTTP clients using JavaScript's fetch API",

@@ -23,3 +23,3 @@ "author": "Michael Jackson",

"dependencies": {
"query-string": "^3.0.0"
"query-string": "^4.1.0"
},

@@ -34,4 +34,6 @@ "devDependencies": {

"eslint": "^2.5.1",
"eslint-config-airbnb": "^6.0.2",
"eslint-plugin-react": "^4.1.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.7.0",
"eslint-plugin-jsx-a11y": "^1.2.0",
"eslint-plugin-react": "^5.1.1",
"expect": "^1.14.0",

@@ -41,6 +43,6 @@ "gzip-size": "^3.0.0",

"karma": "^0.13.21",
"karma-browserstack-launcher": "^0.1.10",
"karma-chrome-launcher": "^0.2.2",
"karma-mocha": "^0.2.2",
"karma-mocha-reporter": "^1.2.3",
"karma-browserstack-launcher": "^1.0.0",
"karma-chrome-launcher": "^1.0.1",
"karma-mocha": "^1.0.1",
"karma-mocha-reporter": "^2.0.3",
"karma-sourcemap-loader": "^0.3.7",

@@ -47,0 +49,0 @@ "karma-webpack": "^1.7.0",

@@ -62,3 +62,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

});
exports.requestInfo = exports.parseJSON = exports.parseText = exports.handleResponse = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.createFetch = exports.createStack = exports.fetch = exports.enhanceFetch = undefined;
exports.requestInfo = exports.parseJSON = exports.parseText = exports.handleResponse = exports.onResponse = exports.params = exports.json = exports.body = exports.query = exports.base = exports.accept = exports.auth = exports.header = exports.method = exports.init = exports.createFetch = exports.createStack = exports.fetch = exports.enhanceFetch = undefined;

@@ -89,3 +89,5 @@ var _queryString = __webpack_require__(1);

return fetch(input, options).then(function (response) {
return options.responseHandlers ? enhanceResponse(response, options.responseHandlers) : response;
var responseHandlers = options.responseHandlers;
return responseHandlers && responseHandlers.length ? enhanceResponse(response, responseHandlers) : response;
});

@@ -182,4 +184,4 @@ };

*/
var accept = exports.accept = function accept(contentType) {
return header('Accept', contentType);
var accept = exports.accept = function accept(value) {
return header('Accept', value);
};

@@ -251,3 +253,3 @@

*/
var handleResponse = exports.handleResponse = function handleResponse(handler) {
var onResponse = exports.onResponse = function onResponse(handler) {
return function (fetch, input) {

@@ -261,2 +263,5 @@ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

// Deprecated.
var handleResponse = exports.handleResponse = onResponse;
/**

@@ -267,3 +272,3 @@ * Adds the text of the response to response[propertyName].

var propertyName = arguments.length <= 0 || arguments[0] === undefined ? 'textString' : arguments[0];
return handleResponse(function (response) {
return onResponse(function (response) {
return response.text().then(function (value) {

@@ -281,3 +286,3 @@ response[propertyName] = value;

var propertyName = arguments.length <= 0 || arguments[0] === undefined ? 'jsonData' : arguments[0];
return handleResponse(function (response) {
return onResponse(function (response) {
return response.json().then(function (value) {

@@ -319,2 +324,6 @@ response[propertyName] = value;

function encode(value, strict) {
return strict ? strictUriEncode(value) : encodeURIComponent(value);
}
exports.extract = function (str) {

@@ -325,4 +334,8 @@ return str.split('?')[1] || '';

exports.parse = function (str) {
// Create an object with no prototype
// https://github.com/sindresorhus/query-string/issues/47
var ret = Object.create(null);
if (typeof str !== 'string') {
return {};
return ret;
}

@@ -333,6 +346,6 @@

if (!str) {
return {};
return ret;
}
return str.split('&').reduce(function (ret, param) {
str.split('&').forEach(function (param) {
var parts = param.replace(/\+/g, ' ').split('=');

@@ -350,3 +363,3 @@ // Firefox (pre 40) decodes `%3D` to `=`

if (!ret.hasOwnProperty(key)) {
if (ret[key] === undefined) {
ret[key] = val;

@@ -358,8 +371,12 @@ } else if (Array.isArray(ret[key])) {

}
});
return ret;
}, {});
return ret;
};
exports.stringify = function (obj) {
exports.stringify = function (obj, opts) {
opts = opts || {};
var strict = opts.strict !== false;
return obj ? Object.keys(obj).sort().map(function (key) {

@@ -377,8 +394,20 @@ var val = obj[key];

if (Array.isArray(val)) {
return val.slice().sort().map(function (val2) {
return strictUriEncode(key) + '=' + strictUriEncode(val2);
}).join('&');
var result = [];
val.slice().sort().forEach(function (val2) {
if (val2 === undefined) {
return;
}
if (val2 === null) {
result.push(encode(key, strict));
} else {
result.push(encode(key, strict) + '=' + encode(val2, strict));
}
});
return result.join('&');
}
return strictUriEncode(key) + '=' + strictUriEncode(val);
return encode(key, strict) + '=' + encode(val, strict);
}).filter(function (x) {

@@ -385,0 +414,0 @@ return x.length > 0;

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

!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HTTPClient=t():n.HTTPClient=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.requestInfo=t.parseJSON=t.parseText=t.handleResponse=t.params=t.json=t.body=t.query=t.base=t.accept=t.auth=t.header=t.method=t.init=t.createFetch=t.createStack=t.fetch=t.enhanceFetch=void 0;var r=e(1),o=function(n){return"string"==typeof n?n:(0,r.stringify)(n)},u=function(n){return"string"==typeof n?n:JSON.stringify(n)},i=function(n,t){return t.reduce(function(n,t){return n.then(t)},Promise.resolve(n))},c=t.enhanceFetch=function(n){return function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(t,e).then(function(n){return e.responseHandlers?i(n,e.responseHandlers):n})}},f=c(fetch);t.fetch=f;var a=function(n,t,e){return n(t,e)},s=t.createStack=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];return 0===t.length?a:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},p=(t.createFetch=function(){if(0===arguments.length)return f;var n=s.apply(void 0,arguments);return c(function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(e.fetch||fetch,t,e)})},t.init=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o[n]=t,e(r,o)}}),d=(t.method=function(n){return p("method",n)},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),h=t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return d(o,n,t),e(r,o)}},l=(t.auth=function(n){return h("Authorization",n)},t.accept=function(n){return h("Accept",n)},t.base=function(n){return function(t,e,r){return t(n+(e||""),r)}},t.query=function(n){var t=o(n);return function(n,e,r){return n(e+(-1===e.indexOf("?")?"?":"&")+t,r)}}),v=t.body=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o.body=n,null!=n.length&&d(o,"Content-Length",n.length),t&&d(o,"Content-Type",t),e(r,o)}},g=(t.json=function(n){return v(u(n),"application/json")},t.params=function(n){var t=o(n);return function(n,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],o=(r.method||"GET").toUpperCase(),u="GET"===o||"HEAD"===o?l(t):v(t,"application/x-www-form-urlencoded");return u(n,e,r)}},t.handleResponse=function(n){return function(t,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return(r.responseHandlers||(r.responseHandlers=[])).push(n),t(e,r)}});t.parseText=function(){var n=arguments.length<=0||void 0===arguments[0]?"textString":arguments[0];return g(function(t){return t.text().then(function(e){return t[n]=e,t})})},t.parseJSON=function(){var n=arguments.length<=0||void 0===arguments[0]?"jsonData":arguments[0];return g(function(t){return t.json().then(function(e){return t[n]=e,t},function(n){throw new Error("Error parsing JSON: "+n.stack)})})},t.requestInfo=function(){return function(n,t,e){return n(t,e).then(function(n){return n.requestInput=t,n.requestOptions=e,n},function(){var n=arguments.length<=0||void 0===arguments[0]?new Error:arguments[0];throw n.requestInput=t,n.requestOptions=e,n})}}},function(n,t,e){"use strict";var r=e(2);t.extract=function(n){return n.split("?")[1]||""},t.parse=function(n){return"string"!=typeof n?{}:(n=n.trim().replace(/^(\?|#|&)/,""),n?n.split("&").reduce(function(n,t){var e=t.replace(/\+/g," ").split("="),r=e.shift(),o=e.length>0?e.join("="):void 0;return r=decodeURIComponent(r),o=void 0===o?null:decodeURIComponent(o),n.hasOwnProperty(r)?Array.isArray(n[r])?n[r].push(o):n[r]=[n[r],o]:n[r]=o,n},{}):{})},t.stringify=function(n){return n?Object.keys(n).sort().map(function(t){var e=n[t];return void 0===e?"":null===e?t:Array.isArray(e)?e.slice().sort().map(function(n){return r(t)+"="+r(n)}).join("&"):r(t)+"="+r(e)}).filter(function(n){return n.length>0}).join("&"):""}},function(n,t){"use strict";n.exports=function(n){return encodeURIComponent(n).replace(/[!'()*]/g,function(n){return"%"+n.charCodeAt(0).toString(16).toUpperCase()})}}])});
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.HTTPClient=t():n.HTTPClient=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var e={};return t.m=n,t.c=e,t.p="",t(0)}([function(n,t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.requestInfo=t.parseJSON=t.parseText=t.handleResponse=t.onResponse=t.params=t.json=t.body=t.query=t.base=t.accept=t.auth=t.header=t.method=t.init=t.createFetch=t.createStack=t.fetch=t.enhanceFetch=void 0;var r=e(1),o=function(n){return"string"==typeof n?n:(0,r.stringify)(n)},u=function(n){return"string"==typeof n?n:JSON.stringify(n)},i=function(n,t){return t.reduce(function(n,t){return n.then(t)},Promise.resolve(n))},c=t.enhanceFetch=function(n){return function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(t,e).then(function(n){var t=e.responseHandlers;return t&&t.length?i(n,t):n})}},f=c(fetch);t.fetch=f;var a=function(n,t,e){return n(t,e)},s=t.createStack=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];return 0===t.length?a:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},p=(t.createFetch=function(){if(0===arguments.length)return f;var n=s.apply(void 0,arguments);return c(function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return n(e.fetch||fetch,t,e)})},t.init=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o[n]=t,e(r,o)}}),h=(t.method=function(n){return p("method",n)},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),d=t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return h(o,n,t),e(r,o)}},l=(t.auth=function(n){return d("Authorization",n)},t.accept=function(n){return d("Accept",n)},t.base=function(n){return function(t,e,r){return t(n+(e||""),r)}},t.query=function(n){var t=o(n);return function(n,e,r){return n(e+(-1===e.indexOf("?")?"?":"&")+t,r)}}),v=t.body=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return o.body=n,null!=n.length&&h(o,"Content-Length",n.length),t&&h(o,"Content-Type",t),e(r,o)}},g=(t.json=function(n){return v(u(n),"application/json")},t.params=function(n){var t=o(n);return function(n,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],o=(r.method||"GET").toUpperCase(),u="GET"===o||"HEAD"===o?l(t):v(t,"application/x-www-form-urlencoded");return u(n,e,r)}},t.onResponse=function(n){return function(t,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return(r.responseHandlers||(r.responseHandlers=[])).push(n),t(e,r)}});t.handleResponse=g,t.parseText=function(){var n=arguments.length<=0||void 0===arguments[0]?"textString":arguments[0];return g(function(t){return t.text().then(function(e){return t[n]=e,t})})},t.parseJSON=function(){var n=arguments.length<=0||void 0===arguments[0]?"jsonData":arguments[0];return g(function(t){return t.json().then(function(e){return t[n]=e,t},function(n){throw new Error("Error parsing JSON: "+n.stack)})})},t.requestInfo=function(){return function(n,t,e){return n(t,e).then(function(n){return n.requestInput=t,n.requestOptions=e,n},function(){var n=arguments.length<=0||void 0===arguments[0]?new Error:arguments[0];throw n.requestInput=t,n.requestOptions=e,n})}}},function(n,t,e){"use strict";function r(n,t){return t?o(n):encodeURIComponent(n)}var o=e(2);t.extract=function(n){return n.split("?")[1]||""},t.parse=function(n){var t=Object.create(null);return"string"!=typeof n?t:(n=n.trim().replace(/^(\?|#|&)/,""))?(n.split("&").forEach(function(n){var e=n.replace(/\+/g," ").split("="),r=e.shift(),o=e.length>0?e.join("="):void 0;r=decodeURIComponent(r),o=void 0===o?null:decodeURIComponent(o),void 0===t[r]?t[r]=o:Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]}),t):t},t.stringify=function(n,t){t=t||{};var e=t.strict!==!1;return n?Object.keys(n).sort().map(function(t){var o=n[t];if(void 0===o)return"";if(null===o)return t;if(Array.isArray(o)){var u=[];return o.slice().sort().forEach(function(n){void 0!==n&&(null===n?u.push(r(t,e)):u.push(r(t,e)+"="+r(n,e)))}),u.join("&")}return r(t,e)+"="+r(o,e)}).filter(function(n){return n.length>0}).join("&"):""}},function(n,t){"use strict";n.exports=function(n){return encodeURIComponent(n).replace(/[!'()*]/g,function(n){return"%"+n.charCodeAt(0).toString(16).toUpperCase()})}}])});
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