Comparing version 0.0.9 to 0.0.10
@@ -0,1 +1,7 @@ | ||
## [0.0.10](https://github.com/posva/mande/compare/v0.0.9...v0.0.10) (2020-06-26) | ||
### Features | ||
- allow fetch polyfill ([a6bb3f4](https://github.com/posva/mande/commit/a6bb3f4859bb7629382b88091a32bb29fa15f695)) | ||
## [0.0.9](https://github.com/posva/mande/compare/v0.0.8...v0.0.9) (2020-06-25) | ||
@@ -2,0 +8,0 @@ |
/*! | ||
* mande v0.0.8 | ||
* mande v0.0.9 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -49,3 +49,3 @@ * @license MIT | ||
*/ | ||
function mande(baseURL, passedInstanceOptions = {}) { | ||
function mande(baseURL, passedInstanceOptions = {}, fetchPolyfill) { | ||
function _fetch(method, urlOrData, dataOrOptions, localOptions = {}) { | ||
@@ -73,3 +73,3 @@ let url; | ||
mergedOptions.body = JSON.stringify(data); | ||
return fetch(url, mergedOptions).then((response) => { | ||
return localFetch(url, mergedOptions).then((response) => { | ||
if (response.status >= 200 && response.status < 300) { | ||
@@ -85,2 +85,6 @@ if (responseAs === '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({ headers: {} }, passedInstanceOptions); | ||
@@ -87,0 +91,0 @@ return { |
@@ -25,3 +25,3 @@ | ||
*/ | ||
export declare function mande(baseURL: string, passedInstanceOptions?: Options): MandeInstance; | ||
export declare function mande(baseURL: string, passedInstanceOptions?: Options, fetchPolyfill?: Window['fetch']): MandeInstance; | ||
@@ -28,0 +28,0 @@ /** |
/*! | ||
* mande v0.0.8 | ||
* mande v0.0.9 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -45,3 +45,3 @@ * @license MIT | ||
*/ | ||
function mande(baseURL, passedInstanceOptions = {}) { | ||
function mande(baseURL, passedInstanceOptions = {}, fetchPolyfill) { | ||
function _fetch(method, urlOrData, dataOrOptions, localOptions = {}) { | ||
@@ -69,3 +69,3 @@ let url; | ||
mergedOptions.body = JSON.stringify(data); | ||
return fetch(url, mergedOptions).then((response) => { | ||
return localFetch(url, mergedOptions).then((response) => { | ||
if (response.status >= 200 && response.status < 300) { | ||
@@ -81,2 +81,6 @@ if (responseAs === '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({ headers: {} }, passedInstanceOptions); | ||
@@ -83,0 +87,0 @@ return { |
/*! | ||
* mande v0.0.8 | ||
* mande v0.0.9 | ||
* (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={}){function r(o,r,c,i={}){let u,l;"object"==typeof r?(u="",l=r,i=c||{}):(u=r,l=c);let p=Object.assign(Object.assign(Object.assign(Object.assign({},n),a),{method:o}),i),b=Object.assign(Object.assign(Object.assign({},n.query),a.query),i.query),{responseAs:j}=p;return p.headers=Object.assign(Object.assign(Object.assign({},n.headers),a.headers),i.headers),u=function(n,s){return n.replace(e,"")+"/"+s.replace(t,"")}(s,"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),l&&(p.body=JSON.stringify(l)),fetch(u,p).then(e=>{if(e.status>=200&&e.status<300)return"response"===j?e:204==e.status?null:e[j]();let t=new Error(e.statusText);throw t.response=e,t})}const a=Object.assign({headers:{}},o);return{options:a,post:r.bind(null,"POST"),put:r.bind(null,"PUT"),patch:r.bind(null,"PATCH"),get:(e,t)=>r("GET",e,null,t),delete:(e,t)=>r("DELETE",e,null,t)}}export{n as defaults,s as mande}; | ||
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}; |
/*! | ||
* mande v0.0.8 | ||
* mande v0.0.9 | ||
* (c) 2020 Eduardo San Martin Morote | ||
@@ -48,3 +48,3 @@ * @license MIT | ||
*/ | ||
function mande(baseURL, passedInstanceOptions = {}) { | ||
function mande(baseURL, passedInstanceOptions = {}, fetchPolyfill) { | ||
function _fetch(method, urlOrData, dataOrOptions, localOptions = {}) { | ||
@@ -72,3 +72,3 @@ let url; | ||
mergedOptions.body = JSON.stringify(data); | ||
return fetch(url, mergedOptions).then((response) => { | ||
return localFetch(url, mergedOptions).then((response) => { | ||
if (response.status >= 200 && response.status < 300) { | ||
@@ -84,2 +84,6 @@ if (responseAs === '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({ headers: {} }, passedInstanceOptions); | ||
@@ -86,0 +90,0 @@ return { |
/*! | ||
* mande v0.0.8 | ||
* mande v0.0.9 | ||
* (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,r={}){function a(r,a,c,i={}){let u,l;"object"==typeof a?(u="",l=a,i=c||{}):(u=a,l=c);let p=Object.assign(Object.assign(Object.assign(Object.assign({},s),o),{method:r}),i),b=Object.assign(Object.assign(Object.assign({},s.query),o.query),i.query),{responseAs:j}=p;return p.headers=Object.assign(Object.assign(Object.assign({},s.headers),o.headers),i.headers),u=function(e,s){return e.replace(t,"")+"/"+s.replace(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),l&&(p.body=JSON.stringify(l)),fetch(u,p).then(e=>{if(e.status>=200&&e.status<300)return"response"===j?e:204==e.status?null:e[j]();let t=new Error(e.statusText);throw t.response=e,t})}const o=Object.assign({headers:{}},r);return{options:o,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 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}({}); |
{ | ||
"name": "mande", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Some awesome description", | ||
@@ -5,0 +5,0 @@ "main": "dist/mande.common.js", |
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
26108
440
10