diff --git a/CHANGELOG.md b/CHANGELOG.md index a76d0aa..0fd3fe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ + +## [2.9.1](https://github.com/elbywan/wretch/compare/2.9.0...2.9.1) (2024-09-06) + + +### :arrow_up: Version update(s) + +* Bump braces from 3.0.2 to 3.0.3 ([a50cdf6](https://github.com/elbywan/wretch/commit/a50cdf6)) +* Bump ws and socket.io ([c615396](https://github.com/elbywan/wretch/commit/c615396)) + +### :art: Code improvement(s) + +* Enhance errorType and allow disabling it ([cfd45a9](https://github.com/elbywan/wretch/commit/cfd45a9)) +* Replace tslint with eslint ([661865a](https://github.com/elbywan/wretch/commit/661865a)) +* Replace URL.canParse with a try/catch block ([f6fc851](https://github.com/elbywan/wretch/commit/f6fc851)), closes [#244](https://github.com/elbywan/wretch/issues/244) + +### :memo: Documentation update(s) + +* Regenerate api docs ([bc1f570](https://github.com/elbywan/wretch/commit/bc1f570)) +* Replace bundlephobia badge with bundlejs ([b9f27a7](https://github.com/elbywan/wretch/commit/b9f27a7)) + + + # [2.9.0](https://github.com/elbywan/wretch/compare/2.8.1...2.9.0) (2024-06-01) @@ -14,7 +36,7 @@ ### :factory: New feature(s) * Add BasicAuth addon ([ad5b591](https://github.com/elbywan/wretch/commit/ad5b591)) -* Omit null and undefined values from query string produced by QueryStringAddon ([6c7fcc7](https://github.com/elbywan/wretch/pull/230/commits/6c7fcc7)), closes [#229](https://github.com/elbywan/wretch/issues/229) + @@ -376,7 +398,40 @@ -# [2.0.0-next.1](https://github.com/elbywan/wretch/compare/1.7.10...2.0.0-next.1) (2022-07-08) +# [2.0.0-next.1](https://github.com/elbywan/wretch/compare/2.0.0-next.0...2.0.0-next.1) (2022-07-08) + + +### :art: Code improvement(s) + +* Add editorconfig ([e81eaff](https://github.com/elbywan/wretch/commit/e81eaff)) + +### :fire: Breaking change(s) + +* Drop support on node < 14 ([1ff926c](https://github.com/elbywan/wretch/commit/1ff926c)) + +### :memo: Documentation update(s) + +* Additional improvements ([e79ff71](https://github.com/elbywan/wretch/commit/e79ff71)) +* Autogenerate API documentation and split it from the main README ([c710a71](https://github.com/elbywan/wretch/commit/c710a71)) +* Move svg asset and minor readme changes ([30de07c](https://github.com/elbywan/wretch/commit/30de07c)) +* Regenerate api doc ([7ae5b57](https://github.com/elbywan/wretch/commit/7ae5b57)) +* Small edits to the contributing file and renames scripts related t ([abec7f0](https://github.com/elbywan/wretch/commit/abec7f0)) +* Update bundle size ([1115d34](https://github.com/elbywan/wretch/commit/1115d34)) +* Update companion website ([d6bb842](https://github.com/elbywan/wretch/commit/d6bb842)) +* Update documentation ([15fd187](https://github.com/elbywan/wretch/commit/15fd187)) + +### :white_check_mark: Test improvement(s) + +* Fix resolvers test for node14 ([ca8b559](https://github.com/elbywan/wretch/commit/ca8b559)) +* Fix test on node 18 (with polyfilled fetch) ([d3b7b00](https://github.com/elbywan/wretch/commit/d3b7b00)) +* Replace restify with fastify for mock server ([9ee2cfc](https://github.com/elbywan/wretch/commit/9ee2cfc)) +* Run lint on CI ([9b819d3](https://github.com/elbywan/wretch/commit/9b819d3)) +* Test in multiple version of node in CI ([00d80a6](https://github.com/elbywan/wretch/commit/00d80a6)) + + + + +# [2.0.0-next.0](https://github.com/elbywan/wretch/compare/1.7.10...2.0.0-next.0) (2022-07-03) ### :arrow_up: Version update(s) @@ -385,7 +440,6 @@ ### :art: Code improvement(s) -* Add editorconfig ([e81eaff](https://github.com/elbywan/wretch/commit/e81eaff)) * Improved packaging and bundling ([69c1e35](https://github.com/elbywan/wretch/commit/69c1e35)) ### :bug: Bug fix(es) @@ -405,29 +459,15 @@ * Add url arg and harmonize replace/mixin arguments ([8e4d0aa](https://github.com/elbywan/wretch/commit/8e4d0aa)) * Complete refactoring ([c2f5035](https://github.com/elbywan/wretch/commit/c2f5035)) -* Drop support on node < 14 ([1ff926c](https://github.com/elbywan/wretch/commit/1ff926c)) * Restore normal array behaviour for formdata and fix tests ([6879d48](https://github.com/elbywan/wretch/commit/6879d48)), closes [#119](https://github.com/elbywan/wretch/issues/119) ### :memo: Documentation update(s) -* Additional improvements ([e79ff71](https://github.com/elbywan/wretch/commit/e79ff71)) -* Autogenerate API documentation and split it from the main README ([c710a71](https://github.com/elbywan/wretch/commit/c710a71)) -* Move svg asset and minor readme changes ([30de07c](https://github.com/elbywan/wretch/commit/30de07c)) -* Regenerate api doc ([7ae5b57](https://github.com/elbywan/wretch/commit/7ae5b57)) -* Small edits to the contributing file and renames scripts related t ([abec7f0](https://github.com/elbywan/wretch/commit/abec7f0)) * Update browserstack badge. ([91cad34](https://github.com/elbywan/wretch/commit/91cad34)) -* Update bundle size ([1115d34](https://github.com/elbywan/wretch/commit/1115d34)) -* Update companion website ([d6bb842](https://github.com/elbywan/wretch/commit/d6bb842)) -* Update documentation ([15fd187](https://github.com/elbywan/wretch/commit/15fd187)) ### :white_check_mark: Test improvement(s) * Better tests coverage ([77e85dc](https://github.com/elbywan/wretch/commit/77e85dc)) -* Fix resolvers test for node14 ([ca8b559](https://github.com/elbywan/wretch/commit/ca8b559)) -* Fix test on node 18 (with polyfilled fetch) ([d3b7b00](https://github.com/elbywan/wretch/commit/d3b7b00)) -* Replace restify with fastify for mock server ([9ee2cfc](https://github.com/elbywan/wretch/commit/9ee2cfc)) -* Run lint on CI ([9b819d3](https://github.com/elbywan/wretch/commit/9b819d3)) -* Test in multiple version of node in CI ([00d80a6](https://github.com/elbywan/wretch/commit/00d80a6)) diff --git a/docs/api/assets/main.js b/docs/api/assets/main.js index 3572881..21a5d74 100644 --- a/docs/api/assets/main.js +++ b/docs/api/assets/main.js @@ -3,7 +3,7 @@ window.translations={"copy":"Copy","copied":"Copied!","normally_hidden":"This me "use strict";(()=>{var Pe=Object.create;var ie=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var De=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _e(e))!Me.call(t,i)&&i!==n&&ie(t,i,{get:()=>e[i],enumerable:!(r=Oe(e,i))||r.enumerable});return t};var Ae=(t,e,n)=>(n=t!=null?Pe(Re(t)):{},De(e||!t||!t.__esModule?ie(n,"default",{value:t,enumerable:!0}):n,t));var ue=Fe((ae,le)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. `,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r1&&(oe&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof ae=="object"?le.exports=n():e.lunr=n()}(this,function(){return t})})()});var se=[];function G(t,e){se.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){se.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!Ve(e)){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r,document.querySelector(".col-sidebar").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(!n)return;let r=n.offsetParent==null,i=n;for(;i!==document.body;)i instanceof HTMLDetailsElement&&(i.open=!0),i=i.parentElement;if(n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let s=document.createElement("p");s.classList.add("warning"),s.textContent=window.translations.normally_hidden,n.prepend(s)}r&&e.scrollIntoView()}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent=window.translations.copied,e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent=window.translations.copy},100)},1e3)})})}};function Ve(t){let e=t.getBoundingClientRect(),n=Math.max(document.documentElement.clientHeight,window.innerHeight);return!(e.bottom<0||e.top-n>=0)}var oe=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var pe=Ae(ue());async function ce(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=pe.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function fe(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{ce(e,t)}),ce(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{te(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),He(t,i,r,e)}function He(t,e,n,r){n.addEventListener("input",oe(()=>{Ne(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?Be(e,t):i.key=="ArrowUp"?(de(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(de(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),te(t))})}function te(t){t.classList.remove("has-focus")}function Ne(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o`,d=he(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=` ${he(l.parent,i)}.${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function de(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function Be(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),te(e)}}function he(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(ee(t.substring(s,o)),`${ee(t.substring(o,o+r.length))}`),s=o+r.length,o=n.indexOf(r,s);return i.push(ee(t.substring(s))),i.join("")}var je={"&":"&","<":"<",">":">","'":"'",'"':"""};function ee(t){return t.replace(/[&<>"'"]/g,e=>je[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",ye="mousemove",N="mouseup",J={x:0,y:0},me=!1,ne=!1,qe=!1,D=!1,ve=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(ve?"is-mobile":"not-mobile");ve&&"ontouchstart"in document.documentElement&&(qe=!0,F="touchstart",ye="touchmove",N="touchend");document.addEventListener(F,t=>{ne=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(ye,t=>{if(ne&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(N,()=>{ne=!1});document.addEventListener("click",t=>{me&&(t.preventDefault(),t.stopImmediatePropagation(),me=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(N,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(N,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var re;try{re=localStorage}catch{re={getItem(){return null},setItem(){}}}var Q=re;var ge=document.head.appendChild(document.createElement("style"));ge.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ge.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } -`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function Ee(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,xe(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),xe(t.value)})}function xe(t){document.documentElement.dataset.theme=t}var K;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Le),Le())}async function Le(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();K=t.dataset.base,K.endsWith("/")||(K+="/"),t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',be(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else be(t,r,t.class)}function be(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=K+t.path,n&&(r.className=n),location.pathname===r.pathname&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&Ee(Te);var $e=new U;Object.defineProperty(window,"app",{value:$e});fe();we();})(); +`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function Ee(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,xe(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),xe(t.value)})}function xe(t){document.documentElement.dataset.theme=t}var K;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Le),Le())}async function Le(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();K=t.dataset.base,K.endsWith("/")||(K+="/"),t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',be(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else be(t,r,t.class)}function be(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=K+t.path,n&&(r.className=n),location.pathname===r.pathname&&!r.href.includes("#")&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else e.appendChild(document.createElement("span")).textContent=t.text}G(X,"a[data-toggle]");G(Z,".tsd-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&Ee(Te);var $e=new U;Object.defineProperty(window,"app",{value:$e});fe();we();})(); /*! Bundled license information: lunr/lunr.js: diff --git a/docs/api/assets/navigation.js b/docs/api/assets/navigation.js index b4b754f..7ac040b 100644 --- a/docs/api/assets/navigation.js +++ b/docs/api/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE62Wb2/TMBDGv0teV/wpbIi+Gx2TEKBBR8WLaZrc+NJYdZ3gOGUV2ndHidvEdu34ou5t/dzv/Fzuzr3/lyh4UsksIZQWokomSUlUnsySbUFrDtVr/furXG15Mkk2TNBkNp0kac44lSCS2X2PWBVShQiP7SmKc9UoF1AVfAey5zGhQGYkdZGW3Elwcfk8sbm/Jag0R1K1eIhJISM1N1xntUgVK4SDO+hs1OX75weDtSIVS69qlQdr2ClQdfx0VF810UOWe64dM8r5jkhGVt7bet2/m1rus0Jur4kiQfNHAcr7zUEctd5RrYjzjHdMrO+l5IO2l5KjXS8lR5lumKb+fMsNEeO4BJkFN81je4py+6NRRr1qXq8d8tmo5oTzFUk3PVPtSx/uKHSAbz5+eHsxHbUiNBOzIkpZrCVUA9U7CHAFPIgxu7YDu0HnbccOi3H/pwa5v1OSiXWwAIYGVYOfvT7aSibbjTtvfExyeITMWjBB4em0Cu3PKOMDD6GGxB8/rfgsZeFvHZPTquKwBVRlISqY54T5v4UJtdRD8HkhMrZ2R1qj9FlsirWqlkC/M0o5/CUShni2Mka/adx8Y5sAsjuOcWJ3w99IF9gZCRNlCHCsa8hASqChBWtiXS0uQ9tjGLwlxLFvy3ZvDVEPEhzv2LpDwKPmjBdG4zDLddu1hud1MQ5Ry4UCrUsY5DxqDQp33Uq/wv7mYMytmod7EhOrog4IT1AwB36otD7QSkE+sq+0+Pgsj66UG4hLd7dh5ehUZlC8t+1O6lvbg/e1lNPmFDjZxxqTkz2yLznZYzumgToBcfPWZUPeG7Ln0o5zCUpGnLcSvPMF2aI+vsaehMTc34pFE4jP4ASM5Ic2cjQPdk23Qbhu0XmcABQfsVwMOHK1YKdck8eM91IoxvFoSx5jOw3vnx7N9TS+Mz0ql4VSnIn1nKR55GlzxKiJ+mXHzDkQ1BJ3cw1xYhVzYwtBWRP3EvdwWSPv8kXsCGeUKHiBy5zCRt4G+Vckco0Rf06cSNwWiaTHbxYnELFjIqmRe8eJwq6hSPIx+yk49v5t4mYeXATthnl4fvgP4UWWi4UXAAA=" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAE6WX227bMAyG38W9zQ5t0w7NXZeuwLAN3doFuyiKQImVRIhiZ7LSNRj67oOt2NGJEjXfJj8/ijRJUY9/M0lfZDbKSJ6XRZUNsi2Rq2yUbcp8x2n1Tv3+diU3PBtka1bk2ehskM1XjOeCFtnosUNcz0oh72lV8mcqgqQTW6q4w9Or4fn74evARP4SVM5XCGAnhHAfScXm1zu5uq5Nw0RHC0FvS7G5IZIgmLY0hJwIjiRqSgj4nYpFhcAZOhAmyqWgVYX71B41BP6xo2L/IAUrloizetQQmNTVgUAaOgg2SygiU/vmNIBd4MvIkEahuELSlUHkFllKR10YdygPDNGSQsjfSWVkq4OnbQoE4k2bf/uMSlZIKhZkbiMNueXg4jI2L4NUJQ4xc7ogO65FvdgVc8nKwsIddCbqcvj65OsdMIedApVHaKC7IR+5pk1S5M9EMDLzntYb/fmZEX3bt2DwrQAVO3DvuKF3VMOiX+AdExv3RPBg2BPB0VG7E80fdM3U9f1DromYiJvhB8bb/IuK1ndvu7Eq3lEbirNWjQnnMzJfH5lyv/XhWqEFfH/14fTiLGlEKCZmRLRTHs7eQYBLILireNLYgm2jftOxw2Ki124jMAGaBpUDeK1yc6Czbbt+7aOT4RbSc8GKnL64WWh+RgUeuAgVJH75KcUnIUp/6eicRhWH3dNqWxYVHa8I838LHWqoQ/BxWSzY0m5phVL/xbpYqXaC5t9YnnP6hwga4pnKGP22juYrWwPI7u8YJ3Y2/IlUgq2W0FGaAMe6oQsqBM2hAatjbS3OQ1NjGLwhxLHvts3cClEPEhyvLd0QsNX0uGEUDjNcN11peG4X7U/UcLmh+W5Lv9D97eEkceSJzwZ6aiitr9ojeMMkTHe+eAR91Ie57cWZnBqPYdjTw5ptk71YRrAHTvaJH8C2CLLvySbt8K4NxL8r7qkUKbXpWiDZbptjfWiWkK9Gn/QNXIsgG98ClhyiJlYkshZ/rkQpJWfFckzmKzrmlKR0V8Qc67Usclab9PDsQSC9fy6eCWc5kfT/3XsZSP9poz5ojPSYVPchW6Q/fC+AhkhPiU0StoZ8TgrJeIIXWw9x8+YSQQA7IUziZI8CKR3EEfVoQnBaHcSRZp4RRNeiR9amStN3/VJbpofr2MS2TngHi/jAP0KARSzCR+7hsW0s4sU2xLnz93bElW4UfwuYlXR8CnjwvpKyngXxLpw2EmRdAkujLwE11DKIB28cFoq9JnsObUUenxvTRoKP3L/SurErrGMSix5cayEPlkEiH3rBRv1gn7Xgegv5sQxQfMRw0eDI0YLtckVOaW/g2obQhjzGtgre3z2K6yl8q3tSbsupJUZ1FG7pdxNj+wpxYhnDPwHSz2GzEs8SehAkH8aFJZ4GuYpEjpGwnCAeC8nu8ZMl9nRIdo2cO6iHRLLzlPkEtr1/mtieg4OgmTBPr0//AFxyWgSYJQAA" \ No newline at end of file diff --git a/docs/api/functions/addons_abort.default.html b/docs/api/functions/addons_abort.default.html index 43a4e03..e685171 100644 --- a/docs/api/functions/addons_abort.default.html +++ b/docs/api/functions/addons_abort.default.html @@ -6,4 +6,4 @@
import AbortAddon from "wretch/addons/abort"

