> For the complete documentation index, see [llms.txt](https://baek2back.gitbook.io/fundamental/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://baek2back.gitbook.io/fundamental/function/once.md).

# once

최초 한번의 함수 호출만 허용

```typescript
function once<A extends any[], R, T>(
  fn: (this: T, ...args: A) => R
): (this: T, ...args: A) => R | undefined {
  let done = false;
  return function (this: T, ...args: A) {
    return done
      ? undefined
      : ((done = true), fn.apply(this, args));
  };
}
```
