@zemnmez/future 1.0.1 → 1.0.3

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 +11 -13
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # `@zemnmez/future`
2
2
 
3
+ [View `@zemnmez/future` on npm](https://www.npmjs.com/package/@zemnmez/future)
4
+
3
5
  `@zemnmez/future` is a tiny TypeScript type for a value that may be loading,
4
6
  resolved, or errored. A `Future<Then, Loading, Error>` represents all three
5
7
  states exactly and requires each state to be handled before its resolved value
@@ -71,21 +73,21 @@ const message = future(
71
73
  ```
72
74
 
73
75
  `future_and_then` maps a resolved value while preserving the loading and error
74
- types. `future_flatten_then` flattens nested Futures, and `future_collect`
75
- combines several Futures into one.
76
+ types. `future_coincide_then` chains a Future-returning operation, and
77
+ `future_collect` combines several Futures into one.
76
78
 
77
79
  ## Pipelines
78
80
 
79
- `future_and_then` and `future_flatten_then` compose Future-returning operations
80
- into a pipeline. Each operation receives the preceding resolved value, while a
81
- loading or error state stops the pipeline:
81
+ `future_coincide_then` composes Future-returning operations into a pipeline.
82
+ Each operation receives the preceding resolved value, while a loading or error
83
+ state stops the pipeline. The resulting Future includes the loading and error
84
+ types from every operation:
82
85
 
83
86
  ```typescript
84
87
  import {
85
88
  error,
86
89
  Future,
87
- future_and_then,
88
- future_flatten_then,
90
+ future_coincide_then,
89
91
  resolve,
90
92
  } from '@zemnmez/future';
91
93
 
@@ -106,12 +108,8 @@ const displayName = (
106
108
  ): Future<string, 'formatting name', 'missing name'> =>
107
109
  user.name ? resolve(user.name) : error('missing name');
108
110
 
109
- const user = future_flatten_then(
110
- future_and_then(resolve(42), findUser)
111
- );
112
- const name = future_flatten_then(
113
- future_and_then(user, displayName)
114
- );
111
+ const user = future_coincide_then(resolve(42), findUser);
112
+ const name = future_coincide_then(user, displayName);
115
113
  // Future<
116
114
  // string,
117
115
  // 'fetching user' | 'formatting name',
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "publishConfig": {
19
19
  "access": "public"
20
20
  },
21
- "version": "1.0.1",
21
+ "version": "1.0.3",
22
22
  "dependencies": {
23
23
  "@tanstack/react-query": "5.101.4",
24
24
  "react": "19.2.8"
@@ -33,6 +33,6 @@
33
33
  "directory": "ts/future"
34
34
  },
35
35
  "bugs": {
36
- "url": "https://github.com/zemn-me/monorepo/issues/new?title=%2F%2Fts%2Ffuture%401.0.1%3A+something+went+wrong%21"
36
+ "url": "https://github.com/zemn-me/monorepo/issues/new?title=%2F%2Fts%2Ffuture%401.0.3%3A+something+went+wrong%21"
37
37
  }
38
38
  }