fetch-plus
Advanced tools
Comparing version 3.8.3 to 3.9.0
@@ -139,6 +139,8 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var errorMiddlewares = []; | ||
var fetchFunc = undefined; | ||
var fetchFunc = void 0; | ||
return new Promise(function (resolve, reject) { | ||
var url = _trimSlashes((0, _compute.compute)(endpoint.url)); | ||
var url = _trimSlashes((0, | ||
// Utilities: | ||
_compute.compute)(endpoint.url)); | ||
@@ -274,2 +276,37 @@ path = (0, _compute.compute)(path); | ||
function get(_endpoint, path) { | ||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
var middlewares = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; | ||
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]; | ||
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]; | ||
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]; | ||
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]; | ||
return request(_endpoint, path, _extends({ action: "del", method: "DELETE" }, options), middlewares); | ||
} | ||
function browse(_endpoint, path) { | ||
@@ -279,5 +316,5 @@ var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
return _callFetch(_endpoint, function () { | ||
return get(_endpoint, function () { | ||
return _expectOdd(path); | ||
}, _extends({ action: "browse", method: "GET" }, options), middlewares); | ||
}, _extends({ action: "browse" }, options), middlewares); | ||
} | ||
@@ -289,5 +326,5 @@ | ||
return _callFetch(_endpoint, function () { | ||
return get(_endpoint, function () { | ||
return _expectEven(path); | ||
}, _extends({ action: "read", method: "GET" }, options), middlewares); | ||
}, _extends({ action: "read" }, options), middlewares); | ||
} | ||
@@ -299,5 +336,5 @@ | ||
return _callFetch(_endpoint, function () { | ||
return patch(_endpoint, function () { | ||
return _expectEven(path); | ||
}, _extends({ action: "edit", method: "PATCH" }, options), middlewares); | ||
}, _extends({ action: "edit" }, options), middlewares); | ||
} | ||
@@ -309,5 +346,5 @@ | ||
return _callFetch(_endpoint, function () { | ||
return put(_endpoint, function () { | ||
return _expectEven(path); | ||
}, _extends({ action: "replace", method: "PUT" }, options), middlewares); | ||
}, _extends({ action: "replace" }, options), middlewares); | ||
} | ||
@@ -319,5 +356,5 @@ | ||
return _callFetch(_endpoint, function () { | ||
return post(_endpoint, function () { | ||
return _expectOdd(path); | ||
}, _extends({ action: "add", method: "POST" }, options), middlewares); | ||
}, _extends({ action: "add" }, options), middlewares); | ||
} | ||
@@ -329,5 +366,5 @@ | ||
return _callFetch(_endpoint, function () { | ||
return del(_endpoint, function () { | ||
return _expectEven(path); | ||
}, _extends({ action: "destroy", method: "DELETE" }, options), middlewares); | ||
}, _extends({ action: "destroy" }, options), middlewares); | ||
} | ||
@@ -347,8 +384,17 @@ | ||
module.exports = { | ||
// Fetch+ API: | ||
createClient: createClient, | ||
connectEndpoint: createClient, | ||
connectEndpoint: createClient, // deprecated | ||
addMiddleware: addMiddleware, | ||
removeMiddleware: removeMiddleware, | ||
// Drop-in replacement: | ||
fetch: _dropInFetch, | ||
// Generic: | ||
request: request, | ||
get: get, | ||
post: post, | ||
patch: patch, | ||
put: put, | ||
del: del, | ||
// BREAD: | ||
browse: browse, | ||
@@ -359,6 +405,6 @@ read: read, | ||
destroy: destroy, | ||
// CRUD: | ||
list: browse, | ||
update: edit, | ||
create: add, | ||
compute: _compute.compute, | ||
create: add, compute: _compute.compute, | ||
computeObject: _compute.computeObject | ||
@@ -467,3 +513,3 @@ }; | ||
if (Array.isArray(val)) { | ||
return val.slice().sort().map(function (val2) { | ||
return val.sort().map(function (val2) { | ||
return strictUriEncode(key) + '=' + strictUriEncode(val2); | ||
@@ -487,3 +533,3 @@ }).join('&'); | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { | ||
return '%' + c.charCodeAt(0).toString(16).toUpperCase(); | ||
return '%' + c.charCodeAt(0).toString(16); | ||
}); | ||
@@ -490,0 +536,0 @@ }; |
{ | ||
"name": "fetch-plus", | ||
"description": "A convenient Fetch API library with first-class middleware support", | ||
"version": "3.8.3", | ||
"version": "3.9.0", | ||
"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
17003
407