Skip to content

Commit 7c5b224

Browse files
committed
2.1.0 tag
1 parent 60a7453 commit 7c5b224

File tree

70 files changed

+220
-289
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+220
-289
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
<a name="2.1.0"></a>
2+
# [2.1.0](https://github.com/elbywan/wretch/compare/2.0.4...2.1.0) (2022-09-03)
3+
4+
5+
### :factory: New feature(s)
6+
7+
* 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)
8+
9+
### :memo: Documentation update(s)
10+
11+
* Remove outdated documentation entries for the retry middleware ([7a5620c](https://github.com/elbywan/wretch/commit/7a5620c))
12+
13+
14+
115
<a name="2.0.4"></a>
216
## [2.0.4](https://github.com/elbywan/wretch/compare/2.0.3...2.0.4) (2022-08-18)
317

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<br>
2121

22-
##### 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.
22+
##### 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.
2323

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

docs/api/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/functions/addons_abort.default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1>Function default</h1></div>
2828
</div>
2929
<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">
3030
<ul>
31-
<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>
31+
<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>
3232
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
3333
<div class="tsd-navigation settings">
3434
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

docs/api/functions/addons_perfs.default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>Function default</h1></div>
3232
</div>
3333
<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">
3434
<ul>
35-
<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>
35+
<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>
3636
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
3737
<div class="tsd-navigation settings">
3838
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

docs/api/functions/index.default-1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h5>_options: <span class="tsd-signature-symbol">{}</span><span class="tsd-signa
3939
<ul class="tsd-parameters"></ul></li></ul></div>
4040
<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">
4141
<ul>
42-
<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>
42+
<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>
4343
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
4444
<div class="tsd-navigation settings">
4545
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

docs/api/functions/middlewares_dedupe.dedupe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
5454
<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>
5555
<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">
5656
<ul>
57-
<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>
57+
<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>
5858
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
5959
<div class="tsd-navigation settings">
6060
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

docs/api/functions/middlewares_delay.delay.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
4141
<h5>time: <span class="tsd-signature-type">number</span></h5></li></ul></div>
4242
<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">
4343
<ul>
44-
<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>
44+
<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>
4545
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
4646
<div class="tsd-navigation settings">
4747
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

docs/api/functions/middlewares_retry.retry.html

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,61 +26,8 @@ <h2>Retry middleware</h2>
2626
<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;">
2727
<h4>Retries a request multiple times in case of an error (or until a custom condition is true).</h4>
2828
</a>
29-
<p><strong>Options</strong></p>
30-
<ul>
31-
<li><em>delayTimer</em> <code>milliseconds</code></li>
32-
</ul>
33-
<blockquote>
34-
<p>The timer between each attempt.</p>
35-
</blockquote>
36-
<blockquote>
37-
<p><em>(default: 500)</em></p>
38-
</blockquote>
39-
<ul>
40-
<li><em>delayRamp</em> <code>(delay, nbOfAttempts) =&gt; milliseconds</code></li>
41-
</ul>
42-
<blockquote>
43-
<p>The custom function that is used to calculate the actual delay based on the the timer &amp; the number of attemps.</p>
44-
</blockquote>
45-
<blockquote>
46-
<p><em>(default: delay * nbOfAttemps)</em></p>
47-
</blockquote>
48-
<ul>
49-
<li><em>maxAttempts</em> <code>number</code></li>
50-
</ul>
51-
<blockquote>
52-
<p>The maximum number of retries before resolving the promise with the last error. Specifying 0 means infinite retries.</p>
53-
</blockquote>
54-
<blockquote>
55-
<p><em>(default: 10)</em></p>
56-
</blockquote>
57-
<ul>
58-
<li><em>until</em> <code>(response, error) =&gt; boolean || Promise&lt;boolean&gt;</code></li>
59-
</ul>
60-
<blockquote>
61-
<p>The request will be retried until that condition is satisfied.</p>
62-
</blockquote>
63-
<blockquote>
64-
<p><em>(default: response &amp;&amp; response.ok)</em></p>
65-
</blockquote>
66-
<ul>
67-
<li><em>onRetry</em> <code>({ response, error, url, options }) =&gt; { url?, options? } || Promise&lt;{url?, options?}&gt;</code></li>
68-
</ul>
69-
<blockquote>
70-
<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>
71-
</blockquote>
72-
<blockquote>
73-
<p><em>(default: null)</em></p>
74-
</blockquote>
75-
<ul>
76-
<li><em>retryOnNetworkError</em> <code>boolean</code></li>
77-
</ul>
78-
<blockquote>
79-
<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>
80-
</blockquote>
81-
<blockquote>
82-
<p><em>(default: false)</em></p>
83-
</blockquote>
29+
<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>
30+
</code></pre>
8431
</div>
8532
<div class="tsd-parameters">
8633
<h4 class="tsd-parameters-title">Parameters</h4>
@@ -89,7 +36,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
8936
<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>
9037
<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">
9138
<ul>
92-
<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>
39+
<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>
9340
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
9441
<div class="tsd-navigation settings">
9542
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

docs/api/functions/middlewares_throttlingCache.throttlingCache.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
7777
<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>
7878
<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">
7979
<ul>
80-
<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>
80+
<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>
8181
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
8282
<div class="tsd-navigation settings">
8383
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">

0 commit comments

Comments
 (0)