summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/truncate.ts
blob: b65202fbd4dc0c0c992f6594c6176521ceab08de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * SPDX-FileCopyrightText: syuilo and other misskey contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

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);
	}
}