1.0.1 • Published 7 years ago

call-once-in-interval v1.0.1

Weekly downloads
14
License
ISC
Repository
github
Last release
7 years ago

call-once-in-interval

A JavaScript module which calls the passed function once in the passed interval.

NPM URL

  • @param {Function} functionTobeCalled The function to be called in the interval.
  • @param {number} interval=600 The interval (in milliseconds) within which the function will not be called.
  • @returns {Function} Returns the new function.
  • @example
// Call a form submit only once even if the user presses the button multiple times.

const onSubmit = () => 'called'
const clickHandler = callOnceInInterval(onSubmit, 1000);

clickHandler();
// => 'called' //This will call the onSubmit

clickHandler();
// => undefined  //All the further calls will not be processed until 1000 ms.