mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-09 22:02:19 +02:00
add folder browsing support (#315)
This commit is contained in:
@@ -8,3 +8,4 @@ export * from './rgb-to-rgba';
|
||||
export * from './sentence-case';
|
||||
export * from './set-local-storage-setttings';
|
||||
export * from './title-case';
|
||||
export * from './truncate-middle';
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
export const truncateMiddle = (text: string, maxLength: number): string => {
|
||||
if (text.length <= maxLength) {
|
||||
return text;
|
||||
}
|
||||
|
||||
const ellipsis = '…';
|
||||
const halfLength = Math.floor((maxLength - ellipsis.length) / 2);
|
||||
const start = text.substring(0, halfLength);
|
||||
const end = text.substring(text.length - halfLength);
|
||||
|
||||
return `${start}${ellipsis}${end}`;
|
||||
};
|
||||
Reference in New Issue
Block a user