MCPcopy Create free account
hub / github.com/porsager/postgres / timer

Function timer

cf/src/connection.js:1044–1064  ·  view source on GitHub ↗
(fn, seconds)

Source from the content-addressed store, hash-verified

1042}
1043
1044function timer(fn, seconds) {
1045 seconds = typeof seconds === 'function' ? seconds() : seconds
1046 if (!seconds)
1047 return { cancel: noop, start: noop }
1048
1049 let timer
1050 return {
1051 cancel() {
1052 timer && (clearTimeout(timer), timer = null)
1053 },
1054 start() {
1055 timer && clearTimeout(timer)
1056 timer = setTimeout(done, seconds * 1000, arguments)
1057 }
1058 }
1059
1060 function done(args) {
1061 fn.apply(null, args)
1062 timer = null
1063 }
1064}

Callers 1

ConnectionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected