mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-26 22:56:23 -04:00
Convert Utilities to TypeScript
This commit is contained in:
committed by
Mark McDowall
parent
76650af9fd
commit
d46f4b2154
@@ -1,11 +0,0 @@
|
||||
export default function getIndexOfFirstCharacter(items, character) {
|
||||
return items.findIndex((item) => {
|
||||
const firstCharacter = item.sortTitle.charAt(0);
|
||||
|
||||
if (character === '#') {
|
||||
return !isNaN(firstCharacter);
|
||||
}
|
||||
|
||||
return firstCharacter === character;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import Series from 'Series/Series';
|
||||
|
||||
const STARTS_WITH_NUMBER_REGEX = /^\d/;
|
||||
|
||||
export default function getIndexOfFirstCharacter(
|
||||
items: Series[],
|
||||
character: string
|
||||
) {
|
||||
return items.findIndex((item) => {
|
||||
const firstCharacter = item.sortTitle.charAt(0);
|
||||
|
||||
if (character === '#') {
|
||||
return STARTS_WITH_NUMBER_REGEX.test(firstCharacter);
|
||||
}
|
||||
|
||||
return firstCharacter === character;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user