rudeshark.net/packages/backend/src/misc/truncate.ts

18 lines
368 B
TypeScript
Raw Normal View History

2023-01-13 05:40:33 +01:00
import { substring } from "stringz";
export function truncate(input: string, size: number): string;
2023-01-13 05:40:33 +01:00
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);
}
}