http-client
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -10,2 +10,8 @@ 'use strict'; | ||
var _byteLength = require('byte-length'); | ||
var _byteLength2 = _interopRequireDefault(_byteLength); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var stringifyQuery = function stringifyQuery(query) { | ||
@@ -160,3 +166,3 @@ return typeof query === 'string' ? query : (0, _queryString.stringify)(query); | ||
if (content.length != null) setHeader(options, 'Content-Length', content.length); | ||
if (content.length != null) setHeader(options, 'Content-Length', (0, _byteLength2.default)(content)); | ||
@@ -163,0 +169,0 @@ if (contentType) setHeader(options, 'Content-Type', contentType); |
{ | ||
"name": "http-client", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Compose HTTP clients using JavaScript's fetch API", | ||
@@ -15,10 +15,11 @@ "author": "Michael Jackson", | ||
"build": "node ./scripts/build.js", | ||
"build-cjs": "rimraf lib && babel ./modules -d lib --ignore '__tests__'", | ||
"build-lib": "rimraf lib && babel ./modules -d lib --ignore '__tests__'", | ||
"build-min": "webpack -p modules/index.js umd/http-client.min.js", | ||
"build-umd": "webpack modules/index.js umd/http-client.js", | ||
"release": "node ./scripts/release.js", | ||
"prepublish": "npm run build", | ||
"prepublish": "node ./scripts/build.js", | ||
"test": "npm run lint && karma start" | ||
}, | ||
"dependencies": { | ||
"byte-length": "^0.1.1", | ||
"query-string": "^4.1.0" | ||
@@ -34,8 +35,6 @@ }, | ||
"eslint": "^2.5.1", | ||
"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", | ||
"gzip-size": "^3.0.0", | ||
"in-publish": "^2.0.0", | ||
"isomorphic-fetch": "^2.2.1", | ||
@@ -58,8 +57,3 @@ "karma": "^0.13.21", | ||
"url": "https://github.com/mjackson/http-client.git" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015" | ||
] | ||
} | ||
} |
@@ -66,2 +66,8 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _byteLength = __webpack_require__(4); | ||
var _byteLength2 = _interopRequireDefault(_byteLength); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var stringifyQuery = function stringifyQuery(query) { | ||
@@ -216,3 +222,3 @@ return typeof query === 'string' ? query : (0, _queryString.stringify)(query); | ||
if (content.length != null) setHeader(options, 'Content-Length', content.length); | ||
if (content.length != null) setHeader(options, 'Content-Length', (0, _byteLength2.default)(content)); | ||
@@ -318,5 +324,10 @@ if (contentType) setHeader(options, 'Content-Type', contentType); | ||
var strictUriEncode = __webpack_require__(2); | ||
var objectAssign = __webpack_require__(3); | ||
function encode(value, strict) { | ||
return strict ? strictUriEncode(value) : encodeURIComponent(value); | ||
function encode(value, opts) { | ||
if (opts.encode) { | ||
return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); | ||
} | ||
return value; | ||
} | ||
@@ -369,5 +380,8 @@ | ||
exports.stringify = function (obj, opts) { | ||
opts = opts || {}; | ||
var defaults = { | ||
encode: true, | ||
strict: true | ||
}; | ||
var strict = opts.strict !== false; | ||
opts = objectAssign(defaults, opts); | ||
@@ -388,3 +402,3 @@ return obj ? Object.keys(obj).sort().map(function (key) { | ||
val.slice().sort().forEach(function (val2) { | ||
val.slice().forEach(function (val2) { | ||
if (val2 === undefined) { | ||
@@ -395,5 +409,5 @@ return; | ||
if (val2 === null) { | ||
result.push(encode(key, strict)); | ||
result.push(encode(key, opts)); | ||
} else { | ||
result.push(encode(key, strict) + '=' + encode(val2, strict)); | ||
result.push(encode(key, opts) + '=' + encode(val2, opts)); | ||
} | ||
@@ -405,3 +419,3 @@ }); | ||
return encode(key, strict) + '=' + encode(val, strict); | ||
return encode(key, opts) + '=' + encode(val, opts); | ||
}).filter(function (x) { | ||
@@ -425,2 +439,119 @@ return x.length > 0; | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
/* eslint-disable no-unused-vars */ | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var propIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
function toObject(val) { | ||
if (val === null || val === undefined) { | ||
throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
} | ||
return Object(val); | ||
} | ||
function shouldUseNative() { | ||
try { | ||
if (!Object.assign) { | ||
return false; | ||
} | ||
// Detect buggy property enumeration order in older V8 versions. | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=4118 | ||
var test1 = new String('abc'); // eslint-disable-line | ||
test1[5] = 'de'; | ||
if (Object.getOwnPropertyNames(test1)[0] === '5') { | ||
return false; | ||
} | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | ||
var test2 = {}; | ||
for (var i = 0; i < 10; i++) { | ||
test2['_' + String.fromCharCode(i)] = i; | ||
} | ||
var order2 = Object.getOwnPropertyNames(test2).map(function (n) { | ||
return test2[n]; | ||
}); | ||
if (order2.join('') !== '0123456789') { | ||
return false; | ||
} | ||
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 | ||
var test3 = {}; | ||
'abcdefghijklmnopqrst'.split('').forEach(function (letter) { | ||
test3[letter] = letter; | ||
}); | ||
if (Object.keys(Object.assign({}, test3)).join('') !== | ||
'abcdefghijklmnopqrst') { | ||
return false; | ||
} | ||
return true; | ||
} catch (e) { | ||
// We don't expect any of the above to throw, but better to be safe. | ||
return false; | ||
} | ||
} | ||
module.exports = shouldUseNative() ? Object.assign : function (target, source) { | ||
var from; | ||
var to = toObject(target); | ||
var symbols; | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = Object(arguments[s]); | ||
for (var key in from) { | ||
if (hasOwnProperty.call(from, key)) { | ||
to[key] = from[key]; | ||
} | ||
} | ||
if (Object.getOwnPropertySymbols) { | ||
symbols = Object.getOwnPropertySymbols(from); | ||
for (var i = 0; i < symbols.length; i++) { | ||
if (propIsEnumerable.call(from, symbols[i])) { | ||
to[symbols[i]] = from[symbols[i]]; | ||
} | ||
} | ||
} | ||
} | ||
return to; | ||
}; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
/* | ||
* Calculate the byte lengths for utf8 encoded strings. | ||
* | ||
* @param {String} str | ||
* @return {Number} | ||
*/ | ||
module.exports = function byteLength (str) { | ||
var i, len; | ||
if (!str) return 0; | ||
str = str.toString(); | ||
for (i = len = str.length; i--;) { | ||
var code = str[i].charCodeAt(); | ||
if (0xDC00 <= code && code <= 0xDFFF) i--; | ||
if (0x7f < code && code <= 0x7ff) len++; | ||
else if (0x7ff < code && code <= 0xffff) len += 2; | ||
} | ||
return len; | ||
}; | ||
/***/ } | ||
@@ -427,0 +558,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.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()})}}])}); | ||
!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";function r(n){return n&&n.__esModule?n:{"default":n}}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 o=e(3),u=e(1),i=r(u),c=function(n){return"string"==typeof n?n:(0,o.stringify)(n)},f=function(n){return"string"==typeof n?n:JSON.stringify(n)},a=function(n,t){return t.reduce(function(n,t){return n.then(t)},Promise.resolve(n))},s=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?a(n,t):n})}},p=s(fetch);t.fetch=p;var l=function(n,t,e){return n(t,e)},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?l:t.reduceRight(function(n,t){return function(e,r,o){return t(function(t,r){return n(e,t,r)},r,o)}})},h=(t.createFetch=function(){if(0===arguments.length)return p;var n=d.apply(void 0,arguments);return s(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)}}),v=(t.method=function(n){return h("method",n)},function(n,t,e){(n.headers||(n.headers={}))[t]=e}),g=t.header=function(n,t){return function(e,r){var o=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return v(o,n,t),e(r,o)}},y=(t.auth=function(n){return g("Authorization",n)},t.accept=function(n){return g("Accept",n)},t.base=function(n){return function(t,e,r){return t(n+(e||""),r)}},t.query=function(n){var t=c(n);return function(n,e,r){return n(e+(-1===e.indexOf("?")?"?":"&")+t,r)}}),b=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&&v(o,"Content-Length",(0,i["default"])(n)),t&&v(o,"Content-Type",t),e(r,o)}},j=(t.json=function(n){return b(f(n),"application/json")},t.params=function(n){var t=c(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):b(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=j,t.parseText=function(){var n=arguments.length<=0||void 0===arguments[0]?"textString":arguments[0];return j(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 j(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){"use strict";n.exports=function(n){var t,e;if(!n)return 0;for(n=n.toString(),t=e=n.length;t--;){var r=n[t].charCodeAt();r>=56320&&57343>=r&&t--,r>127&&2047>=r?e++:r>2047&&65535>=r&&(e+=2)}return e}},function(n,t){"use strict";function e(n){if(null===n||void 0===n)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(n)}function r(){try{if(!Object.assign)return!1;var n=new String("abc");if(n[5]="de","5"===Object.getOwnPropertyNames(n)[0])return!1;for(var t={},e=0;10>e;e++)t["_"+String.fromCharCode(e)]=e;var r=Object.getOwnPropertyNames(t).map(function(n){return t[n]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(n){o[n]=n}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(u){return!1}}var o=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;n.exports=r()?Object.assign:function(n,t){for(var r,i,c=e(n),f=1;f<arguments.length;f++){r=Object(arguments[f]);for(var a in r)o.call(r,a)&&(c[a]=r[a]);if(Object.getOwnPropertySymbols){i=Object.getOwnPropertySymbols(r);for(var s=0;s<i.length;s++)u.call(r,i[s])&&(c[i[s]]=r[i[s]])}}return c}},function(n,t,e){"use strict";function r(n,t){return t.encode?t.strict?o(n):encodeURIComponent(n):n}var o=e(4),u=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){var e={encode:!0,strict:!0};return t=u(e,t),n?Object.keys(n).sort().map(function(e){var o=n[e];if(void 0===o)return"";if(null===o)return e;if(Array.isArray(o)){var u=[];return o.slice().forEach(function(n){void 0!==n&&(null===n?u.push(r(e,t)):u.push(r(e,t)+"="+r(n,t)))}),u.join("&")}return r(e,t)+"="+r(o,t)}).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()})}}])}); |
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
32511
24
651
2
+ Addedbyte-length@^0.1.1
+ Addedbyte-length@0.1.1(transitive)