diff --git a/src/components/syncPlay/core/PlaybackCore.js b/src/components/syncPlay/core/PlaybackCore.js index a47872e9c..91eb71c09 100644 --- a/src/components/syncPlay/core/PlaybackCore.js +++ b/src/components/syncPlay/core/PlaybackCore.js @@ -5,7 +5,7 @@ import { Events } from 'jellyfin-apiclient'; import browser from '../../../scripts/browser'; -import { toBoolean, toFloat } from '../../../scripts/stringUtils'; +import { toBoolean, toFloat } from '../../../utils/string.ts'; import * as Helper from './Helper'; import { getSetting } from './Settings'; diff --git a/src/components/syncPlay/core/timeSync/TimeSyncCore.js b/src/components/syncPlay/core/timeSync/TimeSyncCore.js index 772121dac..cf9d6f09d 100644 --- a/src/components/syncPlay/core/timeSync/TimeSyncCore.js +++ b/src/components/syncPlay/core/timeSync/TimeSyncCore.js @@ -5,7 +5,7 @@ import { Events } from 'jellyfin-apiclient'; import appSettings from '../../../../scripts/settings/appSettings'; -import { toFloat } from '../../../../scripts/stringUtils'; +import { toFloat } from '../../../../utils/string.ts'; import { getSetting } from '../Settings'; import TimeSyncServer from './TimeSyncServer'; diff --git a/src/scripts/stringUtils.js b/src/utils/string.ts similarity index 75% rename from src/scripts/stringUtils.js rename to src/utils/string.ts index 0fcb8a289..301f4c44a 100644 --- a/src/scripts/stringUtils.js +++ b/src/utils/string.ts @@ -4,7 +4,7 @@ * @param {boolean} defaultValue The default value if the string is invalid. * @returns {boolean} The value. */ -export function toBoolean(value, defaultValue = false) { +export function toBoolean(value: string | undefined | null, defaultValue = false) { if (value !== 'true' && value !== 'false') { return defaultValue; } else { @@ -18,8 +18,8 @@ export function toBoolean(value, defaultValue = false) { * @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)) { +export function toFloat(value: string | null | undefined, defaultValue = 0) { + if (!value || isNaN(value as never)) { return defaultValue; } else { return parseFloat(value);