Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/build/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'node:path'
import { root } from './root.ts'

export const threshold = 600_000
export const threshold = 620_000

export const instantiations = 200_000

Expand Down
3 changes: 3 additions & 0 deletions packages/chat-debug-view/src/parts/Clamp/Clamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const clamp = (value: number, minimum: number, maximum: number): number => {
return Math.max(minimum, Math.min(value, maximum))
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { clamp } from '../Clamp/Clamp.ts'
import { parseTimelineSeconds } from '../ParseTimelineSeconds/ParseTimelineSeconds.ts'
import { roundSeconds } from '../RoundSeconds/RoundSeconds.ts'

Expand All @@ -19,8 +20,10 @@ export const getNormalizedRange = (durationSeconds: number, startValue: string,
}
const rawStart = parsedStart ?? 0
const rawEnd = parsedEnd ?? durationSeconds
const normalizedStart = Math.max(0, Math.min(durationSeconds, Math.min(rawStart, rawEnd)))
const normalizedEnd = Math.max(0, Math.min(durationSeconds, Math.max(rawStart, rawEnd)))
const rangeStart = Math.min(rawStart, rawEnd)
const rangeEnd = Math.max(rawStart, rawEnd)
const normalizedStart = clamp(rangeStart, 0, durationSeconds)
const normalizedEnd = clamp(rangeEnd, 0, durationSeconds)
return {
endSeconds: roundSeconds(normalizedEnd),
hasSelection: true,
Expand Down
8 changes: 8 additions & 0 deletions packages/chat-debug-view/test/Clamp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from '@jest/globals'
import { clamp } from '../src/parts/Clamp/Clamp.ts'

test('clamp should keep values inside the given bounds', () => {
expect(clamp(5, 0, 10)).toBe(5)
expect(clamp(-1, 0, 10)).toBe(0)
expect(clamp(12, 0, 10)).toBe(10)
})
Loading