@nlozgachev/pipelined 0.28.0 → 0.30.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.
@@ -3,7 +3,7 @@ import {
3
3
  Maybe,
4
4
  Result,
5
5
  Task
6
- } from "./chunk-7JF44HJH.mjs";
6
+ } from "./chunk-SDGDJ7CU.mjs";
7
7
 
8
8
  // src/Core/Lens.ts
9
9
  var Lens;
@@ -55,14 +55,14 @@ var Logged;
55
55
  })(Logged || (Logged = {}));
56
56
 
57
57
  // src/internal/Op.util.ts
58
- var _abortedNil = { kind: "Nil", reason: "aborted" };
59
- var _droppedNil = { kind: "Nil", reason: "dropped" };
60
- var _replacedNil = { kind: "Nil", reason: "replaced" };
61
- var _evictedNil = { kind: "Nil", reason: "evicted" };
58
+ var _abortedNil = { kind: "OpNil", reason: "aborted" };
59
+ var _droppedNil = { kind: "OpNil", reason: "dropped" };
60
+ var _replacedNil = { kind: "OpNil", reason: "replaced" };
61
+ var _evictedNil = { kind: "OpNil", reason: "evicted" };
62
62
  var _idle = { kind: "Idle" };
63
63
  var _pending = { kind: "Pending" };
64
- var ok = (value) => ({ kind: "Ok", value });
65
- var err = (error) => ({ kind: "Err", error });
64
+ var ok = (value) => ({ kind: "OpOk", value });
65
+ var err = (error) => ({ kind: "OpError", error });
66
66
  var cancellableWait = (ms, signal) => {
67
67
  if (ms <= 0) return Promise.resolve();
68
68
  return new Promise((resolve) => {
@@ -185,6 +185,12 @@ var makeRestartable = (op, minInterval, retryOptions, timeoutOptions) => {
185
185
  subscribers.add(cb);
186
186
  if (currentState.kind !== "Idle") cb(currentState);
187
187
  return () => subscribers.delete(cb);
188
+ },
189
+ reset: () => emit(_idle),
190
+ poll: (input, { interval }) => {
191
+ void run(input);
192
+ const id = setInterval(() => void run(input), interval);
193
+ return () => clearInterval(id);
188
194
  }
189
195
  };
190
196
  };
@@ -249,6 +255,12 @@ var makeExclusive = (op, cooldown, retryOptions, timeoutOptions) => {
249
255
  subscribers.add(cb);
250
256
  if (currentState.kind !== "Idle") cb(currentState);
251
257
  return () => subscribers.delete(cb);
258
+ },
259
+ reset: () => emit(_idle),
260
+ poll: (input, { interval }) => {
261
+ void run(input);
262
+ const id = setInterval(() => void run(input), interval);
263
+ return () => clearInterval(id);
252
264
  }
253
265
  };
254
266
  };
@@ -348,6 +360,12 @@ var makeQueue = (op, maxSize, overflow, concurrency, dedupe, retryOptions, timeo
348
360
  subscribers.add(cb);
349
361
  if (currentState.kind !== "Idle") cb(currentState);
350
362
  return () => subscribers.delete(cb);
363
+ },
364
+ reset: () => emit(_idle),
365
+ poll: (input, { interval }) => {
366
+ void run(input);
367
+ const id = setInterval(() => void run(input), interval);
368
+ return () => clearInterval(id);
351
369
  }
352
370
  };
353
371
  };
@@ -418,6 +436,12 @@ var makeBuffered = (op, size, retryOptions, timeoutOptions) => {
418
436
  subscribers.add(cb);
419
437
  if (currentState.kind !== "Idle") cb(currentState);
420
438
  return () => subscribers.delete(cb);
439
+ },
440
+ reset: () => emit(_idle),
441
+ poll: (input, { interval }) => {
442
+ void run(input);
443
+ const id = setInterval(() => void run(input), interval);
444
+ return () => clearInterval(id);
421
445
  }
422
446
  };
423
447
  };
@@ -540,6 +564,12 @@ var makeDebounced = (op, ms, leading, maxWait, retryOptions, timeoutOptions) =>
540
564
  subscribers.add(cb);
541
565
  if (currentState.kind !== "Idle") cb(currentState);
542
566
  return () => subscribers.delete(cb);
