@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.
package/dist/core.js CHANGED
@@ -106,18 +106,18 @@ var Logged;
106
106
  var Result;
107
107
  ((Result2) => {
108
108
  Result2.ok = (value) => ({ kind: "Ok", value });
109
- Result2.err = (error) => ({ kind: "Error", error });
109
+ Result2.error = (e) => ({ kind: "Error", error: e });
110
110
  Result2.isOk = (data) => data.kind === "Ok";
111
- Result2.isErr = (data) => data.kind === "Error";
111
+ Result2.isError = (data) => data.kind === "Error";
112
112
  Result2.tryCatch = (f, onError) => {
113
113
  try {
114
114
  return (0, Result2.ok)(f());
115
115
  } catch (e) {
116
- return (0, Result2.err)(onError(e));
116
+ return (0, Result2.error)(onError(e));
117
117
  }
118
118
  };
119
119
  Result2.map = (f) => (data) => (0, Result2.isOk)(data) ? (0, Result2.ok)(f(data.value)) : data;
120
- Result2.mapError = (f) => (data) => (0, Result2.isErr)(data) ? (0, Result2.err)(f(data.error)) : data;
120
+ Result2.mapError = (f) => (data) => (0, Result2.isError)(data) ? (0, Result2.error)(f(data.error)) : data;
121
121
  Result2.chain = (f) => (data) => (0, Result2.isOk)(data) ? f(data.value) : data;
122
122
  Result2.fold = (onErr, onOk) => (data) => (0, Result2.isOk)(data) ? onOk(data.value) : onErr(data.error);
123
123
  Result2.match = (cases) => (data) => (0, Result2.isOk)(data) ? cases.ok(data.value) : cases.err(data.error);
@@ -127,14 +127,14 @@ var Result;
127
127
  return data;
128
128
  };
129
129
  Result2.tapError = (f) => (data) => {
130
- if ((0, Result2.isErr)(data)) f(data.error);
130
+ if ((0, Result2.isError)(data)) f(data.error);
131
131
  return data;
132
132
  };
133
- Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.err)(onFalse(a));
133
+ Result2.fromPredicate = (pred, onFalse) => (a) => pred(a) ? (0, Result2.ok)(a) : (0, Result2.error)(onFalse(a));
134
134
  Result2.recover = (fallback) => (data) => (0, Result2.isOk)(data) ? data : fallback(data.error);
135
- Result2.recoverUnless = (isBlocked, fallback) => (data) => (0, Result2.isErr)(data) && !isBlocked(data.error) ? fallback() : data;
135
+ Result2.recoverUnless = (isBlocked, fallback) => (data) => (0, Result2.isError)(data) && !isBlocked(data.error) ? fallback() : data;
136
136
  Result2.toMaybe = (data) => (0, Result2.isOk)(data) ? Maybe.some(data.value) : Maybe.none();
137
- 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;
137
+ 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;
138
138
  })(Result || (Result = {}));
139
139
 
140
140
  // src/Core/Maybe.ts
@@ -149,7 +149,7 @@ var Maybe;
149
149
  Maybe2.toNullable = (data) => (0, Maybe2.isSome)(data) ? data.value : null;
150
150
  Maybe2.toUndefined = (data) => (0, Maybe2.isSome)(data) ? data.value : void 0;
151
151
  Maybe2.fromPredicate = (pred) => (a) => pred(a) ? (0, Maybe2.some)(a) : (0, Maybe2.none)();
152
- Maybe2.toResult = (onNone) => (data) => (0, Maybe2.isSome)(data) ? Result.ok(data.value) : Result.err(onNone());
152
+ Maybe2.toResult = (onNone) => (data) => (0, Maybe2.isSome)(data) ? Result.ok(data.value) : Result.error(onNone());
153
153
  Maybe2.fromResult = (data) => Result.isOk(data) ? (0, Maybe2.some)(data.value) : (0, Maybe2.none)();
154
154
  Maybe2.map = (f) => (data) => (0, Maybe2.isSome)(data) ? (0, Maybe2.some)(f(data.value)) : data;
155
155
  Maybe2.chain = (f) => (data) => (0, Maybe2.isSome)(data) ? f(data.value) : data;
