libp2p-interfaces-compliance-tests
Version:
Compliance tests for JS Libp2p interfaces
18 lines (16 loc) • 432 B
JavaScript
module.exports = {
/**
* A tick is considered valid if it happened between now
* and `ms` milliseconds ago
*
* @param {number} date - Time in ticks
* @param {number} ms - max milliseconds that should have expired
* @returns {boolean}
*/
isValidTick: function isValidTick (date, ms = 5000) {
const now = Date.now()
if (date > now - ms && date <= now) return true
return false
}
}