567
+ },
568
+ reset: () => emit(_idle),
569
+ poll: (input, { interval }) => {
570
+ void run(input);
571
+ const id = setInterval(() => void run(input), interval);
572
+ return () => clearInterval(id);
543
573
  }
544
574
  };
545
575
  };
@@ -632,6 +662,12 @@ var makeThrottled = (op, ms, trailing, retryOptions, timeoutOptions) => {
632
662
  subscribers.add(cb);
633
663
  if (currentState.kind !== "Idle") cb(currentState);
634
664
  return () => subscribers.delete(cb);
665
+ },
666
+ reset: () => emit(_idle),
667
+ poll: (input, { interval }) => {
668
+ void run(input);
669
+ const id = setInterval(() => void run(input), interval);
670
+ return () => clearInterval(id);
635
671
  }
636
672
  };
637
673
  };
@@ -713,6 +749,12 @@ var makeConcurrent = (op, n, overflow, retryOptions, timeoutOptions) => {
713
749
  subscribers.add(cb);
714
750
  if (currentState.kind !== "Idle") cb(currentState);
715
751
  return () => subscribers.delete(cb);
752
+ },
753
+ reset: () => emit(_idle),
754
+ poll: (input, { interval }) => {
755
+ void run(input);
756
+ const id = setInterval(() => void run(input), interval);
757
+ return () => clearInterval(id);
716
758
  }
717
759
  };
718
760
  };
@@ -789,6 +831,15 @@ var makeKeyed = (op, keyFn, perKey, timeoutOptions) => {
789
831
  subscribers.add(cb);
790
832
  if (stateMap.size > 0) cb(new Map(stateMap));
791
833
  return () => subscribers.delete(cb);
834
+ },
835
+ reset: () => {
836
+ stateMap.clear();
837
+ emitSnapshot();
838
+ },
839
+ poll: (input, { interval }) => {
840
+ void run(input);
841
+ const id = setInterval(() => void run(input), interval);
842
+ return () => clearInterval(id);
792
843
  }
793
844
  };
794
845
  };
@@ -843,6 +894,12 @@ var makeOnce = (op, retryOptions, timeoutOptions) => {
843
894
  subscribers.add(cb);
844
895
  if (currentState.kind !== "Idle") cb(currentState);
845
896
  return () => subscribers.delete(cb);
897
+ },
898
+ reset: () => emit(_idle),
899
+ poll: (input, { interval }) => {
900
+ void run(input);
901
+ const id = setInterval(() => void run(input), interval);
902
+ return () => clearInterval(id);
846
903
  }
847
904
  };
848
905
  };
