Skill update round trip / roundtrip (false, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, latest) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
39 lines
873 B
JavaScript
39 lines
873 B
JavaScript
export class BoundedLiveFreezeHistory {
|
|
#entries = []
|
|
#limit
|
|
#nextIndex = 0
|
|
#totalCount = 0
|
|
|
|
constructor(limit) {
|
|
if (!Number.isInteger(limit) || limit <= 0) {
|
|
throw new Error(`History limit must be a positive integer, got ${limit}`)
|
|
}
|
|
this.#limit = limit
|
|
}
|
|
|
|
add(entry) {
|
|
this.#totalCount += 1
|
|
if (this.#entries.length < this.#limit) {
|
|
this.#entries.push(entry)
|
|
return
|
|
}
|
|
this.#entries[this.#nextIndex] = entry
|
|
this.#nextIndex = (this.#nextIndex + 1) % this.#limit
|
|
}
|
|
|
|
get retainedCount() {
|
|
return this.#entries.length
|
|
}
|
|
|
|
get totalCount() {
|
|
return this.#totalCount
|
|
}
|
|
|
|
values() {
|
|
if (this.#entries.length < this.#limit || this.#nextIndex === 0) {
|
|
return [...this.#entries]
|
|
}
|
|
return [...this.#entries.slice(this.#nextIndex), ...this.#entries.slice(0, this.#nextIndex)]
|
|
}
|
|
}
|