For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/function/call.md.

call

Invokes a function with the provided arguments and returns the result.

Equivalent to fn(...args) — exists as a stable, named surface for the "apply function to args" operation. Use inside .map(call) over arrays of thunks, or anywhere a value-position function-call is clearer than an inline arrow.

call(Math.max, 1, 2, 3) // 3
[getUser, getAccount, getPrefs].map((fn) => call(fn))

Usage

call<A extends readonly unknown[], R>(fn: (...args: A) => R, ...args: A)

Invokes a function with the provided arguments and returns the result.

Equivalent to fn(...args) — exists as a stable, named surface for the "apply function to args" operation. Use inside .map(call) over arrays of thunks, or anywhere a value-position function-call is clearer than an inline arrow.

import { call } from 'massaman'
// or:  import { call } from 'massaman/function'

call(Math.max, 1, 2, 3) // 3
[getUser, getAccount, getPrefs].map((fn) => call(fn))

Parameters

fn(...args: A) => Rrequired

the function to invoke.

argsArequired

the arguments passed to fn.

Returns

the value returned by fn.

R