diff --git a/src/async_option.ts b/src/async_option.ts index def48c1..aeaae81 100644 --- a/src/async_option.ts +++ b/src/async_option.ts @@ -1,3 +1,8 @@ +/** + * This module contains the `AsyncOption` class, which is a promise that resolves to an `Option`. + * @module + */ + import { AsyncResult } from "./async_result.ts"; import { None, type Option, type OptionMatch, type OptionMatchAsync, Some } from "./option.ts"; @@ -7,8 +12,15 @@ import { None, type Option, type OptionMatch, type OptionMatchAsync, Some } from * This class is useful for chaining multiple asynchronous operations that return an `Option`. */ export class AsyncOption implements PromiseLike> { + /** + * The promise that resolves to an `Option`. + */ public readonly promise: Promise> | PromiseLike> | AsyncOption; + /** + * Creates a new `AsyncOption`. + * @param promise - The promise that resolves to an `Option`. + */ public constructor(promise: Promise> | PromiseLike> | AsyncOption) { this.promise = promise; } @@ -17,10 +29,16 @@ export class AsyncOption implements PromiseLike> { return "AsyncOption"; } + /** + * Converts the `AsyncOption` to a JSON object. + */ public toJSON(): { AsyncOption: Promise> | PromiseLike> | AsyncOption } { return { AsyncOption: this.promise }; } + /** + * Converts the `AsyncOption` to a string. + */ public toString(): string { return `AsyncOption(${this.promise.toString()})`; }