Обзор
functionCore Record

normalizedConcurrency

Normalizes a requested concurrency value for keyed parallel helpers.

Signature

tsSignature
export function normalizedConcurrency(value: number | undefined, count: number): number;

Imports

tsImport
import { normalizedConcurrency } from "@/lib/flow/core/record";
import { normalizedConcurrency } from "@/lib/flow";

Parameters

value
number | undefined

Requested concurrency.

count
number

Number of available children.

Returns

Safe concurrency limit.

Return type
number

Details

Non-finite or missing values run all children. Finite values are floored and clamped to the

inclusive range from one to the number of children.

all

Runs keyed behaviors in parallel and fails fast on the first child failure.

function
from

Converts a structural result-like value into a branded Flow result.

function
run

Runs a behavior with an optional application context.

function

Source

tsflow/core/record.ts:124-134
export function normalizedConcurrency(value: number | undefined, count: number): number {
if (count === 0) {
return 0;
}
if (value === undefined || !Number.isFinite(value)) {
return count;
}
return Math.max(1, Math.min(count, Math.floor(value)));
}