Skip to main content
Module

x/froebel/function.ts>limitInvocations

A strictly typed utility library.
Go to Latest
variable limitInvocations
import { limitInvocations } from "https://deno.land/x/froebel@v0.20.0/function.ts";

Returns a version of the function fun that can only be invoked limit times. An optional except function will be called with the same parameters on any additional invocations.

If fun returns anything but void (or Promise<void>), supplying an except function is mandatory.

The except function must have the same return type as fun, or — if fun returns a promise — it may return the type that the promise resolves to synchronously.

The except function may also throw instead of returning a value.

type

<T extends λ>(
fun: T,
limit: number,
...unnamed 2: ExcS<T>,
) => T