Genel bakış

Input

Identity behavior for starting typed pipelines.

composition

Install

$
Terminal window
pnpm dlx shadcn@latest add https://archyn.net/r/input.json

Copy the files below into the target paths shown in each tab.

ts@lib/flow/input.ts
import { type Behavior } from "./core/runtime";
import { task } from "./task";
/**
* Creates an identity behavior for starting typed pipelines.
*
* `input` is useful when the first meaningful step is a `map`, `tap`, or `pipe` composition and
* you want the pipeline input type to be explicit.
*
* @typeParam I - Input and output type.
* @returns A behavior that succeeds with its input value.
*
* @example
* ```ts
* const normalizeName = pipe(input<string>(), map(input<string>(), (value) => value.trim()));
* ```
*/
export function input<I>(): Behavior<I, I, never> {
return task<I, I, never>((value, context) => context.ok(value));
}

Update the import paths to match your project setup.

Create an identity Behavior for starting typed pipelines.

Usage

input returns the received input as the successful output. It is useful when a pipeline needs an explicit starting Behavior before mapping or branching.

Use it when:

  • Start a pipeline with a typed input value.
  • Create a reusable identity step for composition.
  • Keep a pipeline shape consistent before adding transforms.
import { input } from "@/lib/flow/input";
import { map } from "@/lib/flow/map";
const normalizedInput = map(input<string>(), (value) => value.trim().toLowerCase());

Behavior

input is implemented as a task that returns context.ok(value) for the incoming value.

input has no domain failure type. Runtime cancellation can still be returned by the runtime if the signal is already aborted.

Types

Input and output are the same type, with no domain error.

Import from @/lib/flow/input.

Composition Notes

Use input to start pipelines with map, tap, or pipe when no source task is needed.

Do not use input when a task already establishes the pipeline input type.

Source

ts@lib/flow/input.ts
import { type Behavior } from "./core/runtime";
import { task } from "./task";
/**
* Creates an identity behavior for starting typed pipelines.
*
* `input` is useful when the first meaningful step is a `map`, `tap`, or `pipe` composition and
* you want the pipeline input type to be explicit.
*
* @typeParam I - Input and output type.
* @returns A behavior that succeeds with its input value.
*
* @example
* ```ts
* const normalizeName = pipe(input<string>(), map(input<string>(), (value) => value.trim()));
* ```
*/
export function input<I>(): Behavior<I, I, never> {
return task<I, I, never>((value, context) => context.ok(value));
}