@sapphire/result 2.8.0-next.6abc5522 → 2.8.0-next.f3515ea3
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/cjs/index.cjs +0 -48
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -115
- package/dist/esm/index.d.mts +1 -115
- package/dist/esm/index.mjs +0 -48
- package/dist/esm/index.mjs.map +1 -1
- package/dist/iife/index.global.js +0 -48
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +1 -1
|
@@ -42,7 +42,6 @@ var SapphireResult = (function (exports) {
|
|
|
42
42
|
// src/lib/Result.ts
|
|
43
43
|
var ValueProperty = Symbol.for("@sapphire/result:Result.value");
|
|
44
44
|
var SuccessProperty = Symbol.for("@sapphire/result:Result.success");
|
|
45
|
-
var UnwrapSafeProperty = Symbol.for("@sapphire/result:Result.safeUnwrap");
|
|
46
45
|
var _a, _b;
|
|
47
46
|
var _Result = class _Result {
|
|
48
47
|
constructor(value, success) {
|
|
@@ -469,7 +468,6 @@ var SapphireResult = (function (exports) {
|
|
|
469
468
|
* @seealso {@link unwrapOrElse}
|
|
470
469
|
* @seealso {@link unwrapErr}
|
|
471
470
|
* @seealso {@link unwrapRaw}
|
|
472
|
-
* @seealso {@link unwrapSafe}
|
|
473
471
|
*
|
|
474
472
|
* @example
|
|
475
473
|
* ```typescript
|
|
@@ -500,7 +498,6 @@ var SapphireResult = (function (exports) {
|
|
|
500
498
|
* @seealso {@link unwrapOr}
|
|
501
499
|
* @seealso {@link unwrapOrElse}
|
|
502
500
|
* @seealso {@link unwrapRaw}
|
|
503
|
-
* @seealso {@link unwrapSafe}
|
|
504
501
|
*
|
|
505
502
|
* @example
|
|
506
503
|
* ```typescript
|
|
@@ -532,7 +529,6 @@ var SapphireResult = (function (exports) {
|
|
|
532
529
|
* @seealso {@link unwrapOrElse}
|
|
533
530
|
* @seealso {@link unwrapErr}
|
|
534
531
|
* @seealso {@link unwrapRaw}
|
|
535
|
-
* @seealso {@link unwrapSafe}
|
|
536
532
|
*
|
|
537
533
|
* @param defaultValue The default value.
|
|
538
534
|
*
|
|
@@ -558,7 +554,6 @@ var SapphireResult = (function (exports) {
|
|
|
558
554
|
* @seealso {@link unwrapOr}
|
|
559
555
|
* @seealso {@link unwrapErr}
|
|
560
556
|
* @seealso {@link unwrapRaw}
|
|
561
|
-
* @seealso {@link unwrapSafe}
|
|
562
557
|
*
|
|
563
558
|
* @param op The predicate.
|
|
564
559
|
*
|
|
@@ -583,7 +578,6 @@ var SapphireResult = (function (exports) {
|
|
|
583
578
|
* @seealso {@link unwrapOr}
|
|
584
579
|
* @seealso {@link unwrapOrElse}
|
|
585
580
|
* @seealso {@link unwrapErr}
|
|
586
|
-
* @seealso {@link unwrapSafe}
|
|
587
581
|
*
|
|
588
582
|
* @example
|
|
589
583
|
* ```typescript
|
|
@@ -604,26 +598,6 @@ var SapphireResult = (function (exports) {
|
|
|
604
598
|
if (this.isErr()) throw this[ValueProperty];
|
|
605
599
|
return this[ValueProperty];
|
|
606
600
|
}
|
|
607
|
-
/**
|
|
608
|
-
* Returns the contained `Ok` value or yelds the contained `Err` value.
|
|
609
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also {@link Result.safeTry}.
|
|
610
|
-
*
|
|
611
|
-
* If used outside of a `safeTry`'s' body, throws the contained error.
|
|
612
|
-
* @seealso {@link unwrap}
|
|
613
|
-
* @seealso {@link unwrapOr}
|
|
614
|
-
* @seealso {@link unwrapErr}
|
|
615
|
-
* @seealso {@link unwrapRaw}
|
|
616
|
-
* @seealso {@link unwrapSafe}
|
|
617
|
-
*
|
|
618
|
-
* @see {@link https://doc.rust-lang.org/std/result/enum.Result.html#method.unwrap_safe}
|
|
619
|
-
*/
|
|
620
|
-
*unwrapSafe() {
|
|
621
|
-
if (this.isOk()) {
|
|
622
|
-
return this[ValueProperty];
|
|
623
|
-
}
|
|
624
|
-
yield this;
|
|
625
|
-
throw new ResultError("Should not be used outside of a safe try generator", this[ValueProperty]);
|
|
626
|
-
}
|
|
627
601
|
/**
|
|
628
602
|
* Returns `result` if the result is `Ok`, otherwise returns the `Err` value of itself.
|
|
629
603
|
* @param result The result to check.
|
|
@@ -898,16 +872,6 @@ var SapphireResult = (function (exports) {
|
|
|
898
872
|
get [Symbol.toStringTag]() {
|
|
899
873
|
return this.match({ ok: /* @__PURE__ */ __name(() => "Ok", "ok"), err: /* @__PURE__ */ __name(() => "Err", "err") });
|
|
900
874
|
}
|
|
901
|
-
/**
|
|
902
|
-
* This function, in combination with `[$]`, is intended to emulate
|
|
903
|
-
* Rust's ? operator.
|
|
904
|
-
*
|
|
905
|
-
* @see {@link Result.safeTry}
|
|
906
|
-
* @see {@link https://doc.rust-lang.org/std/result/enum.Result.html#method.safeTry}
|
|
907
|
-
*/
|
|
908
|
-
get [UnwrapSafeProperty]() {
|
|
909
|
-
return this.unwrapSafe();
|
|
910
|
-
}
|
|
911
875
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
912
876
|
static ok(value) {
|
|
913
877
|
return new _Result(value, true);
|
|
@@ -1027,13 +991,6 @@ var SapphireResult = (function (exports) {
|
|
|
1027
991
|
}
|
|
1028
992
|
return err(errors);
|
|
1029
993
|
}
|
|
1030
|
-
static safeTry(body) {
|
|
1031
|
-
const n = body({ $: UnwrapSafeProperty, $async: unwrapSafeAsync }).next();
|
|
1032
|
-
if (n instanceof Promise) {
|
|
1033
|
-
return n.then((r) => r.value);
|
|
1034
|
-
}
|
|
1035
|
-
return n.value;
|
|
1036
|
-
}
|
|
1037
994
|
};
|
|
1038
995
|
__name(_Result, "Result");
|
|
1039
996
|
var Result = _Result;
|
|
@@ -1042,11 +999,6 @@ var SapphireResult = (function (exports) {
|
|
|
1042
999
|
return Result.isResult(value) ? value : ok(value);
|
|
1043
1000
|
}
|
|
1044
1001
|
__name(resolve, "resolve");
|
|
1045
|
-
async function* unwrapSafeAsync(result) {
|
|
1046
|
-
const _result = await result;
|
|
1047
|
-
return yield* _result.unwrapSafe();
|
|
1048
|
-
}
|
|
1049
|
-
__name(unwrapSafeAsync, "unwrapSafeAsync");
|
|
1050
1002
|
|
|
1051
1003
|
// src/lib/Option.ts
|
|
1052
1004
|
var ValueProperty2 = Symbol.for("@sapphire/result:Option.value");
|