1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #2204 from OancaAndrei/syncplay-settings

This commit is contained in:
Bill Thornton 2021-09-06 12:29:26 -04:00 committed by GitHub
commit 6dffc58e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 407 additions and 18 deletions

View file

@ -0,0 +1,27 @@
/**
* Gets the value of a string as boolean.
* @param {string} name The value as a string.
* @param {boolean} defaultValue The default value if the string is invalid.
* @returns {boolean} The value.
*/
export function toBoolean(value, defaultValue = false) {
if (value !== 'true' && value !== 'false') {
return defaultValue;
} else {
return value !== 'false';
}
}
/**
* Gets the value of a string as float number.
* @param {string} value The value as a string.
* @param {number} defaultValue The default value if the string is invalid.
* @returns {number} The value.
*/
export function toFloat(value, defaultValue = 0) {
if (value === null || value === '' || isNaN(value)) {
return defaultValue;
} else {
return parseFloat(value);
}
}