Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445/** Wraps callback so only first two positional arguments reach wrapped function. Useful when host APIs pass value, index, and collection but callback logic must be protected from collection argument. `Array.prototype.map` remains a natural consumer because mapped value and index stay available while source array does not leak into callback. @param fn - callback that can run from first two positional arguments alone @returns wrapper forwarding only first two positional arguments @example ```ts import { binary, } from '\@monochromatic-dev/module-function-arity'; const rendered = ['a', 'b'].map(binary(function render( value: string, index: number, ): string { return `${index}:${value}`; },),); // ['0:a', '1:b'] ``` */export function binary<const TFirstArgument, const TSecondArgument, const TReturn,>( fn: ( firstArgument: TFirstArgument, secondArgument: TSecondArgument, ) => TReturn,): ( firstArgument: TFirstArgument, secondArgument: TSecondArgument,) => TReturn { return (function binaryWrapper( firstArgument: TFirstArgument, secondArgument: TSecondArgument, ): TReturn { return fn( firstArgument, secondArgument, ); });}