@@ -399,19 +399,34 @@ class ResultConstructor<F, S, T extends ResultType = ResultType>
399399 ) ;
400400 }
401401
402- private static _initialInstance : ResultConstructor < never , never , ResultType . Initial > ;
402+ private static _initialInstance : ResultConstructor <
403+ never ,
404+ never ,
405+ ResultType . Initial
406+ > ;
403407 static initial ( ) : Result < never , never > {
404408 if ( ResultConstructor . _initialInstance === undefined ) {
405- ResultConstructor . _initialInstance = new ResultConstructor < never , never , ResultType . Initial > ( ResultType . Initial , undefined ) ;
409+ ResultConstructor . _initialInstance = new ResultConstructor <
410+ never ,
411+ never ,
412+ ResultType . Initial
413+ > ( ResultType . Initial , undefined ) ;
406414 }
407415 return ResultConstructor . _initialInstance ;
408416 }
409417
410-
411- private static _pendingInstance : ResultConstructor < never , never , ResultType . Pending > ;
418+ private static _pendingInstance : ResultConstructor <
419+ never ,
420+ never ,
421+ ResultType . Pending
422+ > ;
412423 static pending ( ) : Result < never , never > {
413424 if ( ResultConstructor . _pendingInstance === undefined ) {
414- ResultConstructor . _pendingInstance = new ResultConstructor < never , never , ResultType . Pending > ( ResultType . Pending , undefined ) ;
425+ ResultConstructor . _pendingInstance = new ResultConstructor <
426+ never ,
427+ never ,
428+ ResultType . Pending
429+ > ( ResultType . Pending , undefined ) ;
415430 }
416431 return ResultConstructor . _pendingInstance ;
417432 }
@@ -650,7 +665,7 @@ class ResultConstructor<F, S, T extends ResultType = ResultType>
650665
651666 throw new Error ( 'Result state is not Right' ) ;
652667 }
653-
668+
654669 unwrapOr ( x : S ) : S {
655670 return this . isSuccess ( ) ? this . value : x ;
656671 }
@@ -690,3 +705,23 @@ export const pending = ResultConstructor.pending();
690705export const isResult = < F , S > (
691706 value : unknown | Result < F , S >
692707) : value is Result < F , S > => value instanceof ResultConstructor ;
708+
709+ export const isInitial = < F , S > (
710+ value : unknown | Result < F , S >
711+ ) : value is ResultConstructor < F , S , ResultType . Initial > =>
712+ isResult ( value ) && value . isInitial ( ) ;
713+
714+ export const isPending = < F , S > (
715+ value : unknown | Result < F , S >
716+ ) : value is ResultConstructor < F , S , ResultType . Pending > =>
717+ isResult ( value ) && value . isPending ( ) ;
718+
719+ export const isSuccess = < F , S > (
720+ value : unknown | Result < F , S >
721+ ) : value is ResultConstructor < F , S , ResultType . Success > =>
722+ isResult ( value ) && value . isSuccess ( ) ;
723+
724+ export const isFailure = < F , S > (
725+ value : unknown | Result < F , S >
726+ ) : value is ResultConstructor < F , S , ResultType . Failure > =>
727+ isResult ( value ) && value . isFailure ( ) ;
0 commit comments