The restriction of term.
npm install restrictionThe restriction of term.
> This project has been created by Vessel CLI.
For a simple and quick reference about it, click here.
bash
$ npm install --save restriction
or
$ yarn add restriction
`Modules in the package
본 패키지에는 아래와 같은 모듈들을 포함한다.
제공되는 모듈과 메소드 사용법 등은 코드 스니핏을 참고한다.$3
샘플 모듈은 다음과 같은 메소드들을 제공한다.####
debounce
연속적인 빠른 이벤트 콜백들에 제약을 걸어 이벤트 호출 횟수를 감소시킨다.
`typescript
type AnyFunction = (...args: any[]) => any;
type DebounceOption = {
ms?: number; // milliseconds
immediate?: boolean; // debounce 실행 즉시 반영여부
};
type DebouncedFunction = {
handler(...args: Parameters): void;
stop(): void;
};function debounce(
callback: F,
debounceOption?: DebounceOption,
): DebouncedFunction {}
`####
throttle
연속적인 빠른 이벤트 콜백들에 제약을 걸어 일정 주기마다 호출하도록 한다.
`typescript
type AnyFunction = (...args: any[]) => any;
type ThrottleOption = {
ms?: number; // milliseconds
immediate?: boolean; // throttle 실행 즉시 반영여부
};
type ThrottledFunction = {
handler(...args: Parameters): void;
stop(): void;
};function throttle(
callback: F,
throttleOption?: ThrottleOption,
): ThrottledFunction {}
``