Creates a function that invokes fn until it has been called n - 1 times.
fn
n - 1
The returned function will call fn for the first n - 1 invocations. After that, it always returns undefined.
undefined
The type of the function to be invoked.
The maximum number of times fn can be invoked plus one.
The function to invoke until the limit is reached.
A new function that stops invoking fn after n - 1 calls.
1.2.0
const limited = before(3, () => console.log("Run"));limited(); limited(); limited(); // logs "Run" twice Copy
const limited = before(3, () => console.log("Run"));limited(); limited(); limited(); // logs "Run" twice
Creates a function that invokes
fn
until it has been calledn - 1
times.The returned function will call
fn
for the firstn - 1
invocations. After that, it always returnsundefined
.