Module: functions

Methods


<static> debounce(fn [, delay])

debounce

Parameters:
Name Type Argument Default Description
fn TypeVoidFunction
delay Number <optional>
0
Source:
See:
Returns:
Type
TypeVoidFunction
Example
import { debounce } from '@nonoll/code-snippet/functions';

const forExample = () => {
  const delay = 1000 * 1;
  const listener = debounce(res => console.log(res), delay);

  listener('1');
  listener('2');
  listener('3');
  listener(`4 ${new Date()}`);

  setTimeout(() => {
    listener(`5 ${new Date()}`);
  }, delay);
}

forExample();

<static> deepFreeze(target)

deepFreeze

Parameters:
Name Type Description
target any
Source:

<static> throttle(fn [, delay])

throttle

Parameters:
Name Type Argument Default Description
fn TypeVoidFunction
delay Number <optional>
0
Source:
See:
Returns:
Type
TypeVoidFunction
Example
import { debounce } from '@nonoll/code-snippet/functions';

const forExample = () => {
  const delay = 1000 * 1;
  const listener = throttle(res => console.log(res), delay);

  listener(`1 ${new Date()}`);
  listener('2');
  listener('3');
  listener('4');

  setTimeout(() => {
    listener(`5 ${new Date()}`);
  }, delay);
}

forExample();

noop()

empty function

Source: