Improve i18n.

This commit is contained in:
Yang Luo
2021-05-24 20:48:04 +08:00
parent 2fff5f79ce
commit b23e8cf90c
5 changed files with 24 additions and 26 deletions

View File

@ -112,6 +112,23 @@ export function swapRow(array, i, j) {
return [...array.slice(0, i), array[j], ...array.slice(i + 1, j), array[i], ...array.slice(j + 1)];
}
export function trim(str, ch) {
if (str === undefined) {
return undefined;
}
let start = 0;
let end = str.length;
while(start < end && str[start] === ch)
++start;
while(end > start && str[end - 1] === ch)
--end;
return (start > 0 || end < str.length) ? str.substring(start, end) : str;
}
export function isMobile() {
// return getIsMobileView();
return isMobileDevice;