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.4.0 to 2.4.1

5

CHANGES.md

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

## [HEAD]
## [2.4.0]
> Mar 18, 2016

@@ -6,3 +7,3 @@ - Export `handleResponse` helper for building middleware

[HEAD]: https://github.com/mjackson/http-client/compare/latest...HEAD
[2.4.0]: https://github.com/mjackson/http-client/compare/v2.3.0...v2.4.0

@@ -9,0 +10,0 @@ ## [2.3.0]

{
"name": "http-client",
"version": "2.4.0",
"version": "2.4.1",
"description": "Compose HTTP clients using JavaScript's fetch API",
"author": "Michael Jackson",
"license": "MIT",
"webpack": "lib",
"browser": "umd/http-client.min.js",
"main": "lib",
"browser": "umd/http-client.min.js",
"files": [

@@ -10,0 +11,0 @@ "lib",

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

If you're bundling http-client with [webpack](https://webpack.github.io/), you'll want to include the following in your webpack config:
```js
const webpack = require('webpack')
module.exports = {
plugins: [
new webpack.IgnorePlugin(/node-fetch/),
new webpack.DefinePlugin({
'typeof window': JSON.stringify('object')
})
]
}
```
In node, http-client automatically uses the [node-fetch](https://github.com/bitinn/node-fetch) library under the hood so no extra configuration is necessary. You'll need to be running node >= 4. Be sure to read about the [known differences](https://github.com/bitinn/node-fetch/blob/master/LIMITS.md) between node-fetch and [the fetch spec](https://fetch.spec.whatwg.org/).

@@ -36,0 +51,0 @@

4

umd/http-client.js

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

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

@@ -348,3 +348,3 @@ } else if (Array.isArray(ret[key])) {

return ret;
}, {});
}, Object.create(null));
};

@@ -351,0 +351,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.createFetch=t.createStack=t.fetch=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol?"symbol":typeof n},o=e(1),u="function"!=typeof fetch?"object"!==r(window)&&e(!function(){var n=new Error('Cannot find module "node-fetch"');throw n.code="MODULE_NOT_FOUND",n}()):fetch,i=function(n,t){return n.then(function(n){return t(null,n)},t)},c=function(n){return function(t,e,r){"function"!=typeof r&&("function"==typeof e?(r=e,e=void 0):"function"==typeof t&&(r=t,t=void 0));var o=n(t,e);return"function"==typeof r?i(o,r):o}},f=c(u),a=function(n){return"string"==typeof n?n:JSON.stringify(n)},s=function(n){return"string"==typeof n?n:(0,o.stringify)(n)},p=function(n,t,e){return n(t,e)};t.fetch=f;var d=t.createStack=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];return 0===t.length?p:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},l=(t.createFetch=function(){if(0===arguments.length)return f;var n=d.apply(void 0,arguments);return c(function(t,e){return n(u,t,e)})},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),h=(t.method=function(n){return function(t,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return r.method=n,t(e,r)}},t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return l(o,n,t),e(r,o)}}),y=(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=s(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&&l(o,"Content-Length",n.length),t&&l(o,"Content-Type",t),e(r,o)}},g=(t.json=function(n){return v(a(n),"application/json")},t.params=function(n){var t=s(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?y(t):v(t,"application/x-www-form-urlencoded");return u(n,e,r)}},t.handleResponse=function(n){return function(t,e,r){return t(e,r).then(n)}});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.params=t.json=t.body=t.query=t.base=t.accept=t.auth=t.header=t.method=t.createFetch=t.createStack=t.fetch=void 0;var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol?"symbol":typeof n},o=e(1),u="function"!=typeof fetch?"object"!==r(window)&&e(!function(){var n=new Error('Cannot find module "node-fetch"');throw n.code="MODULE_NOT_FOUND",n}()):fetch,i=function(n,t){return n.then(function(n){return t(null,n)},t)},c=function(n){return function(t,e,r){"function"!=typeof r&&("function"==typeof e?(r=e,e=void 0):"function"==typeof t&&(r=t,t=void 0));var o=n(t,e);return"function"==typeof r?i(o,r):o}},f=c(u),a=function(n){return"string"==typeof n?n:JSON.stringify(n)},s=function(n){return"string"==typeof n?n:(0,o.stringify)(n)},p=function(n,t,e){return n(t,e)};t.fetch=f;var d=t.createStack=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];return 0===t.length?p:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},l=(t.createFetch=function(){if(0===arguments.length)return f;var n=d.apply(void 0,arguments);return c(function(t,e){return n(u,t,e)})},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),h=(t.method=function(n){return function(t,e){var r=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return r.method=n,t(e,r)}},t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return l(o,n,t),e(r,o)}}),y=(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=s(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&&l(o,"Content-Length",n.length),t&&l(o,"Content-Type",t),e(r,o)}},g=(t.json=function(n){return v(a(n),"application/json")},t.params=function(n){var t=s(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?y(t):v(t,"application/x-www-form-urlencoded");return u(n,e,r)}},t.handleResponse=function(n){return function(t,e,r){return t(e,r).then(n)}});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[r]?Array.isArray(n[r])?n[r].push(o):n[r]=[n[r],o]:n[r]=o,n},Object.create(null)):{})},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()})}}])});
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