Skip to content

Commit

Permalink
2.1.0 tag
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Sep 3, 2022
1 parent 60a7453 commit 7c5b224
Show file tree
Hide file tree
Showing 70 changed files with 220 additions and 289 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<a name="2.1.0"></a>
# [2.1.0](https://github.com/elbywan/wretch/compare/2.0.4...2.1.0) (2022-09-03)


### :factory: New feature(s)

* Add ability to resolve with latest response to the retry middle ([60a7453](https://github.com/elbywan/wretch/commit/60a7453)), closes [#141](https://github.com/elbywan/wretch/issues/141)

### :memo: Documentation update(s)

* Remove outdated documentation entries for the retry middleware ([7a5620c](https://github.com/elbywan/wretch/commit/7a5620c))



<a name="2.0.4"></a>
## [2.0.4](https://github.com/elbywan/wretch/compare/2.0.3...2.0.4) (2022-08-18)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<br>

##### Wretch 2.0 is now live 🎉 ! Please have a look at the [releases](https://github.com/elbywan/wretch/releases) and the [changelog](https://github.com/elbywan/wretch/blob/master/CHANGELOG.md) after each update for new features and breaking changes. If you want to try out the hot stuff, please look into the [dev](https://github.com/elbywan/wretch/tree/dev) branch.
##### Wretch 2.1 is now live 🎉 ! Please have a look at the [releases](https://github.com/elbywan/wretch/releases) and the [changelog](https://github.com/elbywan/wretch/blob/master/CHANGELOG.md) after each update for new features and breaking changes. If you want to try out the hot stuff, please look into the [dev](https://github.com/elbywan/wretch/tree/dev) branch.

##### And if you like the library please consider becoming a [sponsor](https://github.com/sponsors/elbywan) ❤️.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/assets/search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/functions/addons_abort.default.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1>Function default</h1></div>
</div>
<h4 class="tsd-returns-title">Returns <a href="../types/index.WretchAddon.html" class="tsd-signature-type" data-tsd-kind="Type alias">WretchAddon</a><span class="tsd-signature-symbol">&lt;</span><a href="../interfaces/addons_abort.AbortWretch.html" class="tsd-signature-type" data-tsd-kind="Interface">AbortWretch</a><span class="tsd-signature-symbol">, </span><a href="../interfaces/addons_abort.AbortResolver.html" class="tsd-signature-type" data-tsd-kind="Interface">AbortResolver</a><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/addons/abort.ts#L110">src/addons/abort.ts:110</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/addons/abort.ts#L110">src/addons/abort.ts:110</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
2 changes: 1 addition & 1 deletion docs/api/functions/addons_perfs.default.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1>Function default</h1></div>
</div>
<h4 class="tsd-returns-title">Returns <a href="../types/index.WretchAddon.html" class="tsd-signature-type" data-tsd-kind="Type alias">WretchAddon</a><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">, </span><a href="../interfaces/addons_perfs.PerfsAddon.html" class="tsd-signature-type" data-tsd-kind="Interface">PerfsAddon</a><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/addons/perfs.ts#L114">src/addons/perfs.ts:114</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/addons/perfs.ts#L114">src/addons/perfs.ts:114</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
2 changes: 1 addition & 1 deletion docs/api/functions/index.default-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h5>_options: <span class="tsd-signature-symbol">{}</span><span class="tsd-signa
<ul class="tsd-parameters"></ul></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../interfaces/index.Wretch.html" class="tsd-signature-type" data-tsd-kind="Interface">Wretch</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/index.ts#L36">src/index.ts:36</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/index.ts#L36">src/index.ts:36</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
2 changes: 1 addition & 1 deletion docs/api/functions/middlewares_dedupe.dedupe.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5><code class="tsd-tag ts-flagOptional">Optional</code> options: <a href="../types/middlewares_dedupe.DedupeOptions.html" class="tsd-signature-type" data-tsd-kind="Type alias">DedupeOptions</a></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../types/index.ConfiguredMiddleware.html" class="tsd-signature-type" data-tsd-kind="Type alias">ConfiguredMiddleware</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/middlewares/dedupe.ts#L33">src/middlewares/dedupe.ts:33</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/middlewares/dedupe.ts#L33">src/middlewares/dedupe.ts:33</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
2 changes: 1 addition & 1 deletion docs/api/functions/middlewares_delay.delay.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5>time: <span class="tsd-signature-type">number</span></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../types/index.ConfiguredMiddleware.html" class="tsd-signature-type" data-tsd-kind="Type alias">ConfiguredMiddleware</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/middlewares/delay.ts#L16">src/middlewares/delay.ts:16</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/middlewares/delay.ts#L16">src/middlewares/delay.ts:16</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
59 changes: 3 additions & 56 deletions docs/api/functions/middlewares_retry.retry.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,61 +26,8 @@ <h2>Retry middleware</h2>
<a href="#retries-a-request-multiple-times-in-case-of-an-error-or-until-a-custom-condition-is-true" id="retries-a-request-multiple-times-in-case-of-an-error-or-until-a-custom-condition-is-true" style="color: inherit; text-decoration: none;">
<h4>Retries a request multiple times in case of an error (or until a custom condition is true).</h4>
</a>
<p><strong>Options</strong></p>
<ul>
<li><em>delayTimer</em> <code>milliseconds</code></li>
</ul>
<blockquote>
<p>The timer between each attempt.</p>
</blockquote>
<blockquote>
<p><em>(default: 500)</em></p>
</blockquote>
<ul>
<li><em>delayRamp</em> <code>(delay, nbOfAttempts) =&gt; milliseconds</code></li>
</ul>
<blockquote>
<p>The custom function that is used to calculate the actual delay based on the the timer &amp; the number of attemps.</p>
</blockquote>
<blockquote>
<p><em>(default: delay * nbOfAttemps)</em></p>
</blockquote>
<ul>
<li><em>maxAttempts</em> <code>number</code></li>
</ul>
<blockquote>
<p>The maximum number of retries before resolving the promise with the last error. Specifying 0 means infinite retries.</p>
</blockquote>
<blockquote>
<p><em>(default: 10)</em></p>
</blockquote>
<ul>
<li><em>until</em> <code>(response, error) =&gt; boolean || Promise&lt;boolean&gt;</code></li>
</ul>
<blockquote>
<p>The request will be retried until that condition is satisfied.</p>
</blockquote>
<blockquote>
<p><em>(default: response &amp;&amp; response.ok)</em></p>
</blockquote>
<ul>
<li><em>onRetry</em> <code>({ response, error, url, options }) =&gt; { url?, options? } || Promise&lt;{url?, options?}&gt;</code></li>
</ul>
<blockquote>
<p>Callback that will get executed before retrying the request. If this function returns an object having url and/or options properties, they will override existing values in the retried request.</p>
</blockquote>
<blockquote>
<p><em>(default: null)</em></p>
</blockquote>
<ul>
<li><em>retryOnNetworkError</em> <code>boolean</code></li>
</ul>
<blockquote>
<p>If true, will retry the request if a network error was thrown. Will also provide an &#39;error&#39; argument to the <code>onRetry</code> and <code>until</code> methods.</p>
</blockquote>
<blockquote>
<p><em>(default: false)</em></p>
</blockquote>
<pre><code class="language-ts"><span class="hl-8">import</span><span class="hl-2"> </span><span class="hl-6">wretch</span><span class="hl-2"> </span><span class="hl-8">from</span><span class="hl-2"> </span><span class="hl-5">&#39;wretch&#39;</span><br/><span class="hl-8">import</span><span class="hl-2"> { </span><span class="hl-6">retry</span><span class="hl-2"> } </span><span class="hl-8">from</span><span class="hl-2"> </span><span class="hl-5">&#39;wretch/middlewares&#39;</span><br/><br/><span class="hl-4">wretch</span><span class="hl-2">().</span><span class="hl-4">middlewares</span><span class="hl-2">([</span><br/><span class="hl-2"> </span><span class="hl-4">retry</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-0">// Options - defaults below</span><br/><span class="hl-2"> </span><span class="hl-6">delayTimer:</span><span class="hl-2"> </span><span class="hl-7">500</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-4">delayRamp</span><span class="hl-6">:</span><span class="hl-2"> (</span><span class="hl-6">delay</span><span class="hl-2">, </span><span class="hl-6">nbOfAttempts</span><span class="hl-2">) </span><span class="hl-1">=&gt;</span><span class="hl-2"> </span><span class="hl-6">delay</span><span class="hl-2"> * </span><span class="hl-6">nbOfAttempts</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-6">maxAttempts:</span><span class="hl-2"> </span><span class="hl-7">10</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-4">until</span><span class="hl-6">:</span><span class="hl-2"> (</span><span class="hl-6">response</span><span class="hl-2">, </span><span class="hl-6">error</span><span class="hl-2">) </span><span class="hl-1">=&gt;</span><span class="hl-2"> </span><span class="hl-6">response</span><span class="hl-2"> &amp;&amp; </span><span class="hl-6">response</span><span class="hl-2">.</span><span class="hl-6">ok</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-6">onRetry:</span><span class="hl-2"> </span><span class="hl-1">null</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-6">retryOnNetworkError:</span><span class="hl-2"> </span><span class="hl-1">false</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-6">resolveWithLatestReponse:</span><span class="hl-2"> </span><span class="hl-1">false</span><br/><span class="hl-2"> })</span><br/><span class="hl-2">])</span><br/><br/><span class="hl-0">// You can also return a Promise, which is useful if you want to inspect the body:</span><br/><span class="hl-4">wretch</span><span class="hl-2">().</span><span class="hl-4">middlewares</span><span class="hl-2">([</span><br/><span class="hl-2"> </span><span class="hl-4">retry</span><span class="hl-2">({</span><br/><span class="hl-2"> </span><span class="hl-4">until</span><span class="hl-6">:</span><span class="hl-2"> </span><span class="hl-6">response</span><span class="hl-2"> </span><span class="hl-1">=&gt;</span><br/><span class="hl-2"> </span><span class="hl-6">response</span><span class="hl-2">.</span><span class="hl-4">clone</span><span class="hl-2">().</span><span class="hl-4">json</span><span class="hl-2">().</span><span class="hl-4">then</span><span class="hl-2">(</span><span class="hl-6">body</span><span class="hl-2"> </span><span class="hl-1">=&gt;</span><br/><span class="hl-2"> </span><span class="hl-6">body</span><span class="hl-2">.</span><span class="hl-6">field</span><span class="hl-2"> === </span><span class="hl-5">&#39;something&#39;</span><br/><span class="hl-2"> )</span><br/><span class="hl-2"> })</span><br/><span class="hl-2">])</span>
</code></pre>
</div>
<div class="tsd-parameters">
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -89,7 +36,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5><code class="tsd-tag ts-flagOptional">Optional</code> options: <a href="../types/middlewares_retry.RetryOptions.html" class="tsd-signature-type" data-tsd-kind="Type alias">RetryOptions</a></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../types/index.ConfiguredMiddleware.html" class="tsd-signature-type" data-tsd-kind="Type alias">ConfiguredMiddleware</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/middlewares/retry.ts#L66">src/middlewares/retry.ts:66</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/middlewares/retry.ts#L92">src/middlewares/retry.ts:92</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5><code class="tsd-tag ts-flagOptional">Optional</code> options: <a href="../types/middlewares_throttlingCache.ThrottlingCacheOptions.html" class="tsd-signature-type" data-tsd-kind="Type alias">ThrottlingCacheOptions</a></h5></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="../types/index.ConfiguredMiddleware.html" class="tsd-signature-type" data-tsd-kind="Type alias">ConfiguredMiddleware</a><span class="tsd-signature-symbol"> &amp; </span><span class="tsd-signature-symbol">{ </span>cache<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">; </span>inflight<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">; </span>throttling<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Set</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">; </span>cacheResponse<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> }</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/1981837/src/middlewares/throttlingCache.ts#L56">src/middlewares/throttlingCache.ts:56</a></li></ul></aside></li></ul></section></div>
<li>Defined in <a href="https://github.com/elbywan/wretch/blob/60a7453/src/middlewares/throttlingCache.ts#L56">src/middlewares/throttlingCache.ts:56</a></li></ul></aside></li></ul></section></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
Expand Down

0 comments on commit 7c5b224

Please sign in to comment.