returnsArg

import { returnsArg } from "jsr:@ende/testing/mock";

function

function returnsArg<Arg, Self = any>(idx: number): (this: Self, ...args: Arg[]) => Arg | undefined

Creates a function that returns one of its arguments.

idx: number

The index of the arguments to use.

Returns

A function that returns one of its arguments.

Example: Usage

import { returnsArg } from "@ende/testing/mock";
import { assertEquals } from "@ende/assert";

const func = returnsArg(1);
assertEquals(func(1, 2, 3), 2);

Source