Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. The func is invoked with the arguments of the created function.
func
Returns the new restricted function.
let func = x => xlet single = once(func)single(1) // 1single(2) // 1single(3) // 1// ...// `func` is invoked only once.
The function to restrict
Generated using TypeDoc
Creates a function that is restricted to invoking
funconce. Repeat calls to the function return the value of the first invocation. Thefuncis invoked with the arguments of the created function.Returns
Returns the new restricted function.
Example