mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* [comment audit] Shorten daemon, hook, and emulator comments [skip ci] * [comment audit] Shorten VM, conversation, SQLite, and theme-import comments [skip ci] * [comment audit] Tighten Git execution and source-control comment contracts [skip ci] * [comment audit] Clarify repository probes and maintenance comments [skip ci] * [comment audit] Shorten status, diff-cache, and checkout comments [skip ci] * [comment audit] Clarify worktree lifecycle and WSL routing comments [skip ci] * [comment audit] Shorten forge identity and review-refresh comments [skip ci] * [comment audit] Tighten hosted-review client comment contracts [skip ci] * [comment audit] Clarify GitLab compatibility and review comments [skip ci] * [comment audit] Tighten hook ownership and watchdog rationale [skip ci] * [comment audit] Condense host and integration compatibility comments [skip ci] * [comment audit] Clarify IPC authority and remote-routing rationale [skip ci] * [comment audit] Finalize file-import and containment comment cleanup * [comment audit] Fix stale Jira type imports blocking full CI --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
27 lines
797 B
TypeScript
27 lines
797 B
TypeScript
// Reject exponent notation: Number.isInteger also accepts values such as 1e10.
|
|
const STRICT_INT_RE = /^-?\d+$/
|
|
export const parseStrictInt = (v: string): number | null => {
|
|
if (!STRICT_INT_RE.test(v)) {
|
|
return null
|
|
}
|
|
const num = Number(v)
|
|
return Number.isFinite(num) ? num : null
|
|
}
|
|
|
|
// Average paired padding values to preserve total padding with Orca's symmetric per-axis setting.
|
|
export const parsePaddingValue = (v: string): number | null => {
|
|
const parts = v.split(',')
|
|
if (parts.length > 2) {
|
|
return null
|
|
}
|
|
const nums: number[] = []
|
|
for (const part of parts) {
|
|
const num = parseStrictInt(part.trim())
|
|
if (num === null || num < 0 || num > 512) {
|
|
return null
|
|
}
|
|
nums.push(num)
|
|
}
|
|
return nums.reduce((sum, num) => sum + num, 0) / nums.length
|
|
}
|