call-no-more-often-than

1.0.6 • Public • Published

Call-no-more-often-than

NPM version

Call a function or something else no more often than a certain amount of time

Install

npm i call-no-more-often-than --save-dev

Usage

  const call_no_more_often_than = require('call-no-more-often-than');

  call_no_more_often_than(3000).then(function(){
      // Your code that won't execute more often than 3000 milliseconds
  });

Examples

  const call_no_more_often_than = require('call-no-more-often-than');

  test_function();
  test_function();

  setTimeout(function(){
    test_function();
  }, 2000);

  function test_function(){
    call_no_more_often_than(3000).then(function(){
      console.log('Called once');
    });  
  }

Options

time

  • Type: Integer
  • Default value: 1000

The number is specified in milliseconds. The time during which the internal code of the function will not be called after the first call. The deviation accuracy can be 10-30 milliseconds.

Package Sidebar

Install

npm i call-no-more-often-than

Weekly Downloads

3

Version

1.0.6

License

MIT

Unpacked Size

4.09 kB

Total Files

5

Last publish

Collaborators

  • yuriy-svetlov