Add: Optional parseInt (parseIntNull)
This commit is contained in:
parent
33aa98e456
commit
d8b25b59dc
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user