mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 21:22:33 +00:00
* feat: add test to validate timeline presence * feat: add test and docs for close and timeline * feat: add filter test * docs: dont reference go, it's not relevant
17 lines
423 B
JavaScript
17 lines
423 B
JavaScript
'use strict'
|
|
|
|
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
|
|
}
|
|
}
|