diff --git a/src/lib/util.js b/src/lib/util.js index 6b5c2a7..b885e21 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -29,3 +29,12 @@ export function gotoNamedId(id, name) { const page = getNamedId(id, name); goto(page, { replaceState: true }); } + +/** + * @param {string | null | undefined} string + * @returns {number | null} + */ +export function parseIntNull(string) { + const r = string ? parseInt(string) : null; + return Number.isNaN(r) ? null : r; +}