fetch-plus
Advanced tools
Comparing version 3.10.4 to 3.10.6
@@ -59,3 +59,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -67,3 +67,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /** | ||
var _queryString = __webpack_require__(2); | ||
var _queryString = __webpack_require__(3); | ||
@@ -83,4 +83,4 @@ var _queryString2 = _interopRequireDefault(_queryString); | ||
var createClient = function createClient(url) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var middlewares = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var middlewares = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
@@ -144,14 +144,19 @@ var endpoint = { | ||
var _callFetch = function _callFetch(endpoint) { | ||
var path = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1]; | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
var afterMiddlewares = []; | ||
var errorMiddlewares = []; | ||
var fetchFunc = undefined; | ||
var fetchFunc = void 0; | ||
var normalizeFunc = _trimSlashes; | ||
if (typeof options.normalizeUrl === "function") { | ||
normalizeFunc = options.normalizeUrl; | ||
} else if (typeof endpoint.options.normalizeUrl === "function") { | ||
normalizeFunc = endpoint.options.normalizeUrl; | ||
} | ||
return new Promise(function (resolve, reject) { | ||
var url = _trimSlashes((0, | ||
// Utilities: | ||
_compute.compute)(endpoint.url)); | ||
var url = normalizeFunc((0, _compute.compute)(endpoint.url)); | ||
@@ -164,5 +169,5 @@ path = (0, _compute.compute)(path); | ||
path = _trimSlashes(path.map(_compute.compute).map(encodeURI).join("/")); | ||
path = normalizeFunc(path.map(_compute.compute).map(encodeURI).join("/")); | ||
if (path) { | ||
if (path && path[0] !== "/") { | ||
path = "/" + path; | ||
@@ -199,6 +204,6 @@ } | ||
} else if ((typeof result === "undefined" ? "undefined" : _typeof(result)) === "object") { | ||
var _result$after = result.after; | ||
var after = _result$after === undefined ? null : _result$after; | ||
var _result$error = result.error; | ||
var error = _result$error === undefined ? null : _result$error; | ||
var _result$after = result.after, | ||
after = _result$after === undefined ? null : _result$after, | ||
_result$error = result.error, | ||
error = _result$error === undefined ? null : _result$error; | ||
@@ -286,4 +291,4 @@ | ||
function request(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -294,4 +299,4 @@ return _callFetch(_endpoint, path, _extends({ action: "request" }, options), middlewares); | ||
function get(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -302,4 +307,4 @@ return request(_endpoint, path, _extends({ action: "get", method: "GET" }, options), middlewares); | ||
function post(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -310,4 +315,4 @@ return request(_endpoint, path, _extends({ action: "post", method: "POST" }, options), middlewares); | ||
function patch(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -318,4 +323,4 @@ return request(_endpoint, path, _extends({ action: "patch", method: "PATCH" }, options), middlewares); | ||
function put(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -326,4 +331,4 @@ return request(_endpoint, path, _extends({ action: "put", method: "PUT" }, options), middlewares); | ||
function del(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -334,4 +339,4 @@ return request(_endpoint, path, _extends({ action: "del", method: "DELETE" }, options), middlewares); | ||
function browse(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -344,4 +349,4 @@ return get(_endpoint, function () { | ||
function read(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -354,4 +359,4 @@ return get(_endpoint, function () { | ||
function edit(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -364,4 +369,4 @@ return patch(_endpoint, function () { | ||
function replace(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -374,4 +379,4 @@ return put(_endpoint, function () { | ||
function add(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -384,4 +389,4 @@ return post(_endpoint, function () { | ||
function destroy(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var middlewares = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
@@ -394,4 +399,4 @@ return del(_endpoint, function () { | ||
var _dropInFetch = function _dropInFetch(url) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var middlewares = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var middlewares = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
@@ -429,3 +434,5 @@ return _callFetch({ | ||
update: edit, | ||
create: add, compute: _compute.compute, | ||
create: add, | ||
// Utilities: | ||
compute: _compute.compute, | ||
computeObject: _compute.computeObject | ||
@@ -440,3 +447,3 @@ }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
@@ -488,7 +495,105 @@ /** | ||
/* 2 */ | ||
/***/ 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; | ||
}; | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var strictUriEncode = __webpack_require__(3); | ||
var strictUriEncode = __webpack_require__(4); | ||
var objectAssign = __webpack_require__(2); | ||
function encode(value, opts) { | ||
if (opts.encode) { | ||
return opts.strict ? strictUriEncode(value) : encodeURIComponent(value); | ||
} | ||
return value; | ||
} | ||
exports.extract = function (str) { | ||
@@ -499,4 +604,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; | ||
} | ||
@@ -507,6 +616,6 @@ | ||
if (!str) { | ||
return {}; | ||
return ret; | ||
} | ||
return str.split('&').reduce(function (ret, param) { | ||
str.split('&').forEach(function (param) { | ||
var parts = param.replace(/\+/g, ' ').split('='); | ||
@@ -524,3 +633,3 @@ // Firefox (pre 40) decodes `%3D` to `=` | ||
if (!ret.hasOwnProperty(key)) { | ||
if (ret[key] === undefined) { | ||
ret[key] = val; | ||
@@ -532,8 +641,15 @@ } else if (Array.isArray(ret[key])) { | ||
} | ||
}); | ||
return ret; | ||
}, {}); | ||
return ret; | ||
}; | ||
exports.stringify = function (obj) { | ||
exports.stringify = function (obj, opts) { | ||
var defaults = { | ||
encode: true, | ||
strict: true | ||
}; | ||
opts = objectAssign(defaults, opts); | ||
return obj ? Object.keys(obj).sort().map(function (key) { | ||
@@ -547,12 +663,24 @@ var val = obj[key]; | ||
if (val === null) { | ||
return key; | ||
return encode(key, opts); | ||
} | ||
if (Array.isArray(val)) { | ||
return val.slice().sort().map(function (val2) { | ||
return strictUriEncode(key) + '=' + strictUriEncode(val2); | ||
}).join('&'); | ||
var result = []; | ||
val.slice().forEach(function (val2) { | ||
if (val2 === undefined) { | ||
return; | ||
} | ||
if (val2 === null) { | ||
result.push(encode(key, opts)); | ||
} else { | ||
result.push(encode(key, opts) + '=' + encode(val2, opts)); | ||
} | ||
}); | ||
return result.join('&'); | ||
} | ||
return strictUriEncode(key) + '=' + strictUriEncode(val); | ||
return encode(key, opts) + '=' + encode(val, opts); | ||
}).filter(function (x) { | ||
@@ -565,3 +693,3 @@ return x.length > 0; | ||
/***/ }, | ||
/* 3 */ | ||
/* 4 */ | ||
/***/ function(module, exports) { | ||
@@ -568,0 +696,0 @@ |
{ | ||
"name": "fetch-plus", | ||
"description": "A convenient Fetch API library with first-class middleware support", | ||
"version": "3.10.4", | ||
"version": "3.10.6", | ||
"license": "BSD-3-Clause", | ||
@@ -6,0 +6,0 @@ "repository": { |
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
20940
527