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.
@monochromatic-dev/module-function-arity #
Ready to publish.
Function arity wrappers for callbacks that receive more positional arguments than the wrapped function should see.
Helpers #
unary(fn) #
Returns a one-argument wrapper. Use it when a host API passes extra arguments that would change wrapped-function behavior.
import { unary, } from '@monochromatic-dev/module-function-arity';
const parsed = ['10', '10', '10'].map(unary(Number.parseInt,));
// [10, 10, 10]
binary(fn) #
Returns a two-argument wrapper. Use it when value and index should reach callback logic, but source collection should not.
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']
Design decisions #
- Source-only.
No build step;
consumers import directly from
src/index.ts. - Direct named exports.
unaryandbinaryare named for the arity they preserve. - One file per helper.
unary.tsandbinary.tshold implementations, andindex.tsre-exports them. - Family scope. This package owns callback arity wrappers. It does not own currying, partial application, memoization, or function composition.
- Extracted from
module-es. These helpers previously lived under thetypes.function.from.functiontaxonomy. Promoting them to their own package makes direct consumers depend on the focused utility instead of the largermodule-espackage.