const [c, w] = wretch("...")
.addon(AbortAddon())
.get()
.onAbort((_) => console.log("Aborted !"))
.controller();

w.text((_) => console.log("should never be called"));
c.abort();

// Or :

const controller = new AbortController();

wretch("...")
.addon(AbortAddon())
.signal(controller)
.get()
.onAbort((_) => console.log("Aborted !"))
.text((_) => console.log("should never be called"));

controller.abort();
-
+
diff --git a/docs/api/functions/addons_perfs.default.html b/docs/api/functions/addons_perfs.default.html index 1469231..ffd6072 100644 --- a/docs/api/functions/addons_perfs.default.html +++ b/docs/api/functions/addons_perfs.default.html @@ -11,4 +11,4 @@
// Node.js only
const { performance, PerformanceObserver } = require("perf_hooks");

wretch.polyfills({
fetch: function (url, opts) {
performance.mark(url + " - begin");
return fetch(url, opts).then(res => {
performance.mark(url + " - end");
setTimeout(() => performance.measure(res.url, url + " - begin", url + " - end"), 0);
return res;
});
},
// other polyfills…
performance: performance,
PerformanceObserver: PerformanceObserver,
});
-
+
diff --git a/docs/api/functions/addons_progress.default.html b/docs/api/functions/addons_progress.default.html index e395b4d..5a11cf3 100644 --- a/docs/api/functions/addons_progress.default.html +++ b/docs/api/functions/addons_progress.default.html @@ -3,4 +3,4 @@
import ProgressAddon from "wretch/addons/progress"

wretch("some_url")
// Register the addon
.addon(ProgressAddon())
.get()
// Log the progress as a percentage of completion
.progress((loaded, total) => console.log(`${(loaded / total * 100).toFixed(0)}%`))
-
+
diff --git a/docs/api/functions/index.default.html b/docs/api/functions/index.default.html index b35ef60..6c0ef70 100644 --- a/docs/api/functions/index.default.html +++ b/docs/api/functions/index.default.html @@ -6,12 +6,12 @@