@@ -166,14 +166,14 @@ var Maybe;
166
166
  })(Maybe || (Maybe = {}));
167
167
 
168
168
  // src/internal/Op.util.ts
169
- var _abortedNil = { kind: "Nil", reason: "aborted" };
170
- var _droppedNil = { kind: "Nil", reason: "dropped" };
171
- var _replacedNil = { kind: "Nil", reason: "replaced" };
172
- var _evictedNil = { kind: "Nil", reason: "evicted" };
169
+ var _abortedNil = { kind: "OpNil", reason: "aborted" };
170
+ var _droppedNil = { kind: "OpNil", reason: "dropped" };
171
+ var _replacedNil = { kind: "OpNil", reason: "replaced" };
172
+ var _evictedNil = { kind: "OpNil", reason: "evicted" };
173
173
  var _idle = { kind: "Idle" };
174
174
  var _pending = { kind: "Pending" };
175
- var ok = (value) => ({ kind: "Ok", value });
176
- var err = (error) => ({ kind: "Err", error });
175
+ var ok = (value) => ({ kind: "OpOk", value });
176
+ var err = (error) => ({ kind: "OpError", error });
177
177
  var cancellableWait = (ms, signal) => {
178
178
  if (ms <= 0) return Promise.resolve();
179
179
  return new Promise((resolve) => {
@@ -296,6 +296,12 @@ var makeRestartable = (op, minInterval, retryOptions, timeoutOptions) => {
296
296
  subscribers.add(cb);
297
297
  if (currentState.kind !== "Idle") cb(currentState);
298
298
  return () => subscribers.delete(cb);
299
+ },
300
+ reset: () => emit(_idle),
301
+ poll: (input, { interval }) => {
302
+ void run(input);
303
+ const id = setInterval(() => void run(input), interval);
304
+ return () => clearInterval(id);
299
305
  }
300
306
  };
301
307
  };
@@ -360,6 +366,12 @@ var makeExclusive = (op, cooldown, retryOptions, timeoutOptions) => {
360
366
  subscribers.add(cb);
361
367
  if (currentState.kind !== "Idle") cb(currentState);
362
368
  return () => subscribers.delete(cb);
369
+ },
370
+ reset: () => emit(_idle),
371
+ poll: (input, { interval }) => {
372
+ void run(input);
373
+ const id = setInterval(() => void run(input), interval);
374
+ return () => clearInterval(id);
363
375
  }
364
376
  };
365
377
  };
@@ -459,6 +471,12 @@ var makeQueue = (op, maxSize, overflow, concurrency, dedupe, retryOptions, timeo
459
471
  subscribers.add(cb);
460
472
  if (currentState.kind !== "Idle") cb(currentState);
461
473
  return () => subscribers.delete(cb);
474
+ },
475
+ reset: () => emit(_idle),
476
+ poll: (input, { interval }) => {
477
+ void run(input);
478
+ const id = setInterval(() => void run(input), interval);
479
+ return () => clearInterval(id);
462
480
  }
463
481
  };
464
482
  };
@@ -529,6 +547,12 @@ var makeBuffered = (op, size, retryOptions, timeoutOptions) => {
529
547
  subscribers.add(cb);
530
548
  if (currentState.kind !== "Idle") cb(currentState);
531
549
  return () => subscribers.delete(cb);
550
+ },
551
+ reset: () => emit(_idle),
552
+ poll: (input, { interval }) => {
553
+ void run(input);
554
+ const id = setInterval(() => void run(input), interval);
555
+ return () => clearInterval(id);
532
556
  }
533
557
  };
534
558
  };
@@ -651,6 +675,12 @@ var makeDebounced = (op, ms, leading, maxWait, retryOptions, timeoutOptions) =>
651
675
  subscribers.add(cb);
652
676
  if (currentState.kind !== "Idle") cb(currentState);
653
677
  return () => subscribers.delete(cb);
678
+ },
679
+ reset: () => emit(_idle),
680
+ poll: (input, { interval }) => {
681
+ void run(input);
682
+ const id = setInterval(() => void run(input), interval);
683
+ return () => clearInterval(id);
654
684
  }
655
685
  };
