@nlozgachev/pipelined 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +8 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -192,6 +192,7 @@ With **pipelined**:
192
192
 
193
193
  ```ts
194
194
  import { Op } from "@nlozgachev/pipelined/core";
195
+ import { Duration } from "@nlozgachev/pipelined/types";
195
196
 
196
197
  const fetchUser = Op.interpret(
197
198
  Op.create(
@@ -201,8 +202,11 @@ const fetchUser = Op.interpret(
201
202
  ),
202
203
  {
203
204
  strategy: "restartable",
204
- retry: { attempts: 3, backoff: (n) => n * 1000 },
205
- timeout: { ms: 5000, onTimeout: () => new ApiError("request timed out") },
205
+ retry: { attempts: 3, backoff: (n) => Duration.seconds(n) },
206
+ timeout: {
207
+ duration: Duration.seconds(5),
208
+ onTimeout: () => new ApiError("request timed out"),
209
+ },
206
210
  },
207
211
  );
208
212
  ```
@@ -236,6 +240,7 @@ different answer to the same question: *what happens to the previous call when a
236
240
 
237
241
  ```ts
238
242
  import { Op } from "@nlozgachev/pipelined/core";
243
+ import { Duration } from "@nlozgachev/pipelined/types";
239
244
 
240
245
  const searchOp = Op.create(
241
246
  (signal) => (query: string) =>
@@ -247,7 +252,7 @@ const searchOp = Op.create(
247
252
 
248
253
  const search = Op.interpret(searchOp, {
249
254
  strategy: "restartable", // new call cancels the previous one
250
- retry: { attempts: 2, backoff: 300 },
255
+ retry: { attempts: 2, backoff: Duration.milliseconds(300) },
251
256
  });
252
257
 
253
258
  search.subscribe((state) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlozgachev/pipelined",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Opinionated functional abstractions for TypeScript",
5
5
  "license": "BSD-3-Clause",
6
6
  "homepage": "https://pipelined.lozgachev.dev",