MCPcopy Index your code
hub / github.com/github/relative-time-element / update

Method update

src/relative-time-element.ts:112–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110
111 timer: ReturnType<typeof setTimeout> = -1 as unknown as ReturnType<typeof setTimeout>
112 update() {
113 clearTimeout(this.timer)
114 if (!this.elements.size) return
115
116 let nearestDistance = Infinity
117 this.updating = true
118 try {
119 for (const timeEl of this.elements) {
120 nearestDistance = Math.min(nearestDistance, getUnitFactor(timeEl))
121 timeEl.update()
122 }
123 } finally {
124 this.updating = false
125 }
126 this.time = Math.min(60 * 60 * 1000, nearestDistance)
127 this.timer = setTimeout(() => this.update(), this.time)
128 this.time += Date.now()
129 }
130})()
131
132export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFormatOptions {

Callers 1

observeMethod · 0.45

Calls 1

getUnitFactorFunction · 0.85

Tested by

no test coverage detected