@everyonesoftware/common 6.0.0 → 8.0.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.
@@ -94,6 +94,26 @@ declare abstract class Comparable<T> {
94
94
  static greaterThan<T>(left: Comparable<T>, right: T): boolean;
95
95
  }
96
96
 
97
+ declare class PromiseAsyncResult<T> implements AsyncResult<T> {
98
+ private readonly promise;
99
+ private constructor();
100
+ static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): PromiseAsyncResult<T>;
101
+ static empty(): PromiseAsyncResult<void>;
102
+ static value<T>(value: T): PromiseAsyncResult<T>;
103
+ static error<T>(error: unknown): PromiseAsyncResult<T>;
104
+ static yield(): PromiseAsyncResult<void>;
105
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>;
106
+ onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>;
107
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>;
108
+ catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>;
109
+ onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
110
+ onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
111
+ convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
112
+ convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
113
+ finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>;
114
+ readonly [Symbol.toStringTag]: string;
115
+ }
116
+
97
117
  declare class SyncResult<T> implements AsyncResult<T> {
98
118
  private value;
99
119
  private error;
@@ -690,8 +710,11 @@ declare function isPromise<T>(value: unknown): value is Promise<T>;
690
710
  * A result object that adds extra behavior beyond the standard {@link Promise}.
691
711
  */
692
712
  declare abstract class AsyncResult<T> implements Promise<T> {
693
- static create<T>(action: () => (T | Promise<T>)): AsyncResult<T>;
694
- static create<T>(promise: Promise<T>): AsyncResult<T>;
713
+ static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): AsyncResult<T>;
714
+ /**
715
+ * Get an {@link AsyncResult} that is already completed and doesn't do anything.
716
+ */
717
+ static empty(): AsyncResult<void>;
695
718
  /**
696
719
  * Create a new {@link AsyncResult} that contains the provided value.
697
720
  * @param value The value to wrap in a {@link AsyncResult}.
@@ -755,26 +778,6 @@ declare abstract class AsyncResult<T> implements Promise<T> {
755
778
  readonly abstract [Symbol.toStringTag]: string;
756
779
  }
757
780
 
758
- declare class PromiseAsyncResult<T> implements AsyncResult<T> {
759
- private readonly promise;
760
- private constructor();
761
- static create<T>(action: () => (T | Promise<T>)): PromiseAsyncResult<T>;
762
- static create<T>(promise: Promise<T>): PromiseAsyncResult<T>;
763
- static value<T>(value: T): PromiseAsyncResult<T>;
764
- static error<T>(error: unknown): PromiseAsyncResult<T>;
765
- static yield(): PromiseAsyncResult<void>;
766
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>;
767
- onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>;
768
- catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>;
769
- catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>;
770
- onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
771
- onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
772
- convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
773
- convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
774
- finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>;
775
- readonly [Symbol.toStringTag]: string;
776
- }
777
-
778
781
  declare abstract class CharacterWriteStream {
779
782
  /**
780
783
  * Write the provided text to this {@link CharacterWriteStream}.
@@ -94,6 +94,26 @@ declare abstract class Comparable<T> {
94
94
  static greaterThan<T>(left: Comparable<T>, right: T): boolean;
95
95
  }
96
96
 
97
+ declare class PromiseAsyncResult<T> implements AsyncResult<T> {
98
+ private readonly promise;
99
+ private constructor();
100
+ static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): PromiseAsyncResult<T>;
101
+ static empty(): PromiseAsyncResult<void>;
102
+ static value<T>(value: T): PromiseAsyncResult<T>;
103
+ static error<T>(error: unknown): PromiseAsyncResult<T>;
104
+ static yield(): PromiseAsyncResult<void>;
105
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>;
106
+ onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>;
107
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>;
108
+ catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>;
109
+ onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
110
+ onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
111
+ convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
112
+ convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
113
+ finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>;
114
+ readonly [Symbol.toStringTag]: string;
115
+ }
116
+
97
117
  declare class SyncResult<T> implements AsyncResult<T> {
98
118
  private value;
99
119
  private error;
@@ -690,8 +710,11 @@ declare function isPromise<T>(value: unknown): value is Promise<T>;
690
710
  * A result object that adds extra behavior beyond the standard {@link Promise}.
691
711
  */
692
712
  declare abstract class AsyncResult<T> implements Promise<T> {
693
- static create<T>(action: () => (T | Promise<T>)): AsyncResult<T>;
694
- static create<T>(promise: Promise<T>): AsyncResult<T>;
713
+ static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): AsyncResult<T>;
714
+ /**
715
+ * Get an {@link AsyncResult} that is already completed and doesn't do anything.
716
+ */
717
+ static empty(): AsyncResult<void>;
695
718
  /**
696
719
  * Create a new {@link AsyncResult} that contains the provided value.
697
720
  * @param value The value to wrap in a {@link AsyncResult}.
@@ -755,26 +778,6 @@ declare abstract class AsyncResult<T> implements Promise<T> {
755
778
  readonly abstract [Symbol.toStringTag]: string;
756
779
  }
757
780
 
758
- declare class PromiseAsyncResult<T> implements AsyncResult<T> {
759
- private readonly promise;
760
- private constructor();
761
- static create<T>(action: () => (T | Promise<T>)): PromiseAsyncResult<T>;
762
- static create<T>(promise: Promise<T>): PromiseAsyncResult<T>;
763
- static value<T>(value: T): PromiseAsyncResult<T>;
764
- static error<T>(error: unknown): PromiseAsyncResult<T>;
765
- static yield(): PromiseAsyncResult<void>;
766
- then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>;
767
- onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>;
768
- catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>;
769
- catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>;
770
- onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
771
- onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
772
- convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
773
- convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
774
- finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>;
775
- readonly [Symbol.toStringTag]: string;
776
- }
777
-
778
781
  declare abstract class CharacterWriteStream {
779
782
  /**
780
783
  * Write the provided text to this {@link CharacterWriteStream}.