Parameters

  • _url: string = ""

    The base url

  • _options: {} = {}

    The base fetch options

    Returns Wretch

    A fresh wretch instance

    -

    Properties

    Properties

    WretchError: typeof WretchError
    default: typeof default
    errorType: ((errorType: ErrorType) => void)

    {@inheritDoc setErrorType}

    +

    Properties

    WretchError: typeof WretchError
    default: typeof default
    errorType: ((errorType: ErrorType) => void)

    {@inheritDoc setErrorType}

    Type declaration

      • (errorType): void
      • Sets the default method (text, json, …) used to parse the data contained in the response body in case of an HTTP error. As with other static methods, it will affect wretch instances created after calling this function.

        Note: if the response Content-Type header is set to "application/json", the body will be parsed as json regardless of the errorType.

        @@ -19,14 +19,14 @@

        If null, defaults to "text".

        -

        Parameters

        • errorType: ErrorType

        Returns void

    options: ((options: object, replace?: boolean) => void)

    {@inheritDoc setOptions}

    +

    Parameters

    • errorType: ErrorType

    Returns void

    options: ((options: object, replace?: boolean) => void)

    {@inheritDoc setOptions}

    Type declaration

      • (options, replace?): void
      • Sets the default fetch options that will be stored internally when instantiating wretch objects.

        import wretch from "wretch"

        wretch.options({ headers: { "Accept": "application/json" } });

        // The fetch request is sent with both headers.
        wretch("...", { headers: { "X-Custom": "Header" } }).get().res();

        Parameters

        • options: object

          Default options

        • replace: boolean = false

          If true, completely replaces the existing options instead of mixing in

          -

        Returns void

    polyfills: ((polyfills: object, replace?: boolean) => void)

    {@inheritDoc setPolyfills}

    +

    Returns void

    polyfills: ((polyfills: object, replace?: boolean) => void)

    {@inheritDoc setPolyfills}

    Type declaration

      • (polyfills, replace?): void
      • Sets the default polyfills that will be stored internally when instantiating wretch objects. Useful for browserless environments like node.js.

        Needed for libraries like fetch-ponyfill.

        @@ -35,4 +35,4 @@

        Parameters

        • polyfills: object

          An object containing the polyfills

        • replace: boolean = false

          If true, replaces the current polyfills instead of mixing in

          -

        Returns void

    +

    Returns void

    diff --git a/docs/api/functions/middlewares_dedupe.dedupe.html b/docs/api/functions/middlewares_dedupe.dedupe.html index 0c47eaa..9ea9b22 100644 --- a/docs/api/functions/middlewares_dedupe.dedupe.html +++ b/docs/api/functions/middlewares_dedupe.dedupe.html @@ -1 +1 @@ -dedupe | wretch
    +dedupe | wretch
    diff --git a/docs/api/functions/middlewares_delay.delay.html b/docs/api/functions/middlewares_delay.delay.html index bd8cc8d..2aa86ee 100644 --- a/docs/api/functions/middlewares_delay.delay.html +++ b/docs/api/functions/middlewares_delay.delay.html @@ -1 +1 @@ -delay | wretch
    +delay | wretch
    diff --git a/docs/api/functions/middlewares_retry.retry.html b/docs/api/functions/middlewares_retry.retry.html index 64c6043..886d937 100644 --- a/docs/api/functions/middlewares_retry.retry.html +++ b/docs/api/functions/middlewares_retry.retry.html @@ -1 +1 @@ -retry | wretch
    +retry | wretch
    diff --git a/docs/api/functions/middlewares_throttlingCache.throttlingCache.html b/docs/api/functions/middlewares_throttlingCache.throttlingCache.html index b42733b..13aefea 100644 --- a/docs/api/functions/middlewares_throttlingCache.throttlingCache.html +++ b/docs/api/functions/middlewares_throttlingCache.throttlingCache.html @@ -1 +1 @@ -throttlingCache | wretch
    +throttlingCache | wretch
    diff --git a/docs/api/interfaces/addons_abort.AbortResolver.html b/docs/api/interfaces/addons_abort.AbortResolver.html index 44f2315..d35ec1e 100644 --- a/docs/api/interfaces/addons_abort.AbortResolver.html +++ b/docs/api/interfaces/addons_abort.AbortResolver.html @@ -1,16 +1,16 @@ -AbortResolver | wretch

    Interface AbortResolver

    interface AbortResolver {
        controller: (<T, C, R>(this: C & WretchResponseChain<T, C, R>) => [any, AbortResolver]);
        onAbort: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb: WretchErrorCallback<T, C, R>) => this);
        setTimeout: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, time: number, controller?: AbortController) => this);
    }

    Properties

    controller +AbortResolver | wretch

    Interface AbortResolver

    interface AbortResolver {
        controller: (<T, C, R>(this: C & WretchResponseChain<T, C, R>) => [any, AbortResolver]);
        onAbort: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb: WretchErrorCallback<T, C, R>) => this);
        setTimeout: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, time: number, controller?: AbortController) => this);
    }

    Properties

    controller: (<T, C, R>(this: C & WretchResponseChain<T, C, R>) => [any, AbortResolver])

    Returns the provided or generated AbortController plus the wretch response chain as a pair.

    // We need the controller outside the chain
    const [c, w] = wretch("url")
    .addon(AbortAddon())
    .get()
    .controller()

    // Resume with the chain
    w.onAbort(_ => console.log("ouch")).json()

    // Later on…
    c.abort()
    -
    onAbort: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb: WretchErrorCallback<T, C, R>) => this)

    Catches an AbortError and performs a callback.

    -
    setTimeout: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, time: number, controller?: AbortController) => this)

    Aborts the request after a fixed time.

    +
    onAbort: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb: WretchErrorCallback<T, C, R>) => this)

    Catches an AbortError and performs a callback.

    +
    setTimeout: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, time: number, controller?: AbortController) => this)

    Aborts the request after a fixed time.

    If you use a custom AbortController associated with the request, pass it as the second argument.

    // 1 second timeout
    wretch("...").addon(AbortAddon()).get().setTimeout(1000).json(_ =>
    // will not be called if the request timeouts
    )

    Type declaration

      • <T, C, R>(this, time, controller?): this
      • Type Parameters

        Parameters

        • this: C & WretchResponseChain<T, C, R>
        • time: number

          Time in milliseconds

        • Optionalcontroller: AbortController

          An instance of AbortController

          -

        Returns this

    +

    Returns this

    diff --git a/docs/api/interfaces/addons_abort.AbortWretch.html b/docs/api/interfaces/addons_abort.AbortWretch.html index 14dab34..16cb5fc 100644 --- a/docs/api/interfaces/addons_abort.AbortWretch.html +++ b/docs/api/interfaces/addons_abort.AbortWretch.html @@ -1,4 +1,4 @@ -AbortWretch | wretch

    Interface AbortWretch

    interface AbortWretch {
        signal: (<T, C, R>(this: T & Wretch<T, C, R>, controller: AbortController) => this);
    }

    Properties

    signal +AbortWretch | wretch

    Interface AbortWretch

    interface AbortWretch {
        signal: (<T, C, R>(this: T & Wretch<T, C, R>, controller: AbortController) => this);
    }

    Properties

    Properties

    signal: (<T, C, R>(this: T & Wretch<T, C, R>, controller: AbortController) => this)

    Associates a custom controller with the request.

    Useful when you need to use your own AbortController, otherwise wretch will create a new controller itself.

    @@ -6,4 +6,4 @@

    Type declaration

      • <T, C, R>(this, controller): this
      • Type Parameters

        Parameters

        • this: T & Wretch<T, C, R>
        • controller: AbortController

          An instance of AbortController

          -

        Returns this

    +

    Returns this

    diff --git a/docs/api/interfaces/addons_basicAuth.BasicAuthAddon.html b/docs/api/interfaces/addons_basicAuth.BasicAuthAddon.html index d6d2ce1..cb6f16d 100644 --- a/docs/api/interfaces/addons_basicAuth.BasicAuthAddon.html +++ b/docs/api/interfaces/addons_basicAuth.BasicAuthAddon.html @@ -1,4 +1,4 @@ -BasicAuthAddon | wretch

    Interface BasicAuthAddon

    interface BasicAuthAddon {
        basicAuth<T, C, R>(this: T & Wretch<T, C, R>, username: string, password: string): this;
    }

    Methods

    basicAuth +BasicAuthAddon | wretch

    Interface BasicAuthAddon

    interface BasicAuthAddon {
        basicAuth<T, C, R>(this: T & Wretch<T, C, R>, username: string, password: string): this;
    }

    Methods

    Methods

    • Sets the Authorization header to Basic + . Additionally, allows using URLs with credentials in them.

      const user = "user"
      const pass = "pass"

      // Automatically sets the Authorization header to "Basic " + <base64 encoded credentials>
      wretch("...").addon(BasicAuthAddon).basicAuth(user, pass).get()

      // Allows using URLs with credentials in them
      wretch(`https://${user}:${pass}@...`).addon(BasicAuthAddon).get() @@ -6,4 +6,4 @@

      Type Parameters

      Parameters

      • this: T & Wretch<T, C, R>
      • username: string

        Username to use for basic auth

      • password: string

        Password to use for basic auth

        -

      Returns this

    +

    Returns this

    diff --git a/docs/api/interfaces/addons_formData.FormDataAddon.html b/docs/api/interfaces/addons_formData.FormDataAddon.html index dc7ee13..3082679 100644 --- a/docs/api/interfaces/addons_formData.FormDataAddon.html +++ b/docs/api/interfaces/addons_formData.FormDataAddon.html @@ -1,4 +1,4 @@ -FormDataAddon | wretch

    Interface FormDataAddon

    interface FormDataAddon {
        formData<T, C, R>(this: T & Wretch<T, C, R>, formObject: object, recursive?: boolean | string[]): this;
    }

    Methods

    formData +FormDataAddon | wretch

    Interface FormDataAddon

    interface FormDataAddon {
        formData<T, C, R>(this: T & Wretch<T, C, R>, formObject: object, recursive?: boolean | string[]): this;
    }

    Methods

    Methods

    • Converts the javascript object to a FormData and sets the request body.

      const form = {
      hello: "world",
      duck: "Muscovy",
      };

      wretch("...").addons(FormDataAddon).formData(form).post();
      @@ -24,4 +24,4 @@

      Type Parameters

      Parameters

      • this: T & Wretch<T, C, R>
      • formObject: object

        An object which will be converted to a FormData

      • Optionalrecursive: boolean | string[]

        If true, will recurse through all nested objects. Can be set as an array of string to exclude specific keys.

        -

      Returns this

    +

    Returns this

    diff --git a/docs/api/interfaces/addons_formUrl.FormUrlAddon.html b/docs/api/interfaces/addons_formUrl.FormUrlAddon.html index f22c599..183b5d6 100644 --- a/docs/api/interfaces/addons_formUrl.FormUrlAddon.html +++ b/docs/api/interfaces/addons_formUrl.FormUrlAddon.html @@ -1,4 +1,4 @@ -FormUrlAddon | wretch

    Interface FormUrlAddon

    interface FormUrlAddon {
        formUrl<T, C, R>(this: T & Wretch<T, C, R>, input: string | object): this;
    }

    Methods

    formUrl +FormUrlAddon | wretch

    Interface FormUrlAddon

    interface FormUrlAddon {
        formUrl<T, C, R>(this: T & Wretch<T, C, R>, input: string | object): this;
    }

    Methods

    Methods

    • Converts the input parameter to an url encoded string and sets the content-type header and body. If the input argument is already a string, skips the conversion part.

      @@ -6,4 +6,4 @@

      Type Parameters

      Parameters

      • this: T & Wretch<T, C, R>
      • input: string | object

        An object to convert into an url encoded string or an already encoded string

        -

      Returns this

    +

    Returns this

    diff --git a/docs/api/interfaces/addons_perfs.PerfsAddon.html b/docs/api/interfaces/addons_perfs.PerfsAddon.html index f6d4d58..0ada5a6 100644 --- a/docs/api/interfaces/addons_perfs.PerfsAddon.html +++ b/docs/api/interfaces/addons_perfs.PerfsAddon.html @@ -1,4 +1,4 @@ -PerfsAddon | wretch

    Interface PerfsAddon

    interface PerfsAddon {
        perfs: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb?: PerfCallback) => this);
    }

    Properties

    perfs +PerfsAddon | wretch

    Interface PerfsAddon

    interface PerfsAddon {
        perfs: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb?: PerfCallback) => this);
    }

    Properties

    Properties

    perfs: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, cb?: PerfCallback) => this)

    Performs a callback on the API performance timings of the request.

    Warning: Still experimental on browsers and node.js

    -
    +
    diff --git a/docs/api/interfaces/addons_progress.ProgressResolver.html b/docs/api/interfaces/addons_progress.ProgressResolver.html index a1b558a..88aac77 100644 --- a/docs/api/interfaces/addons_progress.ProgressResolver.html +++ b/docs/api/interfaces/addons_progress.ProgressResolver.html @@ -1,4 +1,4 @@ -ProgressResolver | wretch

    Interface ProgressResolver

    interface ProgressResolver {
        progress: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, onProgress: ((loaded: number, total: number) => void)) => this);
    }

    Properties

    progress +ProgressResolver | wretch

    Interface ProgressResolver

    interface ProgressResolver {
        progress: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, onProgress: ((loaded: number, total: number) => void)) => this);
    }

    Properties

    Properties

    progress: (<T, C, R>(this: C & WretchResponseChain<T, C, R>, onProgress: ((loaded: number, total: number) => void)) => this)

    Provides a way to register a callback to be invoked one or multiple times during the download. The callback receives the current progress as two arguments, the number of bytes loaded and the total number of bytes to load.

    Under the hood: this method adds a middleware to the chain that will intercept the response and replace the body with a new one that will emit the progress event.

    @@ -6,4 +6,4 @@

    Type declaration

      • <T, C, R>(this, onProgress): this
      • Type Parameters

        Parameters

        • this: C & WretchResponseChain<T, C, R>
        • onProgress: ((loaded: number, total: number) => void)

          A callback that will be called one or multiple times with the number of bytes loaded and the total number of bytes to load.

          -
            • (loaded, total): void
            • Parameters

              • loaded: number
              • total: number

              Returns void

        Returns this

    +
      • (loaded, total): void
      • Parameters

        • loaded: number
        • total: number

        Returns void

    Returns this

    diff --git a/docs/api/interfaces/addons_queryString.QueryStringAddon.html b/docs/api/interfaces/addons_queryString.QueryStringAddon.html index 2e85f83..de07561 100644 --- a/docs/api/interfaces/addons_queryString.QueryStringAddon.html +++ b/docs/api/interfaces/addons_queryString.QueryStringAddon.html @@ -1,4 +1,4 @@ -QueryStringAddon | wretch
    interface QueryStringAddon {
        query<T, C, R>(this: T & Wretch<T, C, R>, qp: string | object, replace?: boolean, omitUndefinedOrNullValues?: boolean): this;
    }

    Methods

    query +QueryStringAddon | wretch
    interface QueryStringAddon {
        query<T, C, R>(this: T & Wretch<T, C, R>, qp: string | object, replace?: boolean, omitUndefinedOrNullValues?: boolean): this;
    }

    Methods

    Methods

    • Converts a javascript object to query parameters, then appends this query string to the current url. String values are used as the query string verbatim.

      Pass true as the second argument to replace existing query parameters. @@ -12,4 +12,4 @@

      Type Parameters

      Parameters

      • this: T & Wretch<T, C, R>
      • qp: string | object

        An object which will be converted, or a string which will be used verbatim.

        -
      • Optionalreplace: boolean
      • OptionalomitUndefinedOrNullValues: boolean

      Returns this

    +
  • Optionalreplace: boolean
  • OptionalomitUndefinedOrNullValues: boolean
  • Returns this

    diff --git a/docs/api/interfaces/index.Wretch.html b/docs/api/interfaces/index.Wretch.html index 2b0169d..5e7f4c8 100644 --- a/docs/api/interfaces/index.Wretch.html +++ b/docs/api/interfaces/index.Wretch.html @@ -3,7 +3,7 @@

    Immutability : almost every method of this class return a fresh Wretch object.

    -
    interface Wretch<Self, Chain, Resolver> {
        accept(this: Self & Wretch<Self, Chain, Resolver>, headerValue: string): this;
        addon<W, R>(addon: WretchAddon<W, R>): W & Self & Wretch<Self & W, Chain & R, Resolver>;
        auth(this: Self & Wretch<Self, Chain, Resolver>, headerValue: string): this;
        body(this: Self & Wretch<Self, Chain, Resolver>, contents: any): this;
        catcher(this: Self & Wretch<Self, Chain, Resolver>, errorId: string | number | symbol, catcher: ((error: WretchError, originalRequest: this) => any)): this;
        catcherFallback(this: Self & Wretch<Self, Chain, Resolver>, catcher: ((error: WretchError, originalRequest: this) => any)): this;
        content(this: Self & Wretch<Self, Chain, Resolver>, headerValue: string): this;
        defer<Clear>(this: Self & Wretch<Self, Chain, Resolver>, callback: WretchDeferredCallback<Self, Chain, Resolver>, clear?: Clear): this;
        delete(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        errorType(this: Self & Wretch<Self, Chain, Resolver>, method: ErrorType): this;
        fetch(this: Self & Wretch<Self, Chain, Resolver>, method?: string, url?: string, body?: any): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        get(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        head(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        headers(this: Self & Wretch<Self, Chain, Resolver>, headerValues: HeadersInit): this;
        json(this: Self & Wretch<Self, Chain, Resolver>, jsObject: object, contentType?: string): this;
        middlewares(this: Self & Wretch<Self, Chain, Resolver>, middlewares: ConfiguredMiddleware[], clear?: boolean): this;
        options(this: Self & Wretch<Self, Chain, Resolver>, options: WretchOptions, replace?: boolean): this;
        opts(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        patch(this: Self & Wretch<Self, Chain, Resolver>, body?: any, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        polyfills(this: Self & Wretch<Self, Chain, Resolver>, polyfills: object, replace?: boolean): this;
        post(this: Self & Wretch<Self, Chain, Resolver>, body?: any, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        put(this: Self & Wretch<Self, Chain, Resolver>, body?: any, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        resolve<ResolverReturn, Clear>(this: Self & Wretch<Self, Chain, Resolver>, resolver: ((chain: Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, undefined>
            : Clear extends true
                ? Chain & WretchResponseChain<Self, Chain, undefined>
                : Resolver, originalRequest: Self & Wretch<Self, Chain, Clear extends true
            ? undefined
            : Resolver>) => ResolverReturn), clear?: Clear): Self & Wretch<Self, Chain, ResolverReturn>;
        url(this: Self & Wretch<Self, Chain, Resolver>, url: string, replace?: boolean): this;
    }

    Type Parameters

    • Self = unknown
    • Chain = unknown
    • Resolver = undefined

    Body Types

    interface Wretch<Self, Chain, Resolver> {
        accept(this: Self & Wretch<Self, Chain, Resolver>, headerValue: string): this;
        addon<W, R>(addon: WretchAddon<W, R>): W & Self & Wretch<Self & W, Chain & R, Resolver>;
        auth(this: Self & Wretch<Self, Chain, Resolver>, headerValue: string): this;
        body(this: Self & Wretch<Self, Chain, Resolver>, contents: any): this;
        catcher(this: Self & Wretch<Self, Chain, Resolver>, errorId: string | number | symbol, catcher: ((error: WretchError, originalRequest: this) => any)): this;
        catcherFallback(this: Self & Wretch<Self, Chain, Resolver>, catcher: ((error: WretchError, originalRequest: this) => any)): this;
        content(this: Self & Wretch<Self, Chain, Resolver>, headerValue: string): this;
        defer<Clear>(this: Self & Wretch<Self, Chain, Resolver>, callback: WretchDeferredCallback<Self, Chain, Resolver>, clear?: Clear): this;
        delete(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        errorType(this: Self & Wretch<Self, Chain, Resolver>, method: ErrorType): this;
        fetch(this: Self & Wretch<Self, Chain, Resolver>, method?: string, url?: string, body?: any): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        get(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        head(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        headers(this: Self & Wretch<Self, Chain, Resolver>, headerValues: HeadersInit): this;
        json(this: Self & Wretch<Self, Chain, Resolver>, jsObject: object, contentType?: string): this;
        middlewares(this: Self & Wretch<Self, Chain, Resolver>, middlewares: ConfiguredMiddleware[], clear?: boolean): this;
        options(this: Self & Wretch<Self, Chain, Resolver>, options: WretchOptions, replace?: boolean): this;
        opts(this: Self & Wretch<Self, Chain, Resolver>, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        patch(this: Self & Wretch<Self, Chain, Resolver>, body?: any, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        polyfills(this: Self & Wretch<Self, Chain, Resolver>, polyfills: object, replace?: boolean): this;
        post(this: Self & Wretch<Self, Chain, Resolver>, body?: any, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        put(this: Self & Wretch<Self, Chain, Resolver>, body?: any, url?: string): Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
            : Resolver;
        resolve<ResolverReturn, Clear>(this: Self & Wretch<Self, Chain, Resolver>, resolver: ((chain: Resolver extends undefined
            ? Chain & WretchResponseChain<Self, Chain, undefined>
            : Clear extends true
                ? Chain & WretchResponseChain<Self, Chain, undefined>
                : Resolver, originalRequest: Self & Wretch<Self, Chain, Clear extends true
            ? undefined
            : Resolver>) => ResolverReturn), clear?: Clear): Self & Wretch<Self, Chain, ResolverReturn>;
        url(this: Self & Wretch<Self, Chain, Resolver>, url: string, replace?: boolean): this;
    }

    Type Parameters

    • Self = unknown
    • Chain = unknown
    • Resolver = undefined

    Body Types

    HTTP

    delete fetch @@ -32,17 +32,17 @@

    Parameters

    Returns this

    • Sets the "Content-Type" header, stringifies an object and sets the request body.

      +

    Returns this

    • Sets the "Content-Type" header, stringifies an object and sets the request body.

      const jsonObject = { a: 1, b: 2, c: 3 };
      wretch("...").json(jsonObject).post();
      // Note that calling an 'http verb' method with an object argument is equivalent:
      wretch("...").post(jsonObject);

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • jsObject: object

        An object which will be serialized into a JSON

      • OptionalcontentType: string

        A custom content type.

        -

      Returns this

    HTTP

    Returns this

    HTTP

    • Sends the request using the accumulated fetch options.

      Can be used to replay requests.

      const reAuthOn401 = wretch()
      .catcher(401, async (error, request) => {
      // Renew credentials
      const token = await wretch("/renewtoken").get().text();
      storeToken(token);
      // Replay the original request with new credentials
      return request.auth(token).fetch().unauthorized((err) => {
      throw err;
      }).json();
      });

      reAuthOn401
      .get("/resource")
      .json() // <- Will only be called for the original promise
      .then(callback); // <- Will be called for the original OR the replayed promise result
      @@ -50,46 +50,46 @@

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • Optionalmethod: string

        The HTTP method to use

      • Optionalurl: string

        Some url to append

      • Optionalbody: any

        Set the body. Behaviour varies depending on the argument type, an object is considered as json.

        -

      Returns Resolver extends undefined
          ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
          : Resolver

    Returns Resolver extends undefined
        ? Chain & WretchResponseChain<Self, Chain, Resolver<Resolver>>
        : Resolver

    Helpers

    Helpers

    • Shortcut to set the "Accept" header.

      wretch("...").accept("application/json");
       

      Parameters

      Returns this

    Returns this

    • Register an Addon to enhance the wretch or response objects.

      import FormDataAddon from "wretch/addons/formData"
      import QueryStringAddon from "wretch/addons/queryString"

      // Add both addons
      const w = wretch().addon(FormDataAddon).addon(QueryStringAddon)

      // Additional features are now available
      w.formData({ hello: "world" }).query({ check: true })

      Type Parameters

      • W
      • R

      Parameters

      Returns W & Self & Wretch<Self & W, Chain & R, Resolver>

    • Shortcut to set the "Authorization" header.

      +

    Returns W & Self & Wretch<Self & W, Chain & R, Resolver>

    • Shortcut to set the "Authorization" header.

      wretch("...").auth("Basic d3JldGNoOnJvY2tz");
       

      Parameters

      Returns this

    • Adds a catcher which will be +

    Returns this

    • Adds a catcher which will be called on every subsequent request error.

      Very useful when you need to perform a repetitive action on a specific error code.

      @@ -103,40 +103,40 @@

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • errorId: string | number | symbol

        Error code or name

      • catcher: ((error: WretchError, originalRequest: this) => any)

        The catcher method

        -
          • (error, originalRequest): any
          • Parameters

            Returns any

      Returns this

    • A fallback catcher that will be called for any error thrown - if uncaught by other means.

      +
        • (error, originalRequest): any
        • Parameters

          Returns any

    Returns this

    • A fallback catcher that will be called for any error thrown - if uncaught by other means.

      wretch(url)
      .catcher(404, err => redirect("/routes/notfound", err.message))
      .catcher(500, err => flashMessage("internal.server.error"))
      // this fallback will trigger for any error except the ones caught above (404 and 505)
      .catcherFallback(err => {
      log("Uncaught error:", err)
      throw err
      })

      Parameters

      Returns this

      Wretch.catcher for more details.

      -
    • Shortcut to set the "Content-Type" header.

      +
    • Shortcut to set the "Content-Type" header.

      wretch("...").content("application/json");
       

      Parameters

      Returns this

    • Defer one or multiple request chain methods that will get called just before the request is sent.

      +

    Returns this

    • Defer one or multiple request chain methods that will get called just before the request is sent.

      // Small fictional example: deferred authentication

      // If you cannot retrieve the auth token while configuring the wretch object you can use .defer to postpone the call
      const api = wretch("http://some-domain.com").defer((w, url, options) => {
      // If we are hitting the route /user…
      if (//user/.test(url)) {
      const { token } = options.context;
      return w.auth(token);
      }
      return w;
      });

      // ... //

      const token = await getToken(request.session.user);

      // .auth gets called here automatically
      api.options({
      context: { token },
      }).get("/user/1").res();

      Type Parameters

      • Clear extends boolean = false

      Parameters

      Returns this

    • Sets the method (text, json ...) used to parse the data contained in the +

    Returns this

    • Sets the method (text, json ...) used to parse the data contained in the response body in case of an HTTP error is returned.

      Note: if the response Content-Type header is set to "application/json", the body will be parsed as json regardless of the errorType.

      wretch("http://server/which/returns/an/error/with/a/json/body")
      .errorType("json")
      .get()
      .res()
      .catch(error => {
      // error[errorType] (here, json) contains the parsed body
      console.log(error.json)
      })

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • method: ErrorType

        The method to call on the Fetch response to read the body and use it as the Error message

        -

      Returns this

    • Sets the request headers.

      +

    Returns this

    • Sets the request headers.

      wretch("...")
      .headers({ "Content-Type": "text/plain", Accept: "application/json" })
      .post("my text")
      .json();

      Parameters

      Returns this

    • Add middlewares to intercept a request before being sent.

      +

    Returns this

    • Add middlewares to intercept a request before being sent.

      // A simple delay middleware.
      const delayMiddleware = delay => next => (url, opts) => {
      return new Promise(res => setTimeout(() => res(next(url, opts)), delay))
      }

      // The request will be delayed by 1 second.
      wretch("...").middlewares([
      delayMiddleware(1000)
      ]).get().res()
      -

      Parameters

      Returns this

    • Sets the fetch options.

      wretch("...").options({ credentials: "same-origin" });
       
      @@ -151,24 +151,24 @@

      Parameters

      Returns this

    • Sets non-global polyfills - for instance in browserless environments.

      +

    Returns this

    • Sets non-global polyfills - for instance in browserless environments.

      Needed for libraries like fetch-ponyfill.

      const fetch = require("node-fetch");
      const FormData = require("form-data");

      wretch("http://domain.com")
      .polyfills({
      fetch: fetch,
      FormData: FormData,
      URLSearchParams: require("url").URLSearchParams,
      })
      .get()

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • polyfills: object

        An object containing the polyfills

      • Optionalreplace: boolean

        If true, replaces the current polyfills instead of mixing in

        -

      Returns this

    Returns this

    Returns Self & Wretch<Self, Chain, ResolverReturn>

    • Appends or replaces the url.

      wretch("/root").url("/sub").get().json();

      // Can be used to set a base url

      // Subsequent requests made using the 'blogs' object will be prefixed with "http://domain.com/api/blogs"
      const blogs = wretch("http://domain.com/api/blogs");

      // Perfect for CRUD apis
      const id = await blogs.post({ name: "my blog" }).json(blog => blog.id);
      const blog = await blogs.get(`/${id}`).json();
      console.log(blog.name);

      await blogs.url(`/${id}`).delete().res();

      // And to replace the base url if needed :
      const noMoreBlogs = blogs.url("http://domain2.com/", true);

      Parameters

      • this: Self & Wretch<Self, Chain, Resolver>
      • url: string

        Url segment

      • Optionalreplace: boolean

        If true, replaces the current url instead of appending

        -

      Returns this

    +

    Returns this

    diff --git a/docs/api/interfaces/index.WretchError.html b/docs/api/interfaces/index.WretchError.html index 0acd94b..cdac1ed 100644 --- a/docs/api/interfaces/index.WretchError.html +++ b/docs/api/interfaces/index.WretchError.html @@ -1,5 +1,5 @@ WretchError | wretch

    Interface WretchError

    An Error enhanced with status, text and body.

    -
    interface WretchError {
        json?: any;
        message: string;
        name: string;
        response: WretchResponse;
        stack?: string;
        status: number;
        text?: string;
        url: string;
    }

    Hierarchy

    • Error
      • WretchError

    Properties

    interface WretchError {
        json?: any;
        message: string;
        name: string;
        response: WretchResponse;
        stack?: string;
        status: number;
        text?: string;
        url: string;
    }

    Hierarchy

    • Error
      • WretchError

    Properties

    Properties

    json?: any
    message: string
    name: string
    response: WretchResponse
    stack?: string
    status: number
    text?: string
    url: string
    +

    Properties

    json?: any
    message: string
    name: string
    response: WretchResponse
    stack?: string
    status: number
    text?: string
    url: string
    diff --git a/docs/api/interfaces/index.WretchResponseChain.html b/docs/api/interfaces/index.WretchResponseChain.html index 025f731..300f8cf 100644 --- a/docs/api/interfaces/index.WretchResponseChain.html +++ b/docs/api/interfaces/index.WretchResponseChain.html @@ -1,6 +1,6 @@ WretchResponseChain | wretch

    Interface WretchResponseChain<T, Self, R>

    The resolver interface to chaining catchers and extra methods after the request has been sent. Ultimately returns a Promise.

    -
    interface WretchResponseChain<T, Self, R> {
        arrayBuffer: (<Result>(cb?: ((type: ArrayBuffer) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        badRequest: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        blob: (<Result>(cb?: ((type: Blob) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        error: ((this: Self & WretchResponseChain<T, Self, R>, code: string | number | symbol, cb: WretchErrorCallback<T, Self, R>) => this);
        fetchError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        forbidden: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        formData: (<Result>(cb?: ((type: FormData) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        internalError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        json: (<Result>(cb?: ((type: any) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        notFound: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        res: (<Result>(cb?: ((type: WretchResponse) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        text: (<Result>(cb?: ((type: string) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        timeout: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        unauthorized: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
    }

    Type Parameters

    • T
    • Self = unknown
    • R = undefined

    Catchers

    interface WretchResponseChain<T, Self, R> {
        arrayBuffer: (<Result>(cb?: ((type: ArrayBuffer) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        badRequest: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        blob: (<Result>(cb?: ((type: Blob) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        error: ((this: Self & WretchResponseChain<T, Self, R>, code: string | number | symbol, cb: WretchErrorCallback<T, Self, R>) => this);
        fetchError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        forbidden: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        formData: (<Result>(cb?: ((type: FormData) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        internalError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        json: (<Result>(cb?: ((type: any) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        notFound: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        res: (<Result>(cb?: ((type: WretchResponse) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        text: (<Result>(cb?: ((type: string) => Result | Promise<Result>)) => Promise<Awaited<Result>>);
        timeout: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
        unauthorized: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this);
    }

    Type Parameters

    • T
    • Self = unknown
    • R = undefined

    Catchers

    badRequest error fetchError forbidden @@ -17,52 +17,52 @@

    Catchers

    badRequest: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a bad request (http code 400) and performs a callback.

    Syntactic sugar for error(400, cb).

    error: ((this: Self & WretchResponseChain<T, Self, R>, code: string | number | symbol, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches an http response with a specific error code or name and performs a callback.

    +
    error: ((this: Self & WretchResponseChain<T, Self, R>, code: string | number | symbol, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches an http response with a specific error code or name and performs a callback.

    The original request is passed along the error and can be used in order to perform an additional request.

    wretch("/resource")
    .get()
    .unauthorized(async (error, req) => {
    // Renew credentials
    const token = await wretch("/renewtoken").get().text();
    storeToken(token);
    // Replay the original request with new credentials
    return req.auth(token).get().unauthorized((err) => {
    throw err;
    }).json();
    })
    .json()
    // The promise chain is preserved as expected
    // ".then" will be performed on the result of the original request
    // or the replayed one (if a 401 error was thrown)
    .then(callback);
    -
    fetchError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches any error thrown by the fetch function and perform the callback.

    +
    fetchError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches any error thrown by the fetch function and perform the callback.

    forbidden: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a forbidden request (http code 403) and performs a callback.

    +
    forbidden: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a forbidden request (http code 403) and performs a callback.

    Syntactic sugar for error(403, cb).

    internalError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches an internal server error (http code 500) and performs a callback.

    +
    internalError: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches an internal server error (http code 500) and performs a callback.

    Syntactic sugar for error(500, cb).

    notFound: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a "not found" request (http code 404) and performs a callback.

    +
    notFound: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a "not found" request (http code 404) and performs a callback.

    Syntactic sugar for error(404, cb).

    timeout: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a timeout (http code 408) and performs a callback.

    +
    timeout: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches a timeout (http code 408) and performs a callback.

    Syntactic sugar for error(408, cb).

    unauthorized: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches an unauthorized request (http code 401) and performs a callback.

    +
    unauthorized: ((this: Self & WretchResponseChain<T, Self, R>, cb: WretchErrorCallback<T, Self, R>) => this)

    Catches an unauthorized request (http code 401) and performs a callback.

    Syntactic sugar for error(401, cb).

    Response Type

    arrayBuffer: (<Result>(cb?: ((type: ArrayBuffer) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as an ArrayBuffer object.

    +

    Response Type

    arrayBuffer: (<Result>(cb?: ((type: ArrayBuffer) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as an ArrayBuffer object.

    wretch("...").get().arrayBuffer(arrayBuffer => …)
     
    -
    blob: (<Result>(cb?: ((type: Blob) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as a Blob.

    +
    blob: (<Result>(cb?: ((type: Blob) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as a Blob.

    wretch("...").get().blob(blob => …)
     
    -
    formData: (<Result>(cb?: ((type: FormData) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as a FormData object.

    +
    formData: (<Result>(cb?: ((type: FormData) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as a FormData object.

    wretch("...").get().formData(formData => …)
     
    -
    json: (<Result>(cb?: ((type: any) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as JSON.

    +
    json: (<Result>(cb?: ((type: any) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Read the payload and deserialize it as JSON.

    wretch("...").get().json((json) => console.log(Object.keys(json)));
     
    -
    res: (<Result>(cb?: ((type: WretchResponse) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    The handler for the raw fetch Response. +

    res: (<Result>(cb?: ((type: WretchResponse) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    The handler for the raw fetch Response. Check the MDN documentation for more details on the Response class.

    wretch("...").get().res((response) => console.log(response.url));
     
    -
    text: (<Result>(cb?: ((type: string) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Retrieves the payload as a string.

    +
    text: (<Result>(cb?: ((type: string) => Result | Promise<Result>)) => Promise<Awaited<Result>>)

    Retrieves the payload as a string.

    wretch("...").get().text((txt) => console.log(txt));
     
    -
    +
    diff --git a/docs/api/modules/addons.html b/docs/api/modules/addons.html index 0dd3273..8a71da1 100644 --- a/docs/api/modules/addons.html +++ b/docs/api/modules/addons.html @@ -1,4 +1,4 @@ -addons | wretch

    Module addons

    References

    AbortResolver +addons | wretch

    Module addons

    References

    AbortResolver AbortWretch BasicAuthAddon FormDataAddon diff --git a/docs/api/modules/addons_abort.html b/docs/api/modules/addons_abort.html index c389660..3e3732c 100644 --- a/docs/api/modules/addons_abort.html +++ b/docs/api/modules/addons_abort.html @@ -1,4 +1,4 @@ -addons/abort | wretch

    Module addons/abort

    Index

    Interfaces

    AbortResolver +addons/abort | wretch

    Module addons/abort

    Index

    Interfaces

    Functions

    diff --git a/docs/api/modules/addons_basicAuth.html b/docs/api/modules/addons_basicAuth.html index 7dbb3ee..234c5f9 100644 --- a/docs/api/modules/addons_basicAuth.html +++ b/docs/api/modules/addons_basicAuth.html @@ -1,3 +1,3 @@ -addons/basicAuth | wretch

    Module addons/basicAuth

    Index

    Interfaces

    BasicAuthAddon +addons/basicAuth | wretch

    Module addons/basicAuth

    Index

    Interfaces

    Variables

    diff --git a/docs/api/modules/addons_formData.html b/docs/api/modules/addons_formData.html index d8a6d44..542450f 100644 --- a/docs/api/modules/addons_formData.html +++ b/docs/api/modules/addons_formData.html @@ -1,3 +1,3 @@ -addons/formData | wretch

    Module addons/formData

    Index

    Interfaces

    FormDataAddon +addons/formData | wretch

    Module addons/formData

    Index

    Interfaces

    Variables

    diff --git a/docs/api/modules/addons_formUrl.html b/docs/api/modules/addons_formUrl.html index f08b394..7b1530a 100644 --- a/docs/api/modules/addons_formUrl.html +++ b/docs/api/modules/addons_formUrl.html @@ -1,3 +1,3 @@ -addons/formUrl | wretch

    Module addons/formUrl

    Index

    Interfaces

    FormUrlAddon +addons/formUrl | wretch

    Module addons/formUrl

    Index

    Interfaces

    Variables

    diff --git a/docs/api/modules/addons_perfs.html b/docs/api/modules/addons_perfs.html index d97250a..df5e3b5 100644 --- a/docs/api/modules/addons_perfs.html +++ b/docs/api/modules/addons_perfs.html @@ -1,4 +1,4 @@ -addons/perfs | wretch

    Module addons/perfs

    Index

    Interfaces

    PerfsAddon +addons/perfs | wretch

    Module addons/perfs

    Index

    Interfaces

    Type Aliases

    Functions

    diff --git a/docs/api/modules/addons_progress.html b/docs/api/modules/addons_progress.html index af23a2f..65403fa 100644 --- a/docs/api/modules/addons_progress.html +++ b/docs/api/modules/addons_progress.html @@ -1,3 +1,3 @@ -addons/progress | wretch

    Module addons/progress

    Index

    Interfaces

    ProgressResolver +addons/progress | wretch

    Module addons/progress

    Index

    Interfaces

    Functions

    diff --git a/docs/api/modules/addons_queryString.html b/docs/api/modules/addons_queryString.html index 997a5a3..fc80a52 100644 --- a/docs/api/modules/addons_queryString.html +++ b/docs/api/modules/addons_queryString.html @@ -1,3 +1,3 @@ -addons/queryString | wretch

    Module addons/queryString

    Index

    Interfaces

    QueryStringAddon +addons/queryString | wretch

    Module addons/queryString

    Index

    Interfaces

    Variables

    diff --git a/docs/api/modules/index.html b/docs/api/modules/index.html index f1ba033..4530cdf 100644 --- a/docs/api/modules/index.html +++ b/docs/api/modules/index.html @@ -1,4 +1,4 @@ -index | wretch

    Module index

    Index

    Interfaces

    Wretch +index | wretch

    Module index

    Index

    Interfaces

    Type Aliases

    Config diff --git a/docs/api/modules/middlewares.html b/docs/api/modules/middlewares.html index 4fd1956..8ab6b64 100644 --- a/docs/api/modules/middlewares.html +++ b/docs/api/modules/middlewares.html @@ -1,4 +1,4 @@ -middlewares | wretch

    Module middlewares

    References

    DedupeKeyFunction +middlewares | wretch

    Module middlewares

    References

    DedupeKeyFunction DedupeMiddleware DedupeOptions DedupeResolverFunction diff --git a/docs/api/modules/middlewares_dedupe.html b/docs/api/modules/middlewares_dedupe.html index acae49c..1f74606 100644 --- a/docs/api/modules/middlewares_dedupe.html +++ b/docs/api/modules/middlewares_dedupe.html @@ -1,4 +1,4 @@ -middlewares/dedupe | wretch

    Module middlewares/dedupe

    Index

    Type Aliases

    DedupeKeyFunction +middlewares/dedupe | wretch

    Module middlewares/dedupe

    Index

    Type Aliases

    DedupeKeyFunction DedupeMiddleware DedupeOptions DedupeResolverFunction diff --git a/docs/api/modules/middlewares_delay.html b/docs/api/modules/middlewares_delay.html index 15b75b1..190e239 100644 --- a/docs/api/modules/middlewares_delay.html +++ b/docs/api/modules/middlewares_delay.html @@ -1,3 +1,3 @@ -middlewares/delay | wretch

    Module middlewares/delay

    Index

    Type Aliases

    DelayMiddleware +middlewares/delay | wretch

    Module middlewares/delay

    Index

    Type Aliases

    Functions

    diff --git a/docs/api/modules/middlewares_retry.html b/docs/api/modules/middlewares_retry.html index 499ec02..fa23811 100644 --- a/docs/api/modules/middlewares_retry.html +++ b/docs/api/modules/middlewares_retry.html @@ -1,4 +1,4 @@ -middlewares/retry | wretch

    Module middlewares/retry

    Index

    Type Aliases

    DelayRampFunction +middlewares/retry | wretch

    Module middlewares/retry

    Index

    Type Aliases

    DelayRampFunction OnRetryFunction OnRetryFunctionResponse RetryMiddleware diff --git a/docs/api/modules/middlewares_throttlingCache.html b/docs/api/modules/middlewares_throttlingCache.html index 6e0820f..f0b6971 100644 --- a/docs/api/modules/middlewares_throttlingCache.html +++ b/docs/api/modules/middlewares_throttlingCache.html @@ -1,4 +1,4 @@ -middlewares/throttlingCache | wretch

    Module middlewares/throttlingCache

    Index

    Type Aliases

    ThrottlingCacheClearFunction +middlewares/throttlingCache | wretch

    Module middlewares/throttlingCache

    Index

    Type Aliases

    ThrottlingCacheClearFunction ThrottlingCacheConditionFunction ThrottlingCacheInvalidateFunction ThrottlingCacheKeyFunction diff --git a/docs/api/types/addons_perfs.PerfCallback.html b/docs/api/types/addons_perfs.PerfCallback.html index 839235e..ced7811 100644 --- a/docs/api/types/addons_perfs.PerfCallback.html +++ b/docs/api/types/addons_perfs.PerfCallback.html @@ -1 +1 @@ -PerfCallback | wretch

    Type Alias PerfCallback

    PerfCallback: ((timing: any) => void)
    +PerfCallback | wretch

    Type Alias PerfCallback

    PerfCallback: ((timing: any) => void)
    diff --git a/docs/api/types/index.Config.html b/docs/api/types/index.Config.html index e1eca27..768e343 100644 --- a/docs/api/types/index.Config.html +++ b/docs/api/types/index.Config.html @@ -1,2 +1,2 @@ Config | wretch

    Type Alias Config

    Config: {
        errorType: ErrorType;
        options: object;
        polyfills: object;
        polyfill(p: "fetch", doThrow?: boolean): {
            (input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
            (input: RequestInfo, init?: RequestInit): Promise<Response>;
        };
        polyfill(p: "FormData", doThrow: boolean, instance: true, ...args: [form?: HTMLFormElement, submitter?: HTMLElement]): FormData;
        polyfill(p: "FormData", doThrow?: boolean, instance?: false): {
            prototype: FormData;
            new (form?: HTMLFormElement, submitter?: HTMLElement): FormData;
        };
        polyfill(p: "URL", doThrow: boolean, instance: true, ...args: [url: string | URL, base?: string | URL]): URL;
        polyfill(p: "URL", doThrow?: boolean, instance?: false): {
            prototype: URL;
            canParse(url: string | URL, base?: string): boolean;
            createObjectURL(obj: Blob | MediaSource): string;
            revokeObjectURL(url: string): void;
            new (url: string | URL, base?: string | URL): URL;
        };
        polyfill(p: "URLSearchParams", doThrow: boolean, instance: true, ...args: [init?:
            | string
            | Record<string, string>
            | URLSearchParams
            | string[][]]): URLSearchParams;
        polyfill(p: "URLSearchParams", doThrow?: boolean, instance?: false): {
            prototype: URLSearchParams;
            new (init?:
                | string
                | Record<string, string>
                | URLSearchParams
                | string[][]): URLSearchParams;
        };
        polyfill(p: "AbortController", doThrow: boolean, instance: true, ...args: []): AbortController;
        polyfill(p: "AbortController", doThrow?: boolean, instance?: false): {
            prototype: AbortController;
            new (): AbortController;
        };
        polyfill(p: "performance", doThrow: boolean): Performance;
        polyfill(p: string, doThrow?: boolean, instance?: boolean, ...args: any[]): any;
    }

    Configuration object.

    -
    +
    diff --git a/docs/api/types/index.ConfiguredMiddleware.html b/docs/api/types/index.ConfiguredMiddleware.html index 657e5bf..cffbaf2 100644 --- a/docs/api/types/index.ConfiguredMiddleware.html +++ b/docs/api/types/index.ConfiguredMiddleware.html @@ -1,4 +1,4 @@ ConfiguredMiddleware | wretch

    Type Alias ConfiguredMiddleware

    ConfiguredMiddleware: ((next: FetchLike) => FetchLike)

    A ready to use middleware which is called before the request is sent. Input is the next middleware in the chain, then url and options. Output is a promise.

    -
    +
    diff --git a/docs/api/types/index.FetchLike.html b/docs/api/types/index.FetchLike.html index 0ee0ff3..d81a924 100644 --- a/docs/api/types/index.FetchLike.html +++ b/docs/api/types/index.FetchLike.html @@ -1,2 +1,2 @@ FetchLike | wretch

    Type Alias FetchLike

    FetchLike: ((url: string, opts: WretchOptions) => Promise<WretchResponse>)

    Any function having the same shape as fetch().

    -
    +
    diff --git a/docs/api/types/index.Middleware.html b/docs/api/types/index.Middleware.html index f86e6de..8944acf 100644 --- a/docs/api/types/index.Middleware.html +++ b/docs/api/types/index.Middleware.html @@ -1,3 +1,3 @@ Middleware | wretch

    Type Alias Middleware

    Middleware: ((options?: {
        [key: string]: any;
    }) => ConfiguredMiddleware)

    Shape of a typical middleware. Expects options and returns a ConfiguredMiddleware that can then be registered using the .middlewares function.

    -
    +
    diff --git a/docs/api/types/index.WretchAddon.html b/docs/api/types/index.WretchAddon.html index a59854f..efa2599 100644 --- a/docs/api/types/index.WretchAddon.html +++ b/docs/api/types/index.WretchAddon.html @@ -1,2 +1,2 @@ WretchAddon | wretch

    Type Alias WretchAddon<W, R>

    WretchAddon<W, R>: {
        resolver?: R | (<T, C>(_: C & WretchResponseChain<T, C, R>) => R);
        wretch?: W;
        beforeRequest?<T, C, R>(wretch: T & Wretch<T, C, R>, options: WretchOptions, state: Record<any, any>): T & Wretch<T, C, R>;
    }

    An addon enhancing either the request or response chain (or both).

    -

    Type Parameters

    • W
    • R = unknown
    +

    Type Parameters

    • W
    • R = unknown
    diff --git a/docs/api/types/index.WretchDeferredCallback.html b/docs/api/types/index.WretchDeferredCallback.html index 230bbea..ec5d72e 100644 --- a/docs/api/types/index.WretchDeferredCallback.html +++ b/docs/api/types/index.WretchDeferredCallback.html @@ -1,2 +1,2 @@ WretchDeferredCallback | wretch

    Type Alias WretchDeferredCallback<T, C, R>

    WretchDeferredCallback<T, C, R>: ((wretch: T & Wretch<T, C, R>, url: string, options: WretchOptions) => Wretch<T, C, any>)

    Callback provided to the defer function allowing to chain deferred actions that will be stored and applied just before the request is sent.

    -

    Type Parameters

    • T
    • C
    • R
    +

    Type Parameters

    • T
    • C
    • R
    diff --git a/docs/api/types/index.WretchErrorCallback.html b/docs/api/types/index.WretchErrorCallback.html index bf66875..6ae4caf 100644 --- a/docs/api/types/index.WretchErrorCallback.html +++ b/docs/api/types/index.WretchErrorCallback.html @@ -1,2 +1,2 @@ WretchErrorCallback | wretch

    Type Alias WretchErrorCallback<T, C, R>

    WretchErrorCallback<T, C, R>: ((error: WretchError, originalRequest: T & Wretch<T, C, R>) => any)

    Callback provided to catchers on error. Contains the original wretch instance used to perform the request.

    -

    Type Parameters

    • T
    • C
    • R
    +

    Type Parameters

    • T
    • C
    • R
    diff --git a/docs/api/types/index.WretchOptions.html b/docs/api/types/index.WretchOptions.html index 7a65097..0373991 100644 --- a/docs/api/types/index.WretchOptions.html +++ b/docs/api/types/index.WretchOptions.html @@ -1,2 +1,2 @@ WretchOptions | wretch

    Type Alias WretchOptions

    WretchOptions: Record<string, any>

    Fetch Request options with additional properties.

    -
    +
    diff --git a/docs/api/types/index.WretchResponse.html b/docs/api/types/index.WretchResponse.html index 7210365..221155c 100644 --- a/docs/api/types/index.WretchResponse.html +++ b/docs/api/types/index.WretchResponse.html @@ -1,2 +1,2 @@ WretchResponse | wretch

    Type Alias WretchResponse

    WretchResponse: Response & {
        [key: string]: any;
    }

    Fetch Response object with additional properties.

    -
    +
    diff --git a/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html b/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html index 0e8ecce..85b532b 100644 --- a/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html +++ b/docs/api/types/middlewares_dedupe.DedupeKeyFunction.html @@ -1 +1 @@ -DedupeKeyFunction | wretch

    Type Alias DedupeKeyFunction

    DedupeKeyFunction: ((url: string, opts: WretchOptions) => string)
    +DedupeKeyFunction | wretch

    Type Alias DedupeKeyFunction

    DedupeKeyFunction: ((url: string, opts: WretchOptions) => string)
    diff --git a/docs/api/types/middlewares_dedupe.DedupeMiddleware.html b/docs/api/types/middlewares_dedupe.DedupeMiddleware.html index 5657577..d0be443 100644 --- a/docs/api/types/middlewares_dedupe.DedupeMiddleware.html +++ b/docs/api/types/middlewares_dedupe.DedupeMiddleware.html @@ -18,4 +18,4 @@

    This function is called when resolving the fetch response from duplicate calls. By default it clones the response to allow reading the body from multiple sources.

    -
    +
    diff --git a/docs/api/types/middlewares_dedupe.DedupeOptions.html b/docs/api/types/middlewares_dedupe.DedupeOptions.html index 31417fa..154ccb7 100644 --- a/docs/api/types/middlewares_dedupe.DedupeOptions.html +++ b/docs/api/types/middlewares_dedupe.DedupeOptions.html @@ -1 +1 @@ -DedupeOptions | wretch
    DedupeOptions: {
        key?: DedupeKeyFunction;
        resolver?: DedupeResolverFunction;
        skip?: DedupeSkipFunction;
    }
    +DedupeOptions | wretch
    DedupeOptions: {
        key?: DedupeKeyFunction;
        resolver?: DedupeResolverFunction;
        skip?: DedupeSkipFunction;
    }
    diff --git a/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html b/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html index 6cc15a7..7cd7ae3 100644 --- a/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html +++ b/docs/api/types/middlewares_dedupe.DedupeResolverFunction.html @@ -1 +1 @@ -DedupeResolverFunction | wretch

    Type Alias DedupeResolverFunction

    DedupeResolverFunction: ((response: Response) => Response)
    +DedupeResolverFunction | wretch

    Type Alias DedupeResolverFunction

    DedupeResolverFunction: ((response: Response) => Response)
    diff --git a/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html b/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html index e0f758c..7c69523 100644 --- a/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html +++ b/docs/api/types/middlewares_dedupe.DedupeSkipFunction.html @@ -1 +1 @@ -DedupeSkipFunction | wretch

    Type Alias DedupeSkipFunction

    DedupeSkipFunction: ((url: string, opts: WretchOptions) => boolean)
    +DedupeSkipFunction | wretch

    Type Alias DedupeSkipFunction

    DedupeSkipFunction: ((url: string, opts: WretchOptions) => boolean)
    diff --git a/docs/api/types/middlewares_delay.DelayMiddleware.html b/docs/api/types/middlewares_delay.DelayMiddleware.html index beabc74..714e02c 100644 --- a/docs/api/types/middlewares_delay.DelayMiddleware.html +++ b/docs/api/types/middlewares_delay.DelayMiddleware.html @@ -5,4 +5,4 @@

    The request will be delayed by that amount of time.

    -
    +
    diff --git a/docs/api/types/middlewares_retry.DelayRampFunction.html b/docs/api/types/middlewares_retry.DelayRampFunction.html index 121f67f..2af66e9 100644 --- a/docs/api/types/middlewares_retry.DelayRampFunction.html +++ b/docs/api/types/middlewares_retry.DelayRampFunction.html @@ -1 +1 @@ -DelayRampFunction | wretch

    Type Alias DelayRampFunction

    DelayRampFunction: ((delay: number, nbOfAttempts: number) => number)
    +DelayRampFunction | wretch

    Type Alias DelayRampFunction

    DelayRampFunction: ((delay: number, nbOfAttempts: number) => number)
    diff --git a/docs/api/types/middlewares_retry.OnRetryFunction.html b/docs/api/types/middlewares_retry.OnRetryFunction.html index 6b1b659..37df826 100644 --- a/docs/api/types/middlewares_retry.OnRetryFunction.html +++ b/docs/api/types/middlewares_retry.OnRetryFunction.html @@ -1 +1 @@ -OnRetryFunction | wretch

    Type Alias OnRetryFunction

    OnRetryFunction: ((args: {
        error?: Error;
        options: WretchOptions;
        response?: Response;
        url: string;
    }) => void | OnRetryFunctionResponse | Promise<OnRetryFunctionResponse>)
    +OnRetryFunction | wretch

    Type Alias OnRetryFunction

    OnRetryFunction: ((args: {
        error?: Error;
        options: WretchOptions;
        response?: Response;
        url: string;
    }) => void | OnRetryFunctionResponse | Promise<OnRetryFunctionResponse>)
    diff --git a/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html b/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html index 38d6f87..b77bfba 100644 --- a/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html +++ b/docs/api/types/middlewares_retry.OnRetryFunctionResponse.html @@ -1 +1 @@ -OnRetryFunctionResponse | wretch

    Type Alias OnRetryFunctionResponse

    OnRetryFunctionResponse: {
        options?: WretchOptions;
        url?: string;
    } | undefined
    +OnRetryFunctionResponse | wretch

    Type Alias OnRetryFunctionResponse

    OnRetryFunctionResponse: {
        options?: WretchOptions;
        url?: string;
    } | undefined
    diff --git a/docs/api/types/middlewares_retry.RetryMiddleware.html b/docs/api/types/middlewares_retry.RetryMiddleware.html index 3bd894a..abe4f69 100644 --- a/docs/api/types/middlewares_retry.RetryMiddleware.html +++ b/docs/api/types/middlewares_retry.RetryMiddleware.html @@ -7,4 +7,4 @@
    import wretch from 'wretch'
    import { retry } from 'wretch/middlewares'

    wretch().middlewares([
    retry({
    // Options - defaults below
    delayTimer: 500,
    delayRamp: (delay, nbOfAttempts) => delay * nbOfAttempts,
    maxAttempts: 10,
    until: (response, error) => response && response.ok,
    onRetry: null,
    retryOnNetworkError: false,
    resolveWithLatestResponse: false,
    skip: undefined
    })
    ])

    // You can also return a Promise, which is useful if you want to inspect the body:
    wretch().middlewares([
    retry({
    until: response =>
    response.clone().json().then(body =>
    body.field === 'something'
    )
    })
    ])
    -
    +
    diff --git a/docs/api/types/middlewares_retry.RetryOptions.html b/docs/api/types/middlewares_retry.RetryOptions.html index 3b56b77..654c1d8 100644 --- a/docs/api/types/middlewares_retry.RetryOptions.html +++ b/docs/api/types/middlewares_retry.RetryOptions.html @@ -18,4 +18,4 @@

    Default: undefined

  • Optionaluntil?: UntilFunction

    The request will be retried until that condition is satisfied.

    Default: response && response.ok

    -
  • +
    diff --git a/docs/api/types/middlewares_retry.SkipFunction.html b/docs/api/types/middlewares_retry.SkipFunction.html index 1bc7649..80e7cf0 100644 --- a/docs/api/types/middlewares_retry.SkipFunction.html +++ b/docs/api/types/middlewares_retry.SkipFunction.html @@ -1 +1 @@ -SkipFunction | wretch
    SkipFunction: ((url: string, opts: WretchOptions) => boolean)
    +SkipFunction | wretch
    SkipFunction: ((url: string, opts: WretchOptions) => boolean)
    diff --git a/docs/api/types/middlewares_retry.UntilFunction.html b/docs/api/types/middlewares_retry.UntilFunction.html index aed4b40..334ed33 100644 --- a/docs/api/types/middlewares_retry.UntilFunction.html +++ b/docs/api/types/middlewares_retry.UntilFunction.html @@ -1 +1 @@ -UntilFunction | wretch

    Type Alias UntilFunction

    UntilFunction: ((response?: Response, error?: Error) => boolean | Promise<boolean>)
    +UntilFunction | wretch

    Type Alias UntilFunction

    UntilFunction: ((response?: Response, error?: Error) => boolean | Promise<boolean>)
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html index bf8ed8c..5c757e5 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheClearFunction.html @@ -1 +1 @@ -ThrottlingCacheClearFunction | wretch
    ThrottlingCacheClearFunction: ((url: string, opts: WretchOptions) => boolean)
    +ThrottlingCacheClearFunction | wretch
    ThrottlingCacheClearFunction: ((url: string, opts: WretchOptions) => boolean)
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html index 12cfe82..ce755d5 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheConditionFunction.html @@ -1 +1 @@ -ThrottlingCacheConditionFunction | wretch
    ThrottlingCacheConditionFunction: ((response: WretchOptions) => boolean)
    +ThrottlingCacheConditionFunction | wretch
    ThrottlingCacheConditionFunction: ((response: WretchOptions) => boolean)
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html index b3a0548..a84e9e1 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheInvalidateFunction.html @@ -1 +1 @@ -ThrottlingCacheInvalidateFunction | wretch

    Type Alias ThrottlingCacheInvalidateFunction

    ThrottlingCacheInvalidateFunction: ((url: string, opts: WretchOptions) => string | RegExp | void)
    +ThrottlingCacheInvalidateFunction | wretch

    Type Alias ThrottlingCacheInvalidateFunction

    ThrottlingCacheInvalidateFunction: ((url: string, opts: WretchOptions) => string | RegExp | void)
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html index db62457..f91e9f4 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheKeyFunction.html @@ -1 +1 @@ -ThrottlingCacheKeyFunction | wretch
    ThrottlingCacheKeyFunction: ((url: string, opts: WretchOptions) => string)
    +ThrottlingCacheKeyFunction | wretch
    ThrottlingCacheKeyFunction: ((url: string, opts: WretchOptions) => string)
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html index f98d083..c5f5a94 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheMiddleware.html @@ -41,4 +41,4 @@

    If set, a Response returned from the cache whill be flagged with a property name equal to this option.

    -
    +
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html index 3729f54..f6c2d7d 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheOptions.html @@ -1 +1 @@ -ThrottlingCacheOptions | wretch
    ThrottlingCacheOptions: {
        clear?: ThrottlingCacheClearFunction;
        condition?: ThrottlingCacheConditionFunction;
        flagResponseOnCacheHit?: string;
        invalidate?: ThrottlingCacheInvalidateFunction;
        key?: ThrottlingCacheKeyFunction;
        skip?: ThrottlingCacheSkipFunction;
        throttle?: number;
    }
    +ThrottlingCacheOptions | wretch
    ThrottlingCacheOptions: {
        clear?: ThrottlingCacheClearFunction;
        condition?: ThrottlingCacheConditionFunction;
        flagResponseOnCacheHit?: string;
        invalidate?: ThrottlingCacheInvalidateFunction;
        key?: ThrottlingCacheKeyFunction;
        skip?: ThrottlingCacheSkipFunction;
        throttle?: number;
    }
    diff --git a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html index 84b09dd..67b4770 100644 --- a/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html +++ b/docs/api/types/middlewares_throttlingCache.ThrottlingCacheSkipFunction.html @@ -1 +1 @@ -ThrottlingCacheSkipFunction | wretch
    ThrottlingCacheSkipFunction: ((url: string, opts: WretchOptions) => boolean)
    +ThrottlingCacheSkipFunction | wretch
    ThrottlingCacheSkipFunction: ((url: string, opts: WretchOptions) => boolean)
    diff --git a/docs/api/variables/addons_basicAuth.default.html b/docs/api/variables/addons_basicAuth.default.html index 3e36cf5..e450d2b 100644 --- a/docs/api/variables/addons_basicAuth.default.html +++ b/docs/api/variables/addons_basicAuth.default.html @@ -2,4 +2,4 @@
    import BasicAuthAddon from "wretch/addons/basicAuth"

    wretch().addon(BasicAuthAddon)
    -
    +
    diff --git a/docs/api/variables/addons_formData.default.html b/docs/api/variables/addons_formData.default.html index 12e3074..4180335 100644 --- a/docs/api/variables/addons_formData.default.html +++ b/docs/api/variables/addons_formData.default.html @@ -2,4 +2,4 @@
    import FormDataAddon from "wretch/addons/formData"

    wretch().addon(FormDataAddon)
    -
    +
    diff --git a/docs/api/variables/addons_formUrl.default.html b/docs/api/variables/addons_formUrl.default.html index de6268e..5fe4c58 100644 --- a/docs/api/variables/addons_formUrl.default.html +++ b/docs/api/variables/addons_formUrl.default.html @@ -2,4 +2,4 @@
    import FormUrlAddon from "wretch/addons/formUrl"

    wretch().addon(FormUrlAddon)
    -
    +
    diff --git a/docs/api/variables/addons_queryString.default.html b/docs/api/variables/addons_queryString.default.html index d15f8af..47a19f1 100644 --- a/docs/api/variables/addons_queryString.default.html +++ b/docs/api/variables/addons_queryString.default.html @@ -2,4 +2,4 @@
    import QueryAddon from "wretch/addons/queryString"

    wretch().addon(QueryAddon)
    -
    +
    diff --git a/package-lock.json b/package-lock.json index 4ae4825..e8e506d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wretch", - "version": "2.9.0", + "version": "2.9.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "wretch", - "version": "2.9.0", + "version": "2.9.1", "license": "MIT", "devDependencies": { "@eslint/js": "^9.4.0", @@ -45,7 +45,7 @@ "rollup": "^4.5.0", "ts-jest": "^29.1.1", "tslib": "^2.6.2", - "typedoc": "^0.26.5", + "typedoc": "^0.26.6", "typescript": "^5.4.5", "typescript-eslint": "^7.11.0", "wait-on": "^7.2.0", @@ -1916,15 +1916,23 @@ ] }, "node_modules/@shikijs/core": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.12.0.tgz", - "integrity": "sha512-mc1cLbm6UQ8RxLc0dZES7v5rkH+99LxQp/ZvTqV3NLyYsO/fD6JhEflP1H5b2SDq9gI0+0G36AVZWxvounfR9w==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.16.2.tgz", + "integrity": "sha512-XSVH5OZCvE4WLMgdoBqfPMYmGHGmCC3OgZhw0S7KcSi2XKZ+5oHGe71GFnTljgdOxvxx5WrRks6QoTLKrl1eAA==", "dev": true, "license": "MIT", "dependencies": { + "@shikijs/vscode-textmate": "^9.2.0", "@types/hast": "^3.0.4" } }, + "node_modules/@shikijs/vscode-textmate": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-9.2.0.tgz", + "integrity": "sha512-5FinaOp6Vdh/dl4/yaOTh0ZeKch+rYS8DUb38V3GMKYVkdqzxw53lViRKUYkVILRiVQT7dcPC7VvAKOR73zVtQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@sideway/address": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.4.tgz", @@ -2169,9 +2177,9 @@ "dev": true }, "node_modules/@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "dev": true, "license": "MIT" }, @@ -8171,13 +8179,14 @@ } }, "node_modules/shiki": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.12.0.tgz", - "integrity": "sha512-BuAxWOm5JhRcbSOl7XCei8wGjgJJonnV0oipUupPY58iULxUGyHhW5CF+9FRMuM1pcJ5cGEJGll1LusX6FwpPA==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.16.2.tgz", + "integrity": "sha512-gSym0hZf5a1U0iDPsdoOAZbvoi+e0c6c3NKAi03FoSLTm7oG20tum29+gk0wzzivOasn3loxfGUPT+jZXIUbWg==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/core": "1.12.0", + "@shikijs/core": "1.16.2", + "@shikijs/vscode-textmate": "^9.2.0", "@types/hast": "^3.0.4" } }, @@ -8913,9 +8922,9 @@ } }, "node_modules/typedoc": { - "version": "0.26.5", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz", - "integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==", + "version": "0.26.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.6.tgz", + "integrity": "sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -11036,14 +11045,21 @@ "optional": true }, "@shikijs/core": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.12.0.tgz", - "integrity": "sha512-mc1cLbm6UQ8RxLc0dZES7v5rkH+99LxQp/ZvTqV3NLyYsO/fD6JhEflP1H5b2SDq9gI0+0G36AVZWxvounfR9w==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.16.2.tgz", + "integrity": "sha512-XSVH5OZCvE4WLMgdoBqfPMYmGHGmCC3OgZhw0S7KcSi2XKZ+5oHGe71GFnTljgdOxvxx5WrRks6QoTLKrl1eAA==", "dev": true, "requires": { + "@shikijs/vscode-textmate": "^9.2.0", "@types/hast": "^3.0.4" } }, + "@shikijs/vscode-textmate": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-9.2.0.tgz", + "integrity": "sha512-5FinaOp6Vdh/dl4/yaOTh0ZeKch+rYS8DUb38V3GMKYVkdqzxw53lViRKUYkVILRiVQT7dcPC7VvAKOR73zVtQ==", + "dev": true + }, "@sideway/address": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.4.tgz", @@ -11286,9 +11302,9 @@ "dev": true }, "@types/unist": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", - "integrity": "sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "dev": true }, "@types/yargs": { @@ -15808,12 +15824,13 @@ "dev": true }, "shiki": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.12.0.tgz", - "integrity": "sha512-BuAxWOm5JhRcbSOl7XCei8wGjgJJonnV0oipUupPY58iULxUGyHhW5CF+9FRMuM1pcJ5cGEJGll1LusX6FwpPA==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.16.2.tgz", + "integrity": "sha512-gSym0hZf5a1U0iDPsdoOAZbvoi+e0c6c3NKAi03FoSLTm7oG20tum29+gk0wzzivOasn3loxfGUPT+jZXIUbWg==", "dev": true, "requires": { - "@shikijs/core": "1.12.0", + "@shikijs/core": "1.16.2", + "@shikijs/vscode-textmate": "^9.2.0", "@types/hast": "^3.0.4" } }, @@ -16370,9 +16387,9 @@ } }, "typedoc": { - "version": "0.26.5", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.5.tgz", - "integrity": "sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg==", + "version": "0.26.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.6.tgz", + "integrity": "sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==", "dev": true, "requires": { "lunr": "^2.3.9", diff --git a/package.json b/package.json index 69dcf6d..af286bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wretch", - "version": "2.9.0", + "version": "2.9.1", "type": "module", "description": "A tiny wrapper built around fetch with an intuitive syntax.", "keywords": [ @@ -133,6 +133,7 @@ "rollup": "^4.5.0", "ts-jest": "^29.1.1", "tslib": "^2.6.2", + "typedoc": "^0.26.6", "typescript": "^5.4.5", "typescript-eslint": "^7.11.0", "wait-on": "^7.2.0",