656
686
  };
@@ -743,6 +773,12 @@ var makeThrottled = (op, ms, trailing, retryOptions, timeoutOptions) => {
743
773
  subscribers.add(cb);
744
774
  if (currentState.kind !== "Idle") cb(currentState);
745
775
  return () => subscribers.delete(cb);
776
+ },
777
+ reset: () => emit(_idle),
778
+ poll: (input, { interval }) => {
779
+ void run(input);
780
+ const id = setInterval(() => void run(input), interval);
781
+ return () => clearInterval(id);
746
782
  }
747
783
  };
748
784
  };
@@ -824,6 +860,12 @@ var makeConcurrent = (op, n, overflow, retryOptions, timeoutOptions) => {
824
860
  subscribers.add(cb);
825
861
  if (currentState.kind !== "Idle") cb(currentState);
826
862
  return () => subscribers.delete(cb);
863
+ },
864
+ reset: () => emit(_idle),
865
+ poll: (input, { interval }) => {
866
+ void run(input);
867
+ const id = setInterval(() => void run(input), interval);
868
+ return () => clearInterval(id);
827
869
  }
828
870
  };
829
871
  };
@@ -900,6 +942,15 @@ var makeKeyed = (op, keyFn, perKey, timeoutOptions) => {
900
942
  subscribers.add(cb);
901
943
  if (stateMap.size > 0) cb(new Map(stateMap));
902
944
  return () => subscribers.delete(cb);
945
+ },
946
+ reset: () => {
947
+ stateMap.clear();
948
+ emitSnapshot();
949
+ },
950
+ poll: (input, { interval }) => {
951
+ void run(input);
952
+ const id = setInterval(() => void run(input), interval);
953
+ return () => clearInterval(id);
903
954
  }
904
955
  };
905
956
  };
@@ -954,6 +1005,12 @@ var makeOnce = (op, retryOptions, timeoutOptions) => {
954
1005
  subscribers.add(cb);
955
1006
  if (currentState.kind !== "Idle") cb(currentState);
956
1007
  return () => subscribers.delete(cb);
1008
+ },
1009
+ reset: () => emit(_idle),
1010
+ poll: (input, { interval }) => {
1011
+ void run(input);
1012
+ const id = setInterval(() => void run(input), interval);
1013
+ return () => clearInterval(id);
957
1014
  }
958
1015
  };
959
1016
  };
@@ -961,44 +1018,59 @@ var makeOnce = (op, retryOptions, timeoutOptions) => {
961
1018
  // src/Core/Op.ts
962
1019
  var Op;
963
1020
  ((Op2) => {
964
- Op2.nil = (reason) => ({ kind: "Nil", reason });
1021
+ Op2.nil = (reason) => ({ kind: "OpNil", reason });
965
1022
  Op2.create = (factory, onError) => ({
966
1023
  _factory: (input, signal) => Deferred.fromPromise(
967
- factory(signal)(input).then((value) => Result.ok(value)).catch((e) => signal.aborted ? null : Result.err(onError(e)))
1024
+ factory(signal)(input).then((value) => Result.ok(value)).catch((e) => signal.aborted ? null : Result.error(onError(e)))
968
1025
  )
969
1026
  });
970
- Op2.ok = (value) => ({ kind: "Ok", value });
971
- Op2.err = (error) => ({ kind: "Err", error });
972
- Op2.isOk = (outcome) => outcome.kind === "Ok";
973
- Op2.isErr = (outcome) => outcome.kind === "Err";
974
- Op2.isNil = (outcome) => outcome.kind === "Nil";
1027
+ Op2.lift = (f) => (0, Op2.create)(
1028
+ (signal) => (input) => f(input, signal),
1029
+ (e) => e
1030
+ );
1031
+ Op2.ok = (value) => ({ kind: "OpOk", value });
1032
+ Op2.error = (error2) => ({ kind: "OpError", error: error2 });
1033
+ Op2.isIdle = (state) => state.kind === "Idle";
1034
+ Op2.isPending = (state) => state.kind === "Pending";
1035
+ Op2.isQueued = (state) => state.kind === "Queued";
1036
+ Op2.isRetrying = (state) => state.kind === "Retrying";
1037
+ Op2.isOk = (state) => state.kind === "OpOk";
1038
+ Op2.isError = (state) => state.kind === "OpError";
1039
+ Op2.isNil = (state) => state.kind === "OpNil";
975
1040
  Op2.match = (cases) => (outcome) => {
976
- if (outcome.kind === "Ok") return cases.ok(outcome.value);
977
- if (outcome.kind === "Err") return cases.err(outcome.error);
1041
+ if (outcome.kind === "OpOk") return cases.ok(outcome.value);
1042
+ if (outcome.kind === "OpError") return cases.error(outcome.error);
978
1043
  return cases.nil();
979
1044
  };
980
- Op2.fold = (onErr, onOk, onNil) => (outcome) => {
981
- if (outcome.kind === "Ok") return onOk(outcome.value);
982
- if (outcome.kind === "Err") return onErr(outcome.error);
1045
+ Op2.fold = (onError, onOk, onNil) => (outcome) => {
1046
+ if (outcome.kind === "OpOk") return onOk(outcome.value);
1047
+ if (outcome.kind === "OpError") return onError(outcome.error);
983
1048
  return onNil();
984
1049
  };
985
- Op2.getOrElse = (defaultValue) => (outcome) => outcome.kind === "Ok" ? outcome.value : defaultValue();
986
- Op2.map = (f) => (outcome) => outcome.kind === "Ok" ? (0, Op2.ok)(f(outcome.value)) : outcome;
987
- Op2.mapError = (f) => (outcome) => outcome.kind === "Err" ? (0, Op2.err)(f(outcome.error)) : outcome;
988
- Op2.chain = (f) => (outcome) => outcome.kind === "Ok" ? f(outcome.value) : outcome;
1050
+ Op2.getOrElse = (defaultValue) => (outcome) => outcome.kind === "OpOk" ? outcome.value : defaultValue();
1051
+ Op2.map = (f) => (outcome) => outcome.kind === "OpOk" ? (0, Op2.ok)(f(outcome.value)) : outcome;
1052
+ Op2.mapError = (f) => (outcome) => outcome.kind === "OpError" ? (0, Op2.error)(f(outcome.error)) : outcome;
1053
+ Op2.chain = (f) => (outcome) => outcome.kind === "OpOk" ? f(outcome.value) : outcome;
989
1054
  Op2.tap = (f) => (outcome) => {
990
- if (outcome.kind === "Ok") f(outcome.value);
1055
+ if (outcome.kind === "OpOk") f(outcome.value);
991
1056
  return outcome;
992
1057
  };
993
- Op2.recover = (f) => (outcome) => outcome.kind === "Err" ? f(outcome.error) : outcome;
1058
+ Op2.recover = (f) => (outcome) => outcome.kind === "OpError" ? f(outcome.error) : outcome;
994
1059
  Op2.toResult = (onNil) => (outcome) => {
995
- if (outcome.kind === "Ok") return Result.ok(outcome.value);
996
- if (outcome.kind === "Err") return Result.err(outcome.error);
997
- return Result.err(onNil());
1060
+ if (outcome.kind === "OpOk") return Result.ok(outcome.value);
1061
+ if (outcome.kind === "OpError") return Result.error(outcome.error);
1062
+ return Result.error(onNil());
998
1063
  };
999
- Op2.toMaybe = (outcome) => outcome.kind === "Ok" ? Maybe.some(outcome.value) : Maybe.none();
1064
+ Op2.toMaybe = (outcome) => outcome.kind === "OpOk" ? Maybe.some(outcome.value) : Maybe.none();
1000
1065
  Op2.all = (invocations) => Deferred.fromPromise(Promise.all(invocations.map(Deferred.toPromise)));
1001
1066
  Op2.race = (invocations) => Deferred.fromPromise(Promise.race(invocations.map(Deferred.toPromise)));
1067
+ Op2.wire = (source, f) => source.subscribe((state) => {
1068
+ if ((0, Op2.isOk)(state)) f(state.value);
1069
+ });
1070
+ Op2.wireAll = (...pairs) => {
1071
+ const cleanups = pairs.map(([source, f]) => (0, Op2.wire)(source, f));
1072
+ return () => cleanups.forEach((c) => c());
1073
+ };
1002
1074
  function interpret(op, options) {
1003
1075
  const { strategy, retry: retryOptions, timeout: timeoutOptions } = options;
1004
1076
  switch (strategy) {
@@ -1137,7 +1209,7 @@ var Refinement;
1137
1209
  Refinement2.and = (second) => (first) => (a) => first(a) && second(a);
1138
1210
  Refinement2.or = (second) => (first) => (a) => first(a) || second(a);
1139
1211
  Refinement2.toFilter = (r) => (a) => r(a) ? Maybe.some(a) : Maybe.none();
1140
- Refinement2.toResult = (r, onFail) => (a) => r(a) ? Result.ok(a) : Result.err(onFail(a));
1212
+ Refinement2.toResult = (r, onFail) => (a) => r(a) ? Result.ok(a) : Result.error(onFail(a));
1141
1213
  })(Refinement || (Refinement = {}));
1142
1214
 
1143
1215
  // src/Core/RemoteData.ts
@@ -1206,9 +1278,10 @@ var RemoteData;
1206
1278
  };
1207
1279
  RemoteData2.recover = (fallback) => (data) => (0, RemoteData2.isFailure)(data) ? fallback(data.error) : data;
1208
1280
  RemoteData2.toMaybe = (data) => (0, RemoteData2.isSuccess)(data) ? Maybe.some(data.value) : Maybe.none();
1209
- RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.err((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
1281
+ RemoteData2.toResult = (onNotReady) => (data) => (0, RemoteData2.isSuccess)(data) ? Result.ok(data.value) : Result.error((0, RemoteData2.isFailure)(data) ? data.error : onNotReady());
1210
1282
  RemoteData2.fromResult = (data) => Result.isOk(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(data.error);
1211
1283
  RemoteData2.fromMaybe = (onNone) => (data) => Maybe.isSome(data) ? (0, RemoteData2.success)(data.value) : (0, RemoteData2.failure)(onNone());
1284
+ RemoteData2.filter = (pred, onFalse) => (data) => (0, RemoteData2.isSuccess)(data) ? pred(data.value) ? data : (0, RemoteData2.failure)(onFalse(data.value)) : data;
1212
1285
  })(RemoteData || (RemoteData = {}));
1213
1286
 
1214
1287
  // src/Core/Task.ts
@@ -1248,22 +1321,22 @@ var Task;
1248
1321
  if (times <= 0) return Promise.resolve([]);
1249
1322
  const results = [];
1250
1323
  const wait = () => ms !== void 0 && ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve();
1251
- const run = (left) => toPromise(task, signal).then((a) => {
1324
+ const run2 = (left) => toPromise(task, signal).then((a) => {
1252
1325
  results.push(a);
1253
1326
  if (left <= 1) return results;
1254
- return wait().then(() => run(left - 1));
1327
+ return wait().then(() => run2(left - 1));
1255
1328
  });
1256
- return run(times);
1329
+ return run2(times);
1257
1330
  });
1258
1331
  Task2.repeatUntil = (options) => (task) => (0, Task2.from)((signal) => {
1259
1332
  const { when: predicate, delay: ms, maxAttempts } = options;
1260
1333
  const wait = () => ms !== void 0 && ms > 0 ? new Promise((r) => setTimeout(r, ms)) : Promise.resolve();
1261
- const run = (attempt) => toPromise(task, signal).then((a) => {
1334
+ const run2 = (attempt) => toPromise(task, signal).then((a) => {
1262
1335
  if (predicate(a)) return a;
1263
1336
  if (maxAttempts !== void 0 && attempt >= maxAttempts) return a;
1264
- return wait().then(() => run(attempt + 1));
1337
+ return wait().then(() => run2(attempt + 1));
1265
1338
  });
1266
- return run(1);
1339
+ return run2(1);
1267
1340
  });
1268
1341
  Task2.race = (tasks) => (0, Task2.from)((signal) => Promise.race(tasks.map((t) => toPromise(t, signal))));
1269
1342
  Task2.sequential = (tasks) => (0, Task2.from)(async (signal) => {
@@ -1288,7 +1361,7 @@ var Task;
1288
1361
  timerId = setTimeout(() => {
1289
1362
  controller.abort();
1290
1363
  outerSignal?.removeEventListener("abort", onOuterAbort);
1291
- resolve2(Result.err(onTimeout()));
1364
+ resolve2(Result.error(onTimeout()));
1292
1365
  }, ms);
1293
1366
  })
1294
1367
  ]);
@@ -1311,6 +1384,7 @@ var Task;
1311
1384
  };
1312
1385
  return { task, abort };
1313
1386
  };
1387
+ Task2.run = (signal) => (task) => Deferred.toPromise(task(signal));
1314
1388
  })(Task || (Task = {}));
