1.0.6 • Published 3 years ago

call-no-more-often-than v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago