14 lines
419 B
JavaScript
14 lines
419 B
JavaScript
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(';');
|
|
}
|