📝 Bind the handler-map function in every example

Each README and JSDoc example now assigns the function that takes the
handler object (the factory result, or the tagged key step) to a match…
variable and reuses it, so the builder is created once instead of per
call.
This commit is contained in:
tmu committed 2026-09-23 22:33:43 +00:00
1 parent c8bee95088
commit c878e60ff2
3 files changed
+20 -7

No files matched your search

+4 -2
View File
@@ -111,7 +111,8 @@ const dispatch =
* @typeParam T - The finite universe of primitive members to match.
* @returns A builder for the handler map, or the handler map plus a fallback.
* @example
* const describe = getPrimitiveUnionMatcher<"yes" | "no">()({
* const matchAnswer = getPrimitiveUnionMatcher<"yes" | "no">();
* const describe = matchAnswer({
* yes: () => "agreed",
* no: () => "declined",
* });
@@ -133,7 +134,8 @@ export const getPrimitiveUnionMatcher = <
* @typeParam T - The finite universe of primitive members to match.
* @returns A builder for the handler map, or the handler map plus a fallback.
* @example
* const reply = getPrimitiveUnionMatcherW<"yes" | "no">()({
* const matchReply = getPrimitiveUnionMatcherW<"yes" | "no">();
* const reply = matchReply({
* yes: () => 1,
* no: () => "declined",
* });