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 2.1.1 to 2.1.2

35

lib/index.js

@@ -12,8 +12,3 @@ 'use strict';

var globalFetch = undefined;
if (typeof fetch === 'function') {
globalFetch = fetch;
} else if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== 'object') {
globalFetch = require('node-fetch');
}
var globalFetch = typeof fetch === 'function' ? fetch : (typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== 'object' && require('node-fetch');

@@ -39,6 +34,6 @@ var stringifyQuery = function stringifyQuery(query) {

return middleware.reduceRight(function (inner, outer) {
return function (fetch, url, options) {
return outer(function (url, options) {
return inner(fetch, url, options);
}, url, options);
return function (fetch, outerURL, outerOptions) {
return outer(function (innerURL, innerOptions) {
return inner(fetch, innerURL, innerOptions);
}, outerURL, outerOptions);
};

@@ -119,4 +114,3 @@ });

return function (fetch, url, options) {
url += (url.indexOf('?') === -1 ? '?' : '&') + queryString;
return fetch(url, options);
return fetch(url + (url.indexOf('?') === -1 ? '?' : '&') + queryString, options);
};

@@ -159,4 +153,4 @@ };

var method = (options.method || 'GET').toUpperCase();
var middleware = method === 'GET' || method === 'HEAD' ? query(queryString) : body(queryString, 'application/x-www-form-urlencoded');
var verb = (options.method || 'GET').toUpperCase();
var middleware = verb === 'GET' || verb === 'HEAD' ? query(queryString) : body(queryString, 'application/x-www-form-urlencoded');

@@ -179,4 +173,4 @@ return middleware(fetch, url, options);

return enhanceResponse(function (response) {
return response.text().then(function (text) {
response[propertyName] = text;
return response.text().then(function (value) {
response[propertyName] = value;
return response;

@@ -193,4 +187,4 @@ });

return enhanceResponse(function (response) {
return response.json().then(function (json) {
response[propertyName] = json;
return response.json().then(function (value) {
response[propertyName] = value;
return response;

@@ -213,4 +207,5 @@ }, function (error) {

return response;
}, function (error) {
error = error || new Error();
}, function () {
var error = arguments.length <= 0 || arguments[0] === undefined ? new Error() : arguments[0];
error.requestURL = url;

@@ -217,0 +212,0 @@ error.requestOptions = options;

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

@@ -14,2 +14,3 @@ "author": "Michael Jackson",

"scripts": {
"lint": "eslint modules",
"build": "node ./scripts/build.js",

@@ -21,3 +22,3 @@ "build-cjs": "rimraf lib && babel ./modules -d lib --ignore '__tests__'",

"prepublish": "npm run build",
"test": "karma start"
"test": "npm run lint && karma start"
},

@@ -31,5 +32,9 @@ "dependencies": {

"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.3",
"babel-preset-es2015": "^6.5.0",
"es6-promise": "^3.1.2",
"eslint": "^2.2.0",
"eslint-config-airbnb": "^6.0.2",
"eslint-plugin-react": "^4.1.0",
"expect": "^1.14.0",

@@ -36,0 +41,0 @@ "gzip-size": "^3.0.0",

@@ -35,2 +35,10 @@ # http-client [![Travis][build-badge]][build] [![npm package][npm-badge]][npm]

The UMD build is also available on [npmcdn](https://npmcdn.com):
```html
<script src="https://npmcdn.com/http-client/umd/HTTPClient.min.js"></script>
```
You can find the library on `window.HTTPClient`.
## Usage

@@ -37,0 +45,0 @@

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

var globalFetch = undefined;
if (typeof fetch === 'function') {
globalFetch = fetch;
} else if (( false ? 'undefined' : _typeof(window)) !== 'object') {
globalFetch = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"node-fetch\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
}
var globalFetch = typeof fetch === 'function' ? fetch : ( false ? 'undefined' : _typeof(window)) !== 'object' && __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module \"node-fetch\""); e.code = 'MODULE_NOT_FOUND'; throw e; }()));

@@ -95,6 +90,6 @@ var stringifyQuery = function stringifyQuery(query) {

return middleware.reduceRight(function (inner, outer) {
return function (fetch, url, options) {
return outer(function (url, options) {
return inner(fetch, url, options);
}, url, options);
return function (fetch, outerURL, outerOptions) {
return outer(function (innerURL, innerOptions) {
return inner(fetch, innerURL, innerOptions);
}, outerURL, outerOptions);
};

@@ -175,4 +170,3 @@ });

return function (fetch, url, options) {
url += (url.indexOf('?') === -1 ? '?' : '&') + queryString;
return fetch(url, options);
return fetch(url + (url.indexOf('?') === -1 ? '?' : '&') + queryString, options);
};

@@ -215,4 +209,4 @@ };

var method = (options.method || 'GET').toUpperCase();
var middleware = method === 'GET' || method === 'HEAD' ? query(queryString) : body(queryString, 'application/x-www-form-urlencoded');
var verb = (options.method || 'GET').toUpperCase();
var middleware = verb === 'GET' || verb === 'HEAD' ? query(queryString) : body(queryString, 'application/x-www-form-urlencoded');

@@ -235,4 +229,4 @@ return middleware(fetch, url, options);

return enhanceResponse(function (response) {
return response.text().then(function (text) {
response[propertyName] = text;
return response.text().then(function (value) {
response[propertyName] = value;
return response;

@@ -249,4 +243,4 @@ });

return enhanceResponse(function (response) {
return response.json().then(function (json) {
response[propertyName] = json;
return response.json().then(function (value) {
response[propertyName] = value;
return response;

@@ -269,4 +263,5 @@ }, function (error) {

return response;
}, function (error) {
error = error || new Error();
}, function () {
var error = arguments.length <= 0 || arguments[0] === undefined ? new Error() : arguments[0];
error.requestURL = url;

@@ -273,0 +268,0 @@ error.requestOptions = options;

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

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