"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

exports.default = function (callback, delay) {
  var isThrottled = false,
      args = void 0,
      context = void 0;

  function wrapper() {
    if (isThrottled) {
      args = arguments;
      context = this;
      return;
    }

    isThrottled = true;
    callback.apply(this, arguments);

    setTimeout(function () {
      isThrottled = false;
      if (args) {
        wrapper.apply(context, args);
        args = context = null;
      }
    }, delay);
  }

  return wrapper;
};