Comparing version 0.0.10 to 0.0.11
@@ -0,1 +1,7 @@ | ||
## [0.0.11](https://github.com/posva/mande/compare/v0.0.10...v0.0.11) (2020-07-23) | ||
### Features | ||
- **nuxt:** add nuxt plugin to copy headers ([060fe9d](https://github.com/posva/mande/commit/060fe9da2e93be8b3db3a6399bdeb4c3f03876b2)) | ||
## [0.0.10](https://github.com/posva/mande/compare/v0.0.9...v0.0.10) (2020-06-26) | ||
@@ -2,0 +8,0 @@ |
/*! | ||
* mande v0.0.9 | ||
* mande v0.0.10 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -98,4 +98,23 @@ * @license MIT | ||
} | ||
function nuxtWrap(api, fn) { | ||
const argsAmount = fn.length; | ||
const wrappedCall = function _wrappedCall() { | ||
let apiInstance = api; | ||
let args = Array.from(arguments); | ||
// call from nuxt server | ||
if (arguments.length === argsAmount) { | ||
apiInstance = Object.assign({}, api); | ||
// remove the first argument | ||
const [augmentApiInstance] = args.splice(0, 1); | ||
// let the caller augment the instance | ||
augmentApiInstance(apiInstance); | ||
apiInstance.options.headers = Object.assign({}, apiInstance.options.headers); | ||
} | ||
return fn.call(null, apiInstance, ...args); | ||
}; | ||
return wrappedCall; | ||
} | ||
exports.defaults = defaults; | ||
exports.mande = mande; | ||
exports.nuxtWrap = nuxtWrap; |
@@ -11,2 +11,4 @@ | ||
declare type InferArgs<F> = F extends (api: MandeInstance, ...args: infer A) => any ? A : never; | ||
/** | ||
@@ -118,2 +120,4 @@ * Create a Mande instance | ||
export declare function nuxtWrap<M extends MandeInstance, F extends (api: M, ...args: any[]) => any>(api: M, fn: F): (...args: InferArgs<F>) => ReturnType<F>; | ||
/** | ||
@@ -120,0 +124,0 @@ * Allowed options for a request. Extends native `RequestInit`. |
/*! | ||
* mande v0.0.9 | ||
* mande v0.0.10 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -94,3 +94,21 @@ * @license MIT | ||
} | ||
function nuxtWrap(api, fn) { | ||
const argsAmount = fn.length; | ||
const wrappedCall = function _wrappedCall() { | ||
let apiInstance = api; | ||
let args = Array.from(arguments); | ||
// call from nuxt server | ||
if (arguments.length === argsAmount) { | ||
apiInstance = Object.assign({}, api); | ||
// remove the first argument | ||
const [augmentApiInstance] = args.splice(0, 1); | ||
// let the caller augment the instance | ||
augmentApiInstance(apiInstance); | ||
apiInstance.options.headers = Object.assign({}, apiInstance.options.headers); | ||
} | ||
return fn.call(null, apiInstance, ...args); | ||
}; | ||
return wrappedCall; | ||
} | ||
export { defaults, mande }; | ||
export { defaults, mande, nuxtWrap }; |
/*! | ||
* mande v0.0.9 | ||
* mande v0.0.10 | ||
* (c) 2020 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
let e=/\/+$/,t=/^\/+/;const n={responseAs:"json",headers:{Accept:"application/json","Content-Type":"application/json"}};function s(s,o={},r){function i(o,r,i,u={}){let l,p;"object"==typeof r?(l="",p=r,u=i||{}):(l=r,p=i);let j=Object.assign(Object.assign(Object.assign(Object.assign({},n),a),{method:o}),u),b=Object.assign(Object.assign(Object.assign({},n.query),a.query),u.query),{responseAs:d}=j;return j.headers=Object.assign(Object.assign(Object.assign({},n.headers),a.headers),u.headers),l=function(n,s){return n.replace(e,"")+"/"+s.replace(t,"")}(s,"number"==typeof l?""+l:l||""),l+=function(e){let t=Object.keys(e).map(t=>[t,e[t]].map(encodeURIComponent).join("=")).join("&");return t?"?"+t:""}(b),p&&(j.body=JSON.stringify(p)),c(l,j).then(e=>{if(e.status>=200&&e.status<300)return"response"===d?e:204==e.status?null:e[d]();let t=new Error(e.statusText);throw t.response=e,t})}const c="undefined"!=typeof fetch?fetch:r;if(!c)throw new Error("No fetch function exists. Make sure to include a polyfill on Node.js.");const a=Object.assign({headers:{}},o);return{options:a,post:i.bind(null,"POST"),put:i.bind(null,"PUT"),patch:i.bind(null,"PATCH"),get:(e,t)=>i("GET",e,null,t),delete:(e,t)=>i("DELETE",e,null,t)}}export{n as defaults,s as mande}; | ||
let e=/\/+$/,n=/^\/+/;const t={responseAs:"json",headers:{Accept:"application/json","Content-Type":"application/json"}};function s(s,o={},r){function i(o,r,i,l={}){let u,p;"object"==typeof r?(u="",p=r,l=i||{}):(u=r,p=i);let j=Object.assign(Object.assign(Object.assign(Object.assign({},t),a),{method:o}),l),b=Object.assign(Object.assign(Object.assign({},t.query),a.query),l.query),{responseAs:f}=j;return j.headers=Object.assign(Object.assign(Object.assign({},t.headers),a.headers),l.headers),u=function(t,s){return t.replace(e,"")+"/"+s.replace(n,"")}(s,"number"==typeof u?""+u:u||""),u+=function(e){let n=Object.keys(e).map(n=>[n,e[n]].map(encodeURIComponent).join("=")).join("&");return n?"?"+n:""}(b),p&&(j.body=JSON.stringify(p)),c(u,j).then(e=>{if(e.status>=200&&e.status<300)return"response"===f?e:204==e.status?null:e[f]();let n=new Error(e.statusText);throw n.response=e,n})}const c="undefined"!=typeof fetch?fetch:r;if(!c)throw new Error("No fetch function exists. Make sure to include a polyfill on Node.js.");const a=Object.assign({headers:{}},o);return{options:a,post:i.bind(null,"POST"),put:i.bind(null,"PUT"),patch:i.bind(null,"PATCH"),get:(e,n)=>i("GET",e,null,n),delete:(e,n)=>i("DELETE",e,null,n)}}function o(e,n){const t=n.length;return function(){let s=e,o=Array.from(arguments);if(arguments.length===t){s=Object.assign({},e);const[n]=o.splice(0,1);n(s),s.options.headers=Object.assign({},s.options.headers)}return n.call(null,s,...o)}}export{t as defaults,s as mande,o as nuxtWrap}; |
/*! | ||
* mande v0.0.9 | ||
* mande v0.0.10 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -97,5 +97,24 @@ * @license MIT | ||
} | ||
function nuxtWrap(api, fn) { | ||
const argsAmount = fn.length; | ||
const wrappedCall = function _wrappedCall() { | ||
let apiInstance = api; | ||
let args = Array.from(arguments); | ||
// call from nuxt server | ||
if (arguments.length === argsAmount) { | ||
apiInstance = Object.assign({}, api); | ||
// remove the first argument | ||
const [augmentApiInstance] = args.splice(0, 1); | ||
// let the caller augment the instance | ||
augmentApiInstance(apiInstance); | ||
apiInstance.options.headers = Object.assign({}, apiInstance.options.headers); | ||
} | ||
return fn.call(null, apiInstance, ...args); | ||
}; | ||
return wrappedCall; | ||
} | ||
exports.defaults = defaults; | ||
exports.mande = mande; | ||
exports.nuxtWrap = nuxtWrap; | ||
@@ -102,0 +121,0 @@ return exports; |
/*! | ||
* mande v0.0.9 | ||
* mande v0.0.10 | ||
* (c) 2020 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
var Mande=function(e){"use strict";let t=/\/+$/,n=/^\/+/;const s={responseAs:"json",headers:{Accept:"application/json","Content-Type":"application/json"}};return e.defaults=s,e.mande=function(e,o={},r){function a(o,r,a,u={}){let l,p;"object"==typeof r?(l="",p=r,u=a||{}):(l=r,p=a);let d=Object.assign(Object.assign(Object.assign(Object.assign({},s),c),{method:o}),u),j=Object.assign(Object.assign(Object.assign({},s.query),c.query),u.query),{responseAs:b}=d;return d.headers=Object.assign(Object.assign(Object.assign({},s.headers),c.headers),u.headers),l=function(e,s){return e.replace(t,"")+"/"+s.replace(n,"")}(e,"number"==typeof l?""+l:l||""),l+=function(e){let t=Object.keys(e).map(t=>[t,e[t]].map(encodeURIComponent).join("=")).join("&");return t?"?"+t:""}(j),p&&(d.body=JSON.stringify(p)),i(l,d).then(e=>{if(e.status>=200&&e.status<300)return"response"===b?e:204==e.status?null:e[b]();let t=new Error(e.statusText);throw t.response=e,t})}const i="undefined"!=typeof fetch?fetch:r;if(!i)throw new Error("No fetch function exists. Make sure to include a polyfill on Node.js.");const c=Object.assign({headers:{}},o);return{options:c,post:a.bind(null,"POST"),put:a.bind(null,"PUT"),patch:a.bind(null,"PATCH"),get:(e,t)=>a("GET",e,null,t),delete:(e,t)=>a("DELETE",e,null,t)}},e}({}); | ||
var Mande=function(e){"use strict";let n=/\/+$/,t=/^\/+/;const s={responseAs:"json",headers:{Accept:"application/json","Content-Type":"application/json"}};return e.defaults=s,e.mande=function(e,o={},r){function i(o,r,i,u={}){let l,p;"object"==typeof r?(l="",p=r,u=i||{}):(l=r,p=i);let d=Object.assign(Object.assign(Object.assign(Object.assign({},s),c),{method:o}),u),f=Object.assign(Object.assign(Object.assign({},s.query),c.query),u.query),{responseAs:j}=d;return d.headers=Object.assign(Object.assign(Object.assign({},s.headers),c.headers),u.headers),l=function(e,s){return e.replace(n,"")+"/"+s.replace(t,"")}(e,"number"==typeof l?""+l:l||""),l+=function(e){let n=Object.keys(e).map(n=>[n,e[n]].map(encodeURIComponent).join("=")).join("&");return n?"?"+n:""}(f),p&&(d.body=JSON.stringify(p)),a(l,d).then(e=>{if(e.status>=200&&e.status<300)return"response"===j?e:204==e.status?null:e[j]();let n=new Error(e.statusText);throw n.response=e,n})}const a="undefined"!=typeof fetch?fetch:r;if(!a)throw new Error("No fetch function exists. Make sure to include a polyfill on Node.js.");const c=Object.assign({headers:{}},o);return{options:c,post:i.bind(null,"POST"),put:i.bind(null,"PUT"),patch:i.bind(null,"PATCH"),get:(e,n)=>i("GET",e,null,n),delete:(e,n)=>i("DELETE",e,null,n)}},e.nuxtWrap=function(e,n){const t=n.length;return function(){let s=e,o=Array.from(arguments);if(arguments.length===t){s=Object.assign({},e);const[n]=o.splice(0,1);n(s),s.options.headers=Object.assign({},s.options.headers)}return n.call(null,s,...o)}},e}({}); |
{ | ||
"name": "mande", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Some awesome description", | ||
@@ -33,2 +33,4 @@ "main": "dist/mande.common.js", | ||
"dist/mande.d.ts", | ||
"nuxt/*.js", | ||
"nuxt/types.d.js", | ||
"README.md" | ||
@@ -58,2 +60,3 @@ ], | ||
"@microsoft/api-extractor": "^7.8.0", | ||
"@nuxt/types": "^2.13.3", | ||
"@rollup/plugin-alias": "^3.0.0", | ||
@@ -60,0 +63,0 @@ "@rollup/plugin-replace": "^2.2.1", |
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
29804
11
514
23