1.0.0 • Published 7 years ago

max-frequency-caller v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Max Frequency Caller

Wrap a frequently called function in this Max Frequency Caller to limit the running of it to a max frequency.

import maxFreq from 'max-frequency-caller';

function publishData(channel, data) {
  // ...
  // (In some way costly for the system, e.g
  // due to the use of some external connection)
}

export default function publish(channel, data) {
  maxFreq(publishData, [channel, data], 500);
}
// If publish is called multiple times, only the calls that are
// at least 500 ms apart will run.