1315
1389
 
1316
1390
  // src/Core/Resource.ts
@@ -1323,7 +1397,7 @@ var Resource;
1323
1397
  });
1324
1398
  Resource2.use = (f) => (resource) => Task.from(
1325
1399
  () => Deferred.toPromise(resource.acquire()).then(async (acquired) => {
1326
- if (Result.isErr(acquired)) return acquired;
1400
+ if (Result.isError(acquired)) return acquired;
1327
1401
  const a = acquired.value;
1328
1402
  const usageResult = await Deferred.toPromise(f(a)());
1329
1403
  await Deferred.toPromise(resource.release(a)());
@@ -1333,10 +1407,10 @@ var Resource;
1333
1407
  Resource2.combine = (resourceA, resourceB) => ({
1334
1408
  acquire: Task.from(
1335
1409
  () => Deferred.toPromise(resourceA.acquire()).then(async (acquiredA) => {
1336
- if (Result.isErr(acquiredA)) return acquiredA;
1410
+ if (Result.isError(acquiredA)) return acquiredA;
1337
1411
  const a = acquiredA.value;
1338
1412
  const acquiredB = await Deferred.toPromise(resourceB.acquire());
1339
- if (Result.isErr(acquiredB)) {
1413
+ if (Result.isError(acquiredB)) {
1340
1414
  await Deferred.toPromise(resourceA.release(a)());
1341
1415
  return acquiredB;
1342
1416
  }
@@ -1408,23 +1482,26 @@ var TaskMaybe;
1408
1482
  var TaskResult;
1409
1483
  ((TaskResult2) => {
1410
1484
  TaskResult2.ok = (value) => Task.resolve(Result.ok(value));
1411
- TaskResult2.err = (error) => Task.resolve(Result.err(error));
1485
+ TaskResult2.err = (error) => Task.resolve(Result.error(error));
1412
1486
  TaskResult2.tryCatch = (f, onError) => Task.from(
1413
- (signal) => f(signal).then(Result.ok).catch((e) => Result.err(onError(e)))
1487
+ (signal) => f(signal).then(Result.ok).catch((e) => Result.error(onError(e)))
1414
1488
  );
1415
1489
  TaskResult2.map = (f) => (data) => Task.map(Result.map(f))(data);
1416
1490
  TaskResult2.mapError = (f) => (data) => Task.map(Result.mapError(f))(data);
1417
- TaskResult2.chain = (f) => (data) => Task.chain((result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.err(result.error)))(
1491
+ TaskResult2.chain = (f) => (data) => Task.chain(
1492
+ (result) => Result.isOk(result) ? f(result.value) : Task.resolve(Result.error(result.error))
1493
+ )(
1418
1494
  data
1419
1495
  );
1420
1496
  TaskResult2.fold = (onErr, onOk) => (data) => Task.map(Result.fold(onErr, onOk))(data);
1421
1497
  TaskResult2.match = (cases) => (data) => Task.map(Result.match(cases))(data);
1422
1498
  TaskResult2.recover = (fallback) => (data) => Task.chain(
1423
- (result) => Result.isErr(result) ? fallback(result.error) : Task.resolve(result)
1499
+ (result) => Result.isError(result) ? fallback(result.error) : Task.resolve(result)
1424
1500
  )(data);
1425
1501
  TaskResult2.getOrElse = (defaultValue) => (data) => Task.map(Result.getOrElse(defaultValue))(data);
1426
1502
  TaskResult2.tap = (f) => (data) => Task.map(Result.tap(f))(data);
1427
1503
  TaskResult2.tapError = (f) => (data) => Task.map(Result.tapError(f))(data);
1504
+ TaskResult2.run = (signal) => (task) => Deferred.toPromise(task(signal));
1428
1505
  })(TaskResult || (TaskResult = {}));
1429
1506
 
1430
1507
  // src/Core/Validation.ts
@@ -1467,7 +1544,9 @@ var Validation;
1467
1544
  };
1468
1545
  Validation2.recover = (fallback) => (data) => (0, Validation2.isValid)(data) ? data : fallback(data.errors);
1469
1546
  Validation2.recoverUnless = (isBlocked, fallback) => (data) => (0, Validation2.isInvalid)(data) && !data.errors.some(isBlocked) ? fallback() : data;
1470
- Validation2.toResult = (data) => (0, Validation2.isValid)(data) ? Result.ok(data.value) : Result.err(data.errors);
1547
+ Validation2.toResult = (data) => (0, Validation2.isValid)(data) ? Result.ok(data.value) : Result.error(data.errors);
1548
+ Validation2.toMaybe = (data) => (0, Validation2.isValid)(data) ? Maybe.some(data.value) : Maybe.none();
1549
+ Validation2.fromResult = (data) => data.kind === "Ok" ? (0, Validation2.valid)(data.value) : (0, Validation2.invalid)(data.error);
1471
1550
  Validation2.product = (first, second) => {
1472
1551
  if ((0, Validation2.isValid)(first) && (0, Validation2.isValid)(second)) return (0, Validation2.valid)([first.value, second.value]);
1473
1552
  const errors = [
package/dist/core.mjs CHANGED
@@ -15,13 +15,13 @@ import {
15
15
  These,
16
16
  Tuple,
17
17
  Validation
18
- } from "./chunk-QJS6D6MW.mjs";
18
+ } from "./chunk-PV7JOUKL.mjs";
19
19
  import {
20
20
  Deferred,
21
21
  Maybe,
22
22
  Result,
23
23
  Task
24
- } from "./chunk-7JF44HJH.mjs";
24
+ } from "./chunk-SDGDJ7CU.mjs";
25
25
  export {
26
26
  Deferred,
27
27
  Lens,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { and, compose, constFalse, constNull, constTrue, constUndefined, constVoid, constant, converge, curry, curry3, curry4, flip, flow, identity, juxt, memoize, memoizeWeak, not, on, once, or, pipe, tap, uncurry, uncurry3, uncurry4 } from './composition.mjs';
2
- export { D as Deferred, E as Err, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-BZT0wedE.mjs';
2
+ export { D as Deferred, E as Error, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-BDcKwFAj.mjs';
3
3
  export { Failure, Invalid, Lens, Loading, Logged, NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, State, Success, TaskMaybe, TaskResult, TaskValidation, These, TheseBoth, TheseFirst, TheseSecond, Tuple, Valid, Validation } from './core.mjs';
4
4
  export { Brand } from './types.mjs';
5
5
  export { N as NonEmptyList, i as isNonEmptyList } from './NonEmptyList-BlGFjor5.mjs';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { and, compose, constFalse, constNull, constTrue, constUndefined, constVoid, constant, converge, curry, curry3, curry4, flip, flow, identity, juxt, memoize, memoizeWeak, not, on, once, or, pipe, tap, uncurry, uncurry3, uncurry4 } from './composition.js';
2
- export { D as Deferred, E as Err, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-BW66NsGR.js';
2
+ export { D as Deferred, E as Error, M as Maybe, N as None, O as Ok, R as Result, S as Some, T as Task } from './Task-CnF22Q2o.js';
3
3
  export { Failure, Invalid, Lens, Loading, Logged, NotAsked, Op, Optional, Predicate, Reader, Refinement, RemoteData, Resource, State, Success, TaskMaybe, TaskResult, TaskValidation, These, TheseBoth, TheseFirst, TheseSecond, Tuple, Valid, Validation } from './core.js';
4
4
  export { Brand } from './types.js';
5
5
  export { N as NonEmptyList, i as isNonEmptyList } from './NonEmptyList-BlGFjor5.js';