refactor: extract coerce and stressorToString into util.js

This commit is contained in:
c0dev0id
2026-07-06 21:09:36 +02:00
parent 1ad4b73c9a
commit 9a2e76ba4f
5 changed files with 19 additions and 19 deletions

13
static/util.js Normal file
View File

@@ -0,0 +1,13 @@
export function coerce(s) {
if (s === 'True' || s === 'Y' || s === 'on' || s === 'true') return true;
if (s === 'False' || s === 'N' || s === 'off' || s === 'false') return false;
if (s === '') return s;
const n = Number(s);
if (!isNaN(n)) return n;
return s;
}
export function stressorToString(s) {
if (!s?.groups?.length) return '';
return s.groups.map(g => g.join(',')).join(';');
}