@@ -850,44 +907,59 @@ var makeOnce = (op, retryOptions, timeoutOptions) => {
850
907
  // src/Core/Op.ts
851
908
  var Op;
852
909
  ((Op2) => {
853
- Op2.nil = (reason) => ({ kind: "Nil", reason });
910
+ Op2.nil = (reason) => ({ kind: "OpNil", reason });
854
911
  Op2.create = (factory, onError) => ({
855
912
  _factory: (input, signal) => Deferred.fromPromise(
856
- factory(signal)(input).then((value) => Result.ok(value)).catch((e) => signal.aborted ? null : Result.err(onError(e)))
913
+ factory(signal)(input).then((value) => Result.ok(value)).catch((e) => signal.aborted ? null : Result.error(onError(e)))
857
914
  )
858
915
  });
859
- Op2.ok = (value) => ({ kind: "Ok", value });
860
- Op2.err = (error) => ({ kind: "Err", error });
861
- Op2.isOk = (outcome) => outcome.kind === "Ok";
862
- Op2.isErr = (outcome) => outcome.kind === "Err";
863
- Op2.isNil = (outcome) => outcome.kind === "Nil";
916
+ Op2.lift = (f) => (0, Op2.create)(
917
+ (signal) => (input) => f(input, signal),
918
+ (e) => e
919
+ );
920
+ Op2.ok = (value) => ({ kind: "OpOk", value });
921
+ Op2.error = (error2) => ({ kind: "OpError", error: error2 });
922
+ Op2.isIdle = (state) => state.kind === "Idle";
923
+ Op2.isPending = (state) => state.kind === "Pending";
924
+ Op2.isQueued = (state) => state.kind === "Queued";
925
+ Op2.isRetrying = (state) => state.kind === "Retrying";
926
+ Op2.isOk = (state) => state.kind === "OpOk";
927
+ Op2.isError = (state) => state.kind === "OpError";
928
+ Op2.isNil = (state) => state.kind === "OpNil";
864
929
  Op2.match = (cases) => (outcome) => {
865
- if (outcome.kind === "Ok") return cases.ok(outcome.value);
866
- if (outcome.kind === "Err") return cases.err(outcome.error);
930
+ if (outcome.kind === "OpOk") return cases.ok(outcome.value);
931
+ if (outcome.kind === "OpError") return cases.error(outcome.error);
867
932
  return cases.nil();
868
933
  };
869
- Op2.fold = (onErr, onOk, onNil) => (outcome) => {
870
- if (outcome.kind === "Ok") return onOk(outcome.value);
871
- if (outcome.kind === "Err") return onErr(outcome.error);
934
+ Op2.fold = (onError, onOk, onNil) => (outcome) => {
935
+ if (outcome.kind === "OpOk") return onOk(outcome.value);
936
+ if (outcome.kind === "OpError") return onError(outcome.error);
872
937
  return onNil();
873
938
  };
874
- Op2.getOrElse = (defaultValue) => (outcome) => outcome.kind === "Ok" ? outcome.value : defaultValue();
875
- Op2.map = (f) => (outcome) => outcome.kind === "Ok" ? (0, Op2.ok)(f(outcome.value)) : outcome;
876
- Op2.mapError = (f) => (outcome) => outcome.kind === "Err" ? (0, Op2.err)(f(outcome.error)) : outcome;
877
- Op2.chain = (f) => (outcome) => outcome.kind === "Ok" ? f(outcome.value) : outcome;
939
+ Op2.getOrElse = (defaultValue) => (outcome) => outcome.kind === "OpOk" ? outcome.value : defaultValue();
940
+ Op2.map = (f) => (outcome) => outcome.kind === "OpOk" ? (0, Op2.ok)(f(outcome.value)) : outcome;
941
+ Op2.mapError = (f) => (outcome) => outcome.kind === "OpError" ? (0, Op2.error)(f(outcome.error)) : outcome;
942
+ Op2.chain = (f) => (outcome) => outcome.kind === "OpOk" ? f(outcome.value) : outcome;
878
943
  Op2.tap = (f) => (outcome) => {
879
- if (outcome.kind === "Ok") f(outcome.value);
944
+ if (outcome.kind === "OpOk") f(outcome.value);
880
945
  return outcome;
881
946
  };
882
- Op2.recover = (f) => (outcome) => outcome.kind === "Err" ? f(outcome.error) : outcome;
947
+ Op2.recover = (f) => (outcome) => outcome.kind === "OpError" ? f(outcome.error) : outcome;
883
948
  Op2.toResult = (onNil) => (outcome) => {
884
- if (outcome.kind === "Ok") return Result.ok(outcome.value);
885
- if (outcome.kind === "Err") return Result.err(outcome.error);
886
- return Result.err(onNil());
949
+ if (outcome.kind === "OpOk") return Result.ok(outcome.value);
950
+ if (outcome.kind === "OpError") return Result.error(outcome.error);
951
+ return Result.error(onNil());
887
952
  };
888
- Op2.toMaybe = (outcome) => outcome.kind === "Ok" ? Maybe.some(outcome.value) : Maybe.none();
953
+ Op2.toMaybe = (outcome) => outcome.kind === "OpOk" ? Maybe.some(outcome.value) : Maybe.none();
889
954
  Op2.all = (invocations) => Deferred.fromPromise(Promise.all(invocations.map(Deferred.toPromise)));
890
955
  Op2.race = (invocations) => Deferred.fromPromise(Promise.race(invocations.map(Deferred.toPromise)));
956
+ Op2.wire = (source, f) => source.subscribe((state) => {
957
+ if ((0, Op2.isOk)(state)) f(state.value);
958
+ });
959
+ Op2.wireAll = (...pairs) => {
960
+ const cleanups = pairs.map(([source, f]) => (0, Op2.wire)(source, f));
961
+ return () => cleanups.forEach((c) => c());
962
+ };
891
963
  function interpret(op, options) {
892
964
  const { strategy, retry: retryOptions, timeout: timeoutOptions } = options;
893
965
  switch (strategy) {
@@ -1026,7 +1098,7 @@ var Refinement;
1026
1098
  Refinement2.and = (second) => (first) => (a) => first(a) && second(a);
1027
1099
  Refinement2.or = (second) => (first) => (a) => first(a) || second(a);
1028
1100
  Refinement2.toFilter = (r) => (a) => r(a) ? Maybe.some(a) : Maybe.none();
1029
- Refinement2.toResult = (r, onFail) => (a) => r(a) ? Result.ok(a) : Result.err(onFail(a));
1101
+ Refinement2.toResult = (r, onFail) => (a) => r(a) ? Result.ok(a) : Result.error(onFail(a));
1030
1102
  })(Refinement || (Refinement = {}));
1031
1103
 
1032
1104
  // src/Core/RemoteData.ts
@@ -1095,9 +1167,10 @@ var RemoteData;
1095
1167
  };
1096
1168
  RemoteData2.recover = (fallback) => (data) => (0, RemoteData2.isFailure)(data) ? fallback(data.error) : data;
1097
1169
  RemoteData2.toMaybe = (data) => (0, RemoteData2.isSuccess)(data) ? Maybe.some(data.value) : Maybe.none();
1098
- RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
1170
+ RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.error((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
1099
1171
  RemoteData2.fromResult = (data) => Result.isOk(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(data.error);
1100
1172
  RemoteData2.fromMaybe = (onNone) => (data) => Maybe.isSome(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(onNone());
1173
+ RemoteData2.filter = (pred, onFalse) => (data) => (0, RemoteData2.isSuccess)(data) ? pred(data.value) ? data : (0, RemoteData2.failure)(onFalse(data.value)) : data;
1101
1174
  })(RemoteData || (RemoteData = {}));
1102
1175
 
1103
1176
  // src/Core/Resource.ts
@@ -1110,7 +1183,7 @@ var Resource;
1110
1183
  });
1111
1184
  Resource2.use = (f) => (resource) => Task.from(
1112
1185
  () => Deferred.toPromise(resource.acquire()).then(async (acquired) => {
1113
- if (Result.isErr(acquired)) return acquired;
1186
+ if (Result.isError(acquired)) return acquired;
1114
1187
  const a = acquired.value;
1115
1188
  const usageResult = await Deferred.toPromise(f(a)());
1116
1189
  await Deferred.toPromise(resource.release(a)());
@@ -1120,10 +1193,10 @@ var Resource;
1120
1193
  Resource2.combine = (resourceA, resourceB) => ({
1121
1194
  acquire: Task.from(
1122
1195
  () => Deferred.toPromise(resourceA.acquire()).then(async (acquiredA) => {
1123
- if (Result.isErr(acquiredA)) return acquiredA;
1196
+ if (Result.isError(acquiredA)) return acquiredA;
1124
1197
  const a = acquiredA.value;
1125
1198
  const acquiredB = await Deferred.toPromise(resourceB.acquire());
1126
- if (Result.isErr(acquiredB)) {
1199
+ if (Result.isError(acquiredB)) {
1127
1200
  await Deferred.toPromise(resourceA.release(a)());
1128
1201
  return acquiredB;
1129
1202
  }
@@ -1195,23 +1268,26 @@ var TaskMaybe;
1195
1268
  var TaskResult;
1196
1269
  ((TaskResult2) => {
1197
1270
  TaskResult2.ok = (value) => Task.resolve(Result.ok(value));
1198
- TaskResult2.err = (error) => Task.resolve(Result.err(error));
1271
+ TaskResult2.err = (error) => Task.resolve(Result.error(error));
1199
1272
  TaskResult2.tryCatch = (f, onError) => Task.from(
1200
- (signal) => f(signal).then(Result.ok).catch((e) => Result.err(onError(e)))
1273
+ (signal) => f(signal).then(Result.ok).catch((e) => Result.error(onError(e)))
1201
1274
  );
1202
1275
  TaskResult2.map = (f) => (data) => Task.map(Result.map(f))(data);
1203
1276
  TaskResult2.mapError = (f) => (data) => Task.map(Result.mapError(f))(data);
1204
- TaskResult2.chain = (f) => (data) => Task.chain((result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.err(result.error)))(
1277
+ TaskResult2.chain = (f) => (data) => Task.chain(
1278
+ (result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.error(result.error))
1279
+ )(
1205
1280
  data
1206
1281
  );
1207
1282
  TaskResult2.fold = (onErr, onOk) => (data) => Task.map(Result.fold(onErr, onOk))(data);
1208
1283
  TaskResult2.match = (cases) => (data) => Task.map(Result.match(cases))(data);
1209
1284
  TaskResult2.recover = (fallback) => (data) => Task.chain(
1210
- (result) => Result.isErr(result) ? fallback(result.error) : Task.resolve(result)
1285
+ (result) => Result.isError(result) ? fallback(result.error) : Task.resolve(result)
1211
1286
  )(data);
1212
1287
  TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
1213
1288
  TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
1214
1289
  TaskResult2.tapError = (f) => (data) => Task.map(Result.tapError(f))(data);
1290
+ TaskResult2.run = (signal) => (task) => Deferred.toPromise(task(signal));
1215
1291
  })(TaskResult || (TaskResult = {}));
1216
1292
 
1217
1293
  // src/Core/Validation.ts
@@ -1254,7 +1330,9 @@ var Validation;
1254
1330
  };
1255
1331
  Validation2.recover = (fallback) => (data) => (0, Validation2.isValid)(data) ? data : fallback(data.errors);
1256
1332
  Validation2.recoverUnless = (isBlocked, fallback) => (data) => (0, Validation2.isInvalid)(data) && !data.errors.some(isBlocked) ? fallback() : data;
1257
- Validation2.toResult = (data) => (0, Validation2.isValid)(data) ? Result.ok(data.value) : Result.err(data.errors);
1333
+ Validation2.toResult = (data) => (0, Validation2.isValid)(data) ? Result.ok(data.value) : Result.error(data.errors);
1334
+ Validation2.toMaybe = (data) => (0, Validation2.isValid)(data) ? Maybe.some(data.value) : Maybe.none();
1335
+ Validation2.fromResult = (data) => data.kind === "Ok" ? (0, Validation2.valid)(data.value) : (0, Validation2.invalid)(data.error);
1258
1336
  Validation2.product = (first, second) => {
1259
1337
  if ((0, Validation2.isValid)(first) && (0, Validation2.isValid)(second)) return (0, Validation2.valid)([first.value, second.value]);
1260
1338
  const errors = [
@@ -20,7 +20,7 @@ var Maybe;
20
20
  Maybe2.toNullable = (data) => (0, Maybe2.isSome)(data) ? data.value : null;
21
21
  Maybe2.toUndefined = (data) => (0, Maybe2.isSome)(data) ? data.value : void 0;
22
22
  Maybe2.fromPredicate = (pred) => (a) => pred(a) ? (0, Maybe2.some)(a) : (0, Maybe2.none)();
23
- Maybe2.toResult = (onNone) => (data) => (0, Maybe2.isSome)(data) ? Result.ok(data.value) : Result.err(onNone());
23
+ Maybe2.toResult = (onNone) => (data) => (0, Maybe2.isSome)(data) ? Result.ok(data.value) : Result.error(onNone());
24
24
  Maybe2.fromResult = (data) => Result.isOk(data) ? (0, Maybe2.some)(data.value) : (0, Maybe2.none)();
25
25
  Maybe2.map = (f) => (data) => (0, Maybe2.isSome)(data) ? (0, Maybe2.some)(f(data.value)) : data;
26
26
  Maybe2.chain = (f) => (data) => (0, Maybe2.isSome)(data) ? f(data.value) : data;
@@ -40,18 +40,18 @@ var Maybe;
40
40
  var Result;
41
41
  ((Result2) => {
42
42
  Result2.ok = (value) => ({ kind: "Ok", value });
43
- Result2.err = (error) => ({ kind: "Error", error });
43
+ Result2.error = (e) => ({ kind: "Error", error: e });
44
44
  Result2.isOk = (data) => data.kind === "Ok";
45
- Result2.isErr = (data) => data.kind === "Error";
45
+ Result2.isError = (data) => data.kind === "Error";
46
46
  Result2.tryCatch = (f, onError) => {
47
47
  try {
48
48
  return (0, Result2.ok)(f());
49
49
  } catch (e) {
50
- return (0, Result2.err)(onError(e));
50
+ return (0, Result2.error)(onError(e));
51
51
  }
52
52
  };
53
53
  Result2.map = (f) => (data) => (0, Result2.isOk)(data) ? (0, Result2.ok)(f(data.value)) : data;
54
- Result2.mapError = (f) => (data) => (0, Result2.isErr)(data) ? (0, Result2.err)(f(data.error)) : data;
54
+ Result2.mapError = (f) => (data) => (0, Result2.isError)(data) ? (0, Result2.error)(f(data.error)) : data;
55
55
  Result2.chain = (f) => (data) => (0, Result2.isOk)(data) ? f(data.value) : data;
56
56
  Result2.fold = (onErr, onOk) => (data) => (0, Result2.isOk)(data) ? onOk(data.value) : onErr(data.error);
57
57
  Result2.match = (cases) => (data) => (0, Result2.isOk)(data) ? cases.ok(data.value) : cases.err(data.error);
@@ -61,14 +61,14 @@ var Result;
61
61
  return data;
62
62
  };
63
63
  Result2.tapError = (f) => (data) => {
64
- if ((0, Result2.isErr)(data)) f(data.error);
64
+ if ((0, Result2.isError)(data)) f(data.error);
65
65
  return data;
66
66
  };
67
- Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
67
+ Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.error)(onFalse(a));
68
68
  Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
69
- Result2.recoverUnless = (isBlocked, fallback) => (data) => (0, Result2.isErr)(data) && !isBlocked(data.error) ? fallback() : data;
69
+ Result2.recoverUnless = (isBlocked, fallback) => (data) => (0, Result2.isError)(data) && !isBlocked(data.error) ? fallback() : data;
70
70
  Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
71
- Result2.ap = (arg) => (data) => (0, Result2.isOk)(data) && (0, Result2.isOk)(arg) ? (0, Result2.ok)(data.value(arg.value)) : (0, Result2.isErr)(data) ? data : arg;
71
+ Result2.ap = (arg) => (data) => (0, Result2.isOk)(data) && (0, Result2.isOk)(arg) ? (0, Result2.ok)(data.value(arg.value)) : (0, Result2.isError)(data) ? data : arg;
72
72
  })(Result || (Result = {}));
73
73
 
74
74
  // src/Core/Task.ts
@@ -108,22 +108,22 @@ var Task;
108
108
  if (times <= 0) return Promise.resolve([]);
109
109
  const results = [];
110
110
  const wait = () => ms !== void 0 && ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve();
111
- const run = (left) => toPromise(task, signal).then((a) => {
111
+ const run2 = (left) => toPromise(task, signal).then((a) => {
112
112
  results.push(a);
113
113
  if (left <= 1) return results;
114
- return wait().then(() => run(left - 1));
114
+ return wait().then(() => run2(left - 1));
115
115
  });
116
- return run(times);
116
+ return run2(times);
117
117
  });
118
118
  Task2.repeatUntil = (options) => (task) => (0, Task2.from)((signal) => {
119
119
  const { when: predicate, delay: ms, maxAttempts } = options;
120
120
  const wait = () => ms !== void 0 && ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve();
121
- const run = (attempt) => toPromise(task, signal).then((a) => {
121
+ const run2 = (attempt) => toPromise(task, signal).then((a) => {
122
122
  if (predicate(a)) return a;
123
123
  if (maxAttempts !== void 0 && attempt >= maxAttempts) return a;
124
- return wait().then(() => run(attempt + 1));
124
+ return wait().then(() => run2(attempt + 1));
125
125
  });
126
- return run(1);
126
+ return run2(1);
127
127
  });
128
128
  Task2.race = (tasks) => (0, Task2.from)((signal) => Promise.race(tasks.map((t) => toPromise(t, signal))));
129
129
  Task2.sequential = (tasks) => (0, Task2.from)(async (signal) => {
@@ -148,7 +148,7 @@ var Task;
148
148
  timerId = setTimeout(() => {
149
149
  controller.abort();
150
150
  outerSignal?.removeEventListener("abort", onOuterAbort);
151
- resolve2(Result.err(onTimeout()));
151
+ resolve2(Result.error(onTimeout()));
152
152
  }, ms);
153
153
  })
154
154
  ]);
@@ -171,6 +171,7 @@ var Task;
171
171
  };
172
172
  return { task, abort };
173
173
  };
174
+ Task2.run = (signal) => (task) => Deferred.toPromise(task(signal));
174
175
  })(Task || (Task = {}));
175
176
 
176
177
  export {