UNPKG

fast-string-truncated-width

Version:

A fast function for calculating where a string should be truncated, given an optional width limit and an ellipsis string.

23 lines (22 loc) 495 B
type TruncationOptions = { limit?: number; ellipsis?: string; ellipsisWidth?: number; }; type WidthOptions = { ansiWidth?: number; controlWidth?: number; tabWidth?: number; ambiguousWidth?: number; emojiWidth?: number; fullWidthWidth?: number; regularWidth?: number; wideWidth?: number; }; type Result = { width: number; index: number; truncated: boolean; ellipsed: boolean; }; export type { TruncationOptions, WidthOptions, Result };