
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
get-countdown
Advanced tools
轮询获取剩余毫秒倒计时长
npm i -S get-countdown
const getCountdown = require('get-countdown')
getCountdown(60 * 1000, 1000, (countdownMs, timeoutId) => {
// clearTimeout(timeoutId) // 清除定时器后,callback将不再执行
// 当countdownMs小于等于0时,定时器自动清除,callback将不再执行
console.log(`剩余倒计时长:${Math.ceil(countdownMs / 1000)}秒`)
})
const loopSetTimeout = require('loop-setTimeout')
/**
* getCountdown 轮询获取剩余毫秒倒计时长
* @param {Number} durationMs 倒计时持续时间(毫秒)
* @param {Number} timeout 定时延时时间(毫秒)
* @param {Function} loopCallback
* @return {undefined}
*/
function getCountdown (durationMs, timeout = 1000, loopCallback) {
let startTime = Date.now()
const callback = timeoutId => {
let nowTime = Date.now()
durationMs = durationMs - (nowTime - startTime)
startTime = nowTime
try {
loopCallback && loopCallback(durationMs, timeoutId)
} catch(error) {
console.log(error)
}
if (durationMs <= 0) {
clearTimeout(timeoutId)
}
}
loopSetTimeout(callback, timeout)
}
export default getCountdown
FAQs
We found that get-countdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.