From 035179d0224c6c9fc0ce71be3172717555d45018 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Fri, 3 Jan 2025 14:56:47 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20document=20the=20`constant()`=20?= =?UTF-8?q?function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constant.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/constant.ts b/lib/constant.ts index bace3fed..dc5bf2ee 100644 --- a/lib/constant.ts +++ b/lib/constant.ts @@ -1,5 +1,17 @@ import type { Operation } from "./types.ts"; +/** + * Create an {@link Operation} that always evaluates to `value`. + * + * @example + * + * ```ts + * let x = yield* constant("hello world"); + * x === "hello world" //=> true + * ``` + * + * @returns the {@link Operation} that evaluates to `value`; + */ export function constant(value: T): Operation { return { [Symbol.iterator]: () => ({ next: () => ({ done: true, value }) }),