mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Move string utils and migrate to typescript
This commit is contained in:
parent
5b016bafad
commit
a238ae21f1
3 changed files with 5 additions and 5 deletions
|
@ -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';
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue