retuple 1.0.0-next.17 → 1.0.0-next.18
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/index.cjs +3 -37
- package/dist/index.d.cts +1 -30
- package/dist/index.d.ts +1 -30
- package/dist/index.js +3 -37
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -162,8 +162,6 @@ function $resolve(result) {
|
|
|
162
162
|
switch (true) {
|
|
163
163
|
case result instanceof ResultAsync:
|
|
164
164
|
return result;
|
|
165
|
-
case result instanceof ResultRetry:
|
|
166
|
-
return new ResultAsync(result);
|
|
167
165
|
case result instanceof ResultOk:
|
|
168
166
|
case result instanceof ResultErr:
|
|
169
167
|
return new ResultAsync(Promise.resolve(result));
|
|
@@ -1212,7 +1210,7 @@ _ResultAsync_inner = new WeakMap();
|
|
|
1212
1210
|
/**
|
|
1213
1211
|
* ## ResultRetry
|
|
1214
1212
|
*/
|
|
1215
|
-
class ResultRetry {
|
|
1213
|
+
class ResultRetry extends ResultAsync {
|
|
1216
1214
|
static zero() {
|
|
1217
1215
|
return 0;
|
|
1218
1216
|
}
|
|
@@ -1226,6 +1224,7 @@ class ResultRetry {
|
|
|
1226
1224
|
return 0;
|
|
1227
1225
|
}
|
|
1228
1226
|
constructor(f) {
|
|
1227
|
+
super(Promise.resolve().then(() => __classPrivateFieldGet(this, _ResultRetry_promise, "f")));
|
|
1229
1228
|
_ResultRetry_f.set(this, void 0);
|
|
1230
1229
|
_ResultRetry_promise.set(this, void 0);
|
|
1231
1230
|
_ResultRetry_times.set(this, 1);
|
|
@@ -1238,7 +1237,7 @@ class ResultRetry {
|
|
|
1238
1237
|
__classPrivateFieldSet(this, _ResultRetry_promise, this.drain(), "f");
|
|
1239
1238
|
}
|
|
1240
1239
|
then(onfulfilled, onrejected) {
|
|
1241
|
-
return
|
|
1240
|
+
return super.then(onfulfilled, onrejected);
|
|
1242
1241
|
}
|
|
1243
1242
|
/**
|
|
1244
1243
|
* Sets the maximum number of times the retry function can be executed,
|
|
@@ -1308,39 +1307,6 @@ class ResultRetry {
|
|
|
1308
1307
|
__classPrivateFieldSet(this, _ResultRetry_handler, f, "f");
|
|
1309
1308
|
return this;
|
|
1310
1309
|
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Returns {@link ResultAsync} which resolves to this retried {@link Result}.
|
|
1313
|
-
*
|
|
1314
|
-
* @example
|
|
1315
|
-
*
|
|
1316
|
-
* ```ts
|
|
1317
|
-
* const result: Result<string, SomeError> = await Result
|
|
1318
|
-
* .$retry(someResultFn)
|
|
1319
|
-
* .$times(3)
|
|
1320
|
-
* .$delay(100)
|
|
1321
|
-
* .$async()
|
|
1322
|
-
* .$andThen((message) => `Success: ${message}`)
|
|
1323
|
-
* .$mapErr((code) => new SomeError({ code }));
|
|
1324
|
-
* ```
|
|
1325
|
-
*/
|
|
1326
|
-
$async() {
|
|
1327
|
-
return new ResultAsync(this);
|
|
1328
|
-
}
|
|
1329
|
-
/**
|
|
1330
|
-
* Returns a `Promise` which resolves to this retried {@link Result}.
|
|
1331
|
-
*
|
|
1332
|
-
* @example
|
|
1333
|
-
*
|
|
1334
|
-
* ```ts
|
|
1335
|
-
* const promise: Promise<Result<string, Error>> = Result
|
|
1336
|
-
* .$retry(someResultFn)
|
|
1337
|
-
* .$times(3)
|
|
1338
|
-
* .$promise();
|
|
1339
|
-
* ```
|
|
1340
|
-
*/
|
|
1341
|
-
$promise() {
|
|
1342
|
-
return Promise.resolve(this);
|
|
1343
|
-
}
|
|
1344
1310
|
async drain() {
|
|
1345
1311
|
var _b;
|
|
1346
1312
|
while (__classPrivateFieldGet(this, _ResultRetry_attempt, "f") < __classPrivateFieldGet(this, _ResultRetry_times, "f")) {
|
package/dist/index.d.cts
CHANGED
|
@@ -644,7 +644,7 @@ declare class ResultAsync<T, E> {
|
|
|
644
644
|
/**
|
|
645
645
|
* ## ResultRetry
|
|
646
646
|
*/
|
|
647
|
-
declare class ResultRetry<T, E> implements PromiseLike<Result<T, E>> {
|
|
647
|
+
declare class ResultRetry<T, E> extends ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
648
648
|
#private;
|
|
649
649
|
private static MAX_TIMEOUT;
|
|
650
650
|
private static MAX_RETRY;
|
|
@@ -731,35 +731,6 @@ declare class ResultRetry<T, E> implements PromiseLike<Result<T, E>> {
|
|
|
731
731
|
* ```
|
|
732
732
|
*/
|
|
733
733
|
$handle(f: (controller: ResultRetryController<E>) => void): ResultRetry<T, E>;
|
|
734
|
-
/**
|
|
735
|
-
* Returns {@link ResultAsync} which resolves to this retried {@link Result}.
|
|
736
|
-
*
|
|
737
|
-
* @example
|
|
738
|
-
*
|
|
739
|
-
* ```ts
|
|
740
|
-
* const result: Result<string, SomeError> = await Result
|
|
741
|
-
* .$retry(someResultFn)
|
|
742
|
-
* .$times(3)
|
|
743
|
-
* .$delay(100)
|
|
744
|
-
* .$async()
|
|
745
|
-
* .$andThen((message) => `Success: ${message}`)
|
|
746
|
-
* .$mapErr((code) => new SomeError({ code }));
|
|
747
|
-
* ```
|
|
748
|
-
*/
|
|
749
|
-
$async(this: ResultRetry<T, E>): ResultAsync<T, E>;
|
|
750
|
-
/**
|
|
751
|
-
* Returns a `Promise` which resolves to this retried {@link Result}.
|
|
752
|
-
*
|
|
753
|
-
* @example
|
|
754
|
-
*
|
|
755
|
-
* ```ts
|
|
756
|
-
* const promise: Promise<Result<string, Error>> = Result
|
|
757
|
-
* .$retry(someResultFn)
|
|
758
|
-
* .$times(3)
|
|
759
|
-
* .$promise();
|
|
760
|
-
* ```
|
|
761
|
-
*/
|
|
762
|
-
$promise(this: ResultRetry<T, E>): Promise<Result<T, E>>;
|
|
763
734
|
private drain;
|
|
764
735
|
}
|
|
765
736
|
interface Retuple<T, E> extends RetupleArray<T | E | undefined>, ResultLike<T, E> {
|
package/dist/index.d.ts
CHANGED
|
@@ -644,7 +644,7 @@ declare class ResultAsync<T, E> {
|
|
|
644
644
|
/**
|
|
645
645
|
* ## ResultRetry
|
|
646
646
|
*/
|
|
647
|
-
declare class ResultRetry<T, E> implements PromiseLike<Result<T, E>> {
|
|
647
|
+
declare class ResultRetry<T, E> extends ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
|
|
648
648
|
#private;
|
|
649
649
|
private static MAX_TIMEOUT;
|
|
650
650
|
private static MAX_RETRY;
|
|
@@ -731,35 +731,6 @@ declare class ResultRetry<T, E> implements PromiseLike<Result<T, E>> {
|
|
|
731
731
|
* ```
|
|
732
732
|
*/
|
|
733
733
|
$handle(f: (controller: ResultRetryController<E>) => void): ResultRetry<T, E>;
|
|
734
|
-
/**
|
|
735
|
-
* Returns {@link ResultAsync} which resolves to this retried {@link Result}.
|
|
736
|
-
*
|
|
737
|
-
* @example
|
|
738
|
-
*
|
|
739
|
-
* ```ts
|
|
740
|
-
* const result: Result<string, SomeError> = await Result
|
|
741
|
-
* .$retry(someResultFn)
|
|
742
|
-
* .$times(3)
|
|
743
|
-
* .$delay(100)
|
|
744
|
-
* .$async()
|
|
745
|
-
* .$andThen((message) => `Success: ${message}`)
|
|
746
|
-
* .$mapErr((code) => new SomeError({ code }));
|
|
747
|
-
* ```
|
|
748
|
-
*/
|
|
749
|
-
$async(this: ResultRetry<T, E>): ResultAsync<T, E>;
|
|
750
|
-
/**
|
|
751
|
-
* Returns a `Promise` which resolves to this retried {@link Result}.
|
|
752
|
-
*
|
|
753
|
-
* @example
|
|
754
|
-
*
|
|
755
|
-
* ```ts
|
|
756
|
-
* const promise: Promise<Result<string, Error>> = Result
|
|
757
|
-
* .$retry(someResultFn)
|
|
758
|
-
* .$times(3)
|
|
759
|
-
* .$promise();
|
|
760
|
-
* ```
|
|
761
|
-
*/
|
|
762
|
-
$promise(this: ResultRetry<T, E>): Promise<Result<T, E>>;
|
|
763
734
|
private drain;
|
|
764
735
|
}
|
|
765
736
|
interface Retuple<T, E> extends RetupleArray<T | E | undefined>, ResultLike<T, E> {
|
package/dist/index.js
CHANGED
|
@@ -150,8 +150,6 @@ function $resolve(result) {
|
|
|
150
150
|
switch (true) {
|
|
151
151
|
case result instanceof ResultAsync:
|
|
152
152
|
return result;
|
|
153
|
-
case result instanceof ResultRetry:
|
|
154
|
-
return new ResultAsync(result);
|
|
155
153
|
case result instanceof ResultOk:
|
|
156
154
|
case result instanceof ResultErr:
|
|
157
155
|
return new ResultAsync(Promise.resolve(result));
|
|
@@ -1200,7 +1198,7 @@ _ResultAsync_inner = new WeakMap();
|
|
|
1200
1198
|
/**
|
|
1201
1199
|
* ## ResultRetry
|
|
1202
1200
|
*/
|
|
1203
|
-
class ResultRetry {
|
|
1201
|
+
class ResultRetry extends ResultAsync {
|
|
1204
1202
|
static zero() {
|
|
1205
1203
|
return 0;
|
|
1206
1204
|
}
|
|
@@ -1214,6 +1212,7 @@ class ResultRetry {
|
|
|
1214
1212
|
return 0;
|
|
1215
1213
|
}
|
|
1216
1214
|
constructor(f) {
|
|
1215
|
+
super(Promise.resolve().then(() => __classPrivateFieldGet(this, _ResultRetry_promise, "f")));
|
|
1217
1216
|
_ResultRetry_f.set(this, void 0);
|
|
1218
1217
|
_ResultRetry_promise.set(this, void 0);
|
|
1219
1218
|
_ResultRetry_times.set(this, 1);
|
|
@@ -1226,7 +1225,7 @@ class ResultRetry {
|
|
|
1226
1225
|
__classPrivateFieldSet(this, _ResultRetry_promise, this.drain(), "f");
|
|
1227
1226
|
}
|
|
1228
1227
|
then(onfulfilled, onrejected) {
|
|
1229
|
-
return
|
|
1228
|
+
return super.then(onfulfilled, onrejected);
|
|
1230
1229
|
}
|
|
1231
1230
|
/**
|
|
1232
1231
|
* Sets the maximum number of times the retry function can be executed,
|
|
@@ -1296,39 +1295,6 @@ class ResultRetry {
|
|
|
1296
1295
|
__classPrivateFieldSet(this, _ResultRetry_handler, f, "f");
|
|
1297
1296
|
return this;
|
|
1298
1297
|
}
|
|
1299
|
-
/**
|
|
1300
|
-
* Returns {@link ResultAsync} which resolves to this retried {@link Result}.
|
|
1301
|
-
*
|
|
1302
|
-
* @example
|
|
1303
|
-
*
|
|
1304
|
-
* ```ts
|
|
1305
|
-
* const result: Result<string, SomeError> = await Result
|
|
1306
|
-
* .$retry(someResultFn)
|
|
1307
|
-
* .$times(3)
|
|
1308
|
-
* .$delay(100)
|
|
1309
|
-
* .$async()
|
|
1310
|
-
* .$andThen((message) => `Success: ${message}`)
|
|
1311
|
-
* .$mapErr((code) => new SomeError({ code }));
|
|
1312
|
-
* ```
|
|
1313
|
-
*/
|
|
1314
|
-
$async() {
|
|
1315
|
-
return new ResultAsync(this);
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* Returns a `Promise` which resolves to this retried {@link Result}.
|
|
1319
|
-
*
|
|
1320
|
-
* @example
|
|
1321
|
-
*
|
|
1322
|
-
* ```ts
|
|
1323
|
-
* const promise: Promise<Result<string, Error>> = Result
|
|
1324
|
-
* .$retry(someResultFn)
|
|
1325
|
-
* .$times(3)
|
|
1326
|
-
* .$promise();
|
|
1327
|
-
* ```
|
|
1328
|
-
*/
|
|
1329
|
-
$promise() {
|
|
1330
|
-
return Promise.resolve(this);
|
|
1331
|
-
}
|
|
1332
1298
|
async drain() {
|
|
1333
1299
|
var _b;
|
|
1334
1300
|
while (__classPrivateFieldGet(this, _ResultRetry_attempt, "f") < __classPrivateFieldGet(this, _ResultRetry_times, "f")) {
|