2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-14 00:59:27 +09:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2021-09-30 01:44:22 +09:00
|
|
|
import { substring } from 'stringz';
|
|
|
|
|
|
|
|
export function truncate(input: string, size: number): string;
|
|
|
|
export function truncate(input: string | undefined, size: number): string | undefined;
|
|
|
|
export function truncate(input: string | undefined, size: number): string | undefined {
|
|
|
|
if (!input) {
|
|
|
|
return input;
|
|
|
|
} else {
|
|
|
|
return substring(input, 0, size);
|
|
|
|
}
|
|
|
|
}
|