Function returnsArgs

  • Creates a function that returns its arguments or a subset of them. If end is specified, it will return arguments up to but not including the end.

    Type Parameters

    • Args extends unknown[]

      The arguments type of the returned function

    • Self = any

      The self type of the returned function

    Parameters

    • start: number = 0

      The start index of the arguments to return. Default is 0.

    • Optionalend: number

      The end index of the arguments to return.

    Returns ((this: Self, ...args: Args) => Args)

    A function that returns its arguments or a subset of them.

    import { returnsArgs } from "@std/testing/mock";
    import { assertEquals } from "@std/assert";

    const func = returnsArgs();
    assertEquals(func(1, 2, 3), [1, 2, 3]);