mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-04-29 02:37:27 +09:00
* update deps * lint fixes * fix * trace-redirectを削除 Co-Authored-By: あわわわとーにゅ <17376330+u1-liquid@users.noreply.github.com> * attempt to fix test * refactor * fix test --------- Co-authored-by: あわわわとーにゅ <17376330+u1-liquid@users.noreply.github.com>
17 lines
293 B
TypeScript
17 lines
293 B
TypeScript
import { nullOrEmpty } from './null-or-empty.js';
|
|
|
|
export function clip(s: string, max: number): string {
|
|
if (nullOrEmpty(s)) {
|
|
return s;
|
|
}
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
s = s.trim();
|
|
|
|
if (s.length > max) {
|
|
return s.substr(0, max) + '...';
|
|
} else {
|
|
return s;
|
|
}
|
|
}
|