@siteimprove/alfa-future 0.89.5

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,151 @@
1
+ # @siteimprove/alfa-future
2
+
3
+ ## 0.89.3
4
+
5
+ ## 0.89.2
6
+
7
+ ### Patch Changes
8
+
9
+ - **Changed:** Trying to fix a problem in generating provenance statements ([#1674](https://github.com/Siteimprove/alfa/pull/1674))
10
+
11
+ ## 0.89.1
12
+
13
+ ### Patch Changes
14
+
15
+ - **Added:** Trying to publish Alfa packages on the npm registry ([#1673](https://github.com/Siteimprove/alfa/pull/1673))
16
+
17
+ ## 0.89.0
18
+
19
+ ## 0.88.0
20
+
21
+ ### Minor Changes
22
+
23
+ - **Fixed:** The publish flow was updated to a new version. ([`a2f19cf9a6c7c72b8bf085597e4f1a95ac3e4eb2`](https://github.com/Siteimprove/alfa/commit/a2f19cf9a6c7c72b8bf085597e4f1a95ac3e4eb2))
24
+
25
+ Some 0.87.\* versions were generating uninstallable package. This should be fixed now.
26
+
27
+ ## 0.87.12
28
+
29
+ ## 0.87.11
30
+
31
+ ## 0.87.10
32
+
33
+ ## 0.87.7
34
+
35
+ ## 0.87.6
36
+
37
+ ## 0.87.5
38
+
39
+ ## 0.87.4
40
+
41
+ ## 0.87.3
42
+
43
+ ## 0.87.2
44
+
45
+ ## 0.87.1
46
+
47
+ ## 0.87.0
48
+
49
+ ## 0.86.2
50
+
51
+ ## 0.86.1
52
+
53
+ ## 0.86.0
54
+
55
+ ### Minor Changes
56
+
57
+ - **Breaking:** TS resolution has been changed to `Node16`, target to `es2022`. ([#1636](https://github.com/Siteimprove/alfa/pull/1636))
58
+
59
+ - **Breaking:** Alfa is now distributed as ESM rather than CJS modules; projects using it must be ESM or use dynamic `import()`. ([#1636](https://github.com/Siteimprove/alfa/pull/1636))
60
+
61
+ ⚠️ This is the last of a series of changes on the internal structure and build process of distributed packages that was started with v0.85.0.
62
+
63
+ ## 0.85.1
64
+
65
+ ## 0.85.0
66
+
67
+ ### Minor Changes
68
+
69
+ - **Breaking:** The .js files are now built in the `dist` folder rather than in `src`. ([#1628](https://github.com/Siteimprove/alfa/pull/1628))
70
+
71
+ ⚠️ This is the first of a series of changes on the internal structure and build process of distributed packages. It is probably better to not use this version and wait until more of these internal changes have been done to jump directly to the final result. We are internally releasing these changes for validation purpose only.
72
+
73
+ This should not impact consumers, the `package.json` files should be set correctly to consume these files.
74
+
75
+ ## 0.84.0
76
+
77
+ ## 0.83.1
78
+
79
+ ## 0.83.0
80
+
81
+ ## 0.82.0
82
+
83
+ ### Minor Changes
84
+
85
+ - **Breaking:** Node 18 is no longer supported. ([#1618](https://github.com/Siteimprove/alfa/pull/1618))
86
+
87
+ ## 0.81.0
88
+
89
+ ### Patch Changes
90
+
91
+ - **Added:** Each package now contains its internal dependency graph in its `docs` directory. ([#1610](https://github.com/Siteimprove/alfa/pull/1610))
92
+
93
+ ## 0.80.0
94
+
95
+ ## 0.79.1
96
+
97
+ ## 0.79.0
98
+
99
+ ## 0.78.2
100
+
101
+ ## 0.78.1
102
+
103
+ ## 0.78.0
104
+
105
+ ## 0.77.0
106
+
107
+ ## 0.76.0
108
+
109
+ ## 0.75.2
110
+
111
+ ## 0.75.1
112
+
113
+ ## 0.75.0
114
+
115
+ ## 0.74.0
116
+
117
+ ## 0.73.0
118
+
119
+ ## 0.72.0
120
+
121
+ ## 0.71.1
122
+
123
+ ## 0.71.0
124
+
125
+ ## 0.70.0
126
+
127
+ ## 0.69.0
128
+
129
+ ## 0.68.0
130
+
131
+ ## 0.67.0
132
+
133
+ ## 0.66.0
134
+
135
+ ## 0.65.1
136
+
137
+ ## 0.65.0
138
+
139
+ ## 0.64.0
140
+
141
+ ## 0.63.3
142
+
143
+ ## 0.63.2
144
+
145
+ ## 0.63.1
146
+
147
+ ## 0.63.0
148
+
149
+ ## 0.62.2
150
+
151
+ ## 0.62.1
@@ -0,0 +1,47 @@
1
+ import type { Applicative } from "@siteimprove/alfa-applicative";
2
+ import type { Callback } from "@siteimprove/alfa-callback";
3
+ import type { Continuation } from "@siteimprove/alfa-continuation";
4
+ import type { Functor } from "@siteimprove/alfa-functor";
5
+ import { Iterable } from "@siteimprove/alfa-iterable";
6
+ import type { Mapper } from "@siteimprove/alfa-mapper";
7
+ import type { Monad } from "@siteimprove/alfa-monad";
8
+ import type { Thenable } from "@siteimprove/alfa-thenable";
9
+ import type { Thunk } from "@siteimprove/alfa-thunk";
10
+ /**
11
+ * {@link http://blog.higher-order.com/assets/trampolines.pdf}
12
+ *
13
+ * @public
14
+ */
15
+ export declare abstract class Future<T> implements Functor<T>, Applicative<T>, Monad<T>, Thenable<T>, AsyncIterable<T> {
16
+ protected abstract step(): Future<T>;
17
+ then(callback: Callback<T>): void;
18
+ get(): T;
19
+ abstract isNow(): boolean;
20
+ abstract isDeferred(): boolean;
21
+ abstract isSuspended(): boolean;
22
+ map<U>(mapper: Mapper<T, U>): Future<U>;
23
+ apply<U>(mapper: Future<Mapper<T, U>>): Future<U>;
24
+ abstract flatMap<U>(mapper: Mapper<T, Future<U>>): Future<U>;
25
+ flatten<T>(this: Future<Future<T>>): Future<T>;
26
+ tee(callback: Callback<T>): Future<T>;
27
+ asyncIterator(): AsyncIterator<T>;
28
+ [Symbol.asyncIterator](): AsyncIterator<T>;
29
+ toPromise(): Promise<T>;
30
+ }
31
+ /**
32
+ * @public
33
+ */
34
+ export declare namespace Future {
35
+ type Maybe<T> = T | Future<T>;
36
+ function isFuture<T>(value: AsyncIterable<T>): value is Future<T>;
37
+ function isFuture<T>(value: unknown): value is Future<T>;
38
+ function empty(): Future<void>;
39
+ function now<T>(value: T): Future<T>;
40
+ function defer<T>(continuation: Continuation<T>): Future<T>;
41
+ function suspend<T>(thunk: Thunk<Future<T>>): Future<T>;
42
+ function delay<T>(thunk: Thunk<T>): Future<T>;
43
+ function from<T>(promise: Promise<T> | Thunk<Promise<T>>): Future<T>;
44
+ function traverse<T, U>(values: Iterable<T>, mapper: Mapper<T, Future<U>, [index: number]>): Future<Iterable<U>>;
45
+ function sequence<T>(futures: Iterable<Future<T>>): Future<Iterable<T>>;
46
+ }
47
+ //# sourceMappingURL=future.d.ts.map
package/dist/future.js ADDED
@@ -0,0 +1,258 @@
1
+ import { Array } from "@siteimprove/alfa-array";
2
+ import { Iterable } from "@siteimprove/alfa-iterable";
3
+ /**
4
+ * {@link http://blog.higher-order.com/assets/trampolines.pdf}
5
+ *
6
+ * @public
7
+ */
8
+ export class Future {
9
+ then(callback) {
10
+ let step = this;
11
+ while (true) {
12
+ const next = step.step();
13
+ if (step !== next) {
14
+ step = next;
15
+ }
16
+ else {
17
+ return next.then(callback);
18
+ }
19
+ }
20
+ }
21
+ get() {
22
+ let step = this;
23
+ while (true) {
24
+ const next = step.step();
25
+ if (step !== next) {
26
+ step = next;
27
+ }
28
+ else {
29
+ return next.get();
30
+ }
31
+ }
32
+ }
33
+ map(mapper) {
34
+ return this.flatMap((value) => Now.of(mapper(value)));
35
+ }
36
+ apply(mapper) {
37
+ return mapper.flatMap((mapper) => this.map(mapper));
38
+ }
39
+ flatten() {
40
+ return this.flatMap((future) => future);
41
+ }
42
+ tee(callback) {
43
+ return this.map((value) => {
44
+ callback(value);
45
+ return value;
46
+ });
47
+ }
48
+ async *asyncIterator() {
49
+ yield this.toPromise();
50
+ }
51
+ [Symbol.asyncIterator]() {
52
+ return this.asyncIterator();
53
+ }
54
+ toPromise() {
55
+ return new Promise((resolve) => this.then(resolve));
56
+ }
57
+ }
58
+ /**
59
+ * @public
60
+ */
61
+ (function (Future) {
62
+ function isFuture(value) {
63
+ return value instanceof Future;
64
+ }
65
+ Future.isFuture = isFuture;
66
+ function empty() {
67
+ return now(undefined);
68
+ }
69
+ Future.empty = empty;
70
+ function now(value) {
71
+ return Now.of(value);
72
+ }
73
+ Future.now = now;
74
+ function defer(continuation) {
75
+ return Defer.of(continuation);
76
+ }
77
+ Future.defer = defer;
78
+ function suspend(thunk) {
79
+ return Suspend.of(thunk);
80
+ }
81
+ Future.suspend = suspend;
82
+ function delay(thunk) {
83
+ return suspend(() => now(thunk()));
84
+ }
85
+ Future.delay = delay;
86
+ function from(promise) {
87
+ return Future.defer((callback) => (typeof promise === "function" ? promise() : promise).then(callback));
88
+ }
89
+ Future.from = from;
90
+ function traverse(values, mapper) {
91
+ return Iterable.reduce(values, (values, value, i) => values.flatMap((values) => mapper(value, i).map((value) => Array.append(values, value))), now(Array.empty()));
92
+ }
93
+ Future.traverse = traverse;
94
+ function sequence(futures) {
95
+ return traverse(futures, (value) => value);
96
+ }
97
+ Future.sequence = sequence;
98
+ })(Future || (Future = {}));
99
+ class Now extends Future {
100
+ static of(value) {
101
+ return new Now(value);
102
+ }
103
+ _value;
104
+ constructor(value) {
105
+ super();
106
+ this._value = value;
107
+ }
108
+ step() {
109
+ return this;
110
+ }
111
+ then(callback) {
112
+ callback(this._value);
113
+ }
114
+ get() {
115
+ return this._value;
116
+ }
117
+ isNow() {
118
+ return true;
119
+ }
120
+ isDeferred() {
121
+ return false;
122
+ }
123
+ isSuspended() {
124
+ return false;
125
+ }
126
+ map(mapper) {
127
+ return new Now(mapper(this._value));
128
+ }
129
+ flatMap(mapper) {
130
+ return Suspend.of(() => mapper(this._value));
131
+ }
132
+ }
133
+ class Defer extends Future {
134
+ static of(continuation) {
135
+ return new Defer(continuation);
136
+ }
137
+ _continuation;
138
+ constructor(continuation) {
139
+ super();
140
+ this._continuation = continuation;
141
+ }
142
+ step() {
143
+ return this;
144
+ }
145
+ then(callback) {
146
+ this._continuation((value) => defer(() => callback(value)));
147
+ }
148
+ get() {
149
+ throw new Error("Attempted to .get() from deferred future");
150
+ }
151
+ isNow() {
152
+ return false;
153
+ }
154
+ isDeferred() {
155
+ return true;
156
+ }
157
+ isSuspended() {
158
+ return false;
159
+ }
160
+ flatMap(mapper) {
161
+ return Defer.Bind.of(this._continuation, mapper);
162
+ }
163
+ }
164
+ (function (Defer) {
165
+ class Bind extends Future {
166
+ static of(continuation, mapper) {
167
+ return new Bind(continuation, mapper);
168
+ }
169
+ _continuation;
170
+ _mapper;
171
+ constructor(continuation, mapper) {
172
+ super();
173
+ this._continuation = continuation;
174
+ this._mapper = mapper;
175
+ }
176
+ step() {
177
+ return this;
178
+ }
179
+ then(callback) {
180
+ this._continuation((value) => defer(() => this._mapper(value).then(callback)));
181
+ }
182
+ get() {
183
+ throw new Error("Attempted to .get() from deferred future");
184
+ }
185
+ isNow() {
186
+ return false;
187
+ }
188
+ isDeferred() {
189
+ return true;
190
+ }
191
+ isSuspended() {
192
+ return false;
193
+ }
194
+ flatMap(mapper) {
195
+ return Suspend.of(() => Bind.of(this._continuation, (value) => this._mapper(value).flatMap(mapper)));
196
+ }
197
+ }
198
+ Defer.Bind = Bind;
199
+ })(Defer || (Defer = {}));
200
+ class Suspend extends Future {
201
+ static of(thunk) {
202
+ return new Suspend(thunk);
203
+ }
204
+ _thunk;
205
+ constructor(thunk) {
206
+ super();
207
+ this._thunk = thunk;
208
+ }
209
+ step() {
210
+ return this._thunk();
211
+ }
212
+ isNow() {
213
+ return false;
214
+ }
215
+ isDeferred() {
216
+ return false;
217
+ }
218
+ isSuspended() {
219
+ return true;
220
+ }
221
+ flatMap(mapper) {
222
+ return Suspend.Bind.of(this._thunk, mapper);
223
+ }
224
+ }
225
+ (function (Suspend) {
226
+ class Bind extends Future {
227
+ static of(thunk, mapper) {
228
+ return new Bind(thunk, mapper);
229
+ }
230
+ _thunk;
231
+ _mapper;
232
+ constructor(thunk, mapper) {
233
+ super();
234
+ this._thunk = thunk;
235
+ this._mapper = mapper;
236
+ }
237
+ step() {
238
+ return this._thunk().flatMap(this._mapper);
239
+ }
240
+ isNow() {
241
+ return false;
242
+ }
243
+ isDeferred() {
244
+ return false;
245
+ }
246
+ isSuspended() {
247
+ return true;
248
+ }
249
+ flatMap(mapper) {
250
+ return Suspend.of(() => Bind.of(this._thunk, (value) => this._mapper(value).flatMap(mapper)));
251
+ }
252
+ }
253
+ Suspend.Bind = Bind;
254
+ })(Suspend || (Suspend = {}));
255
+ async function defer(thunk) {
256
+ return Promise.resolve().then(thunk);
257
+ }
258
+ //# sourceMappingURL=future.js.map
@@ -0,0 +1,2 @@
1
+ export * from "./future.js";
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./future.js";
2
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/package",
3
+ "name": "@siteimprove/alfa-future",
4
+ "homepage": "https://alfa.siteimprove.com",
5
+ "version": "0.89.5",
6
+ "license": "MIT",
7
+ "description": "An implementation of futures, which are a lazy version of promises for dealing with possibly asynchronous control flow",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "github:Siteimprove/alfa",
11
+ "directory": "packages/alfa-future"
12
+ },
13
+ "bugs": "https://github.com/siteimprove/alfa/issues",
14
+ "engines": {
15
+ "node": ">=20.0.0"
16
+ },
17
+ "type": "module",
18
+ "main": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "files": [
21
+ "dist/**/*.js",
22
+ "dist/**/*.d.ts"
23
+ ],
24
+ "dependencies": {
25
+ "@siteimprove/alfa-applicative": "^0.89.5",
26
+ "@siteimprove/alfa-array": "^0.89.5",
27
+ "@siteimprove/alfa-callback": "^0.89.5",
28
+ "@siteimprove/alfa-continuation": "^0.89.5",
29
+ "@siteimprove/alfa-functor": "^0.89.5",
30
+ "@siteimprove/alfa-iterable": "^0.89.5",
31
+ "@siteimprove/alfa-mapper": "^0.89.5",
32
+ "@siteimprove/alfa-monad": "^0.89.5",
33
+ "@siteimprove/alfa-thenable": "^0.89.5",
34
+ "@siteimprove/alfa-thunk": "^0.89.5"
35
+ },
36
+ "devDependencies": {
37
+ "@siteimprove/alfa-test": "^0.89.5"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "registry": "https://npm.pkg.github.com/"
42
+ }
43
+ }