feat(project): init

This commit is contained in:
2026-02-03 18:05:47 +08:00
commit f37a119eff
188 changed files with 29246 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import { appendCapped } from "./cap"
describe("appendCapped", () => {
test("keeps all items when under max", () => {
expect(appendCapped([1, 2], [3], 10)).toEqual([1, 2, 3])
})
test("drops from head when exceeding max", () => {
expect(appendCapped([1, 2], [3, 4, 5], 3)).toEqual([3, 4, 5])
})
test("calls onDrop for dropped items", () => {
const dropped: number[] = []
const result = appendCapped([1, 2], [3, 4, 5], 3, (x) => dropped.push(x))
expect(result).toEqual([3, 4, 5])
expect(dropped).toEqual([1, 2])
})
})