Comparing version 2.0.5 to 2.0.6
@@ -0,1 +1,7 @@ | ||
## [2.0.6](https://github.com/posva/mande/compare/v2.0.5...v2.0.6) (2023-02-28) | ||
### Bug Fixes | ||
- work with test mocks ([4856726](https://github.com/posva/mande/commit/4856726b6d3c4e12e9cb36cd7900681607adcd52)) | ||
## [2.0.5](https://github.com/posva/mande/compare/v2.0.3...v2.0.5) (2023-02-27) | ||
@@ -2,0 +8,0 @@ |
/*! | ||
* mande v2.0.3 | ||
* mande v2.0.5 | ||
* (c) 2023 Eduardo San Martin Morote | ||
@@ -99,2 +99,7 @@ * @license MIT | ||
mergedOptions.body = JSON.stringify(data); | ||
// we check the localFetch here to account for global fetch polyfills and msw in tests | ||
const localFetch = typeof fetch != 'undefined' ? fetch : fetchPolyfill; | ||
if (!localFetch) { | ||
throw new Error('No fetch function exists. Make sure to include a polyfill on Node.js.'); | ||
} | ||
return localFetch(url, mergedOptions) | ||
@@ -123,6 +128,2 @@ .then((response) => | ||
} | ||
const localFetch = typeof fetch != 'undefined' ? fetch : fetchPolyfill; | ||
if (!localFetch) { | ||
throw new Error('No fetch function exists. Make sure to include a polyfill on Node.js.'); | ||
} | ||
const instanceOptions = Object.assign({ query: {}, headers: {} }, passedInstanceOptions); | ||
@@ -129,0 +130,0 @@ return { |
/*! | ||
* mande v2.0.3 | ||
* mande v2.0.5 | ||
* (c) 2023 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
var Mande=function(e){"use strict";let t=/^\/+/;const n={responseAs:"json",headers:{Accept:"application/json","Content-Type":"application/json"}};return e.defaults=n,e.mande=function(e,s={},r){function o(s,r,o,a={}){let u,l;"object"==typeof r?(u="",a=o||r||{},l=r):(u=r,l=o);let p=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),i),{method:s}),a),{headers:(d=Object.assign(Object.assign(Object.assign({},n.headers),i.headers),a.headers),Object.keys(d).reduce(((e,t)=>(null!=d[t]&&(e[t]=d[t]),e)),{}))});var d;let b=Object.assign(Object.assign(Object.assign({},n.query),i.query),a.query),{responseAs:f}=p;return u=function(e,n){return e+(n&&(e.endsWith("/")?n.replace(t,""):n.startsWith("/")?n:"/"+n))}(e,"number"==typeof u?""+u:u||""),u+=function(e){let t=Object.keys(e).map((t=>[t,e[t]].map(encodeURIComponent).join("="))).join("&");return t?"?"+t:""}(b),"P"===s[0]&&l&&(p.body=JSON.stringify(l)),c(u,p).then((e=>Promise.all([e,"response"===f?e:e[f]().catch((()=>null))]))).then((([e,t])=>{if(e.status>=200&&e.status<300)return"response"!==f&&204==e.status?null:t;let n=new Error(e.statusText);throw n.response=e,n.body=t,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 i=Object.assign({query:{},headers:{}},s);return{options:i,post:o.bind(null,"POST"),put:o.bind(null,"PUT"),patch:o.bind(null,"PATCH"),get:(e,t)=>o("GET",e,null,t),delete:(e,t)=>o("DELETE",e,null,t)}},e.nuxtWrap=function(e,t){const n=t.length;return function(){let s=e,r=Array.from(arguments);if(arguments.length===n){s=Object.assign({},e);const[t]=r.splice(0,1);t(s)}return t.call(null,s,...r)}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var Mande=function(e){"use strict";let t=/^\/+/;const n={responseAs:"json",headers:{Accept:"application/json","Content-Type":"application/json"}};return e.defaults=n,e.mande=function(e,s={},r){function o(s,o,i,a={}){let u,l;"object"==typeof o?(u="",a=i||o||{},l=o):(u=o,l=i);let p=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),c),{method:s}),a),{headers:(d=Object.assign(Object.assign(Object.assign({},n.headers),c.headers),a.headers),Object.keys(d).reduce(((e,t)=>(null!=d[t]&&(e[t]=d[t]),e)),{}))});var d;let b=Object.assign(Object.assign(Object.assign({},n.query),c.query),a.query),{responseAs:f}=p;u=function(e,n){return e+(n&&(e.endsWith("/")?n.replace(t,""):n.startsWith("/")?n:"/"+n))}(e,"number"==typeof u?""+u:u||""),u+=function(e){let t=Object.keys(e).map((t=>[t,e[t]].map(encodeURIComponent).join("="))).join("&");return t?"?"+t:""}(b),"P"===s[0]&&l&&(p.body=JSON.stringify(l));const j="undefined"!=typeof fetch?fetch:r;if(!j)throw new Error("No fetch function exists. Make sure to include a polyfill on Node.js.");return j(u,p).then((e=>Promise.all([e,"response"===f?e:e[f]().catch((()=>null))]))).then((([e,t])=>{if(e.status>=200&&e.status<300)return"response"!==f&&204==e.status?null:t;let n=new Error(e.statusText);throw n.response=e,n.body=t,n}))}const c=Object.assign({query:{},headers:{}},s);return{options:c,post:o.bind(null,"POST"),put:o.bind(null,"PUT"),patch:o.bind(null,"PATCH"),get:(e,t)=>o("GET",e,null,t),delete:(e,t)=>o("DELETE",e,null,t)}},e.nuxtWrap=function(e,t){const n=t.length;return function(){let s=e,r=Array.from(arguments);if(arguments.length===n){s=Object.assign({},e);const[t]=r.splice(0,1);t(s)}return t.call(null,s,...r)}},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
{ | ||
"name": "mande", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "Some awesome description", | ||
@@ -5,0 +5,0 @@ "packageManager": "pnpm@7.28.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
52059
836