svg-text
Version:
Utilities for working with SVG, including SvgText for multiline text.
28 lines (24 loc) • 548 B
JavaScript
const ELLIPSIS = '…';
/**
* Translates a text-overflow code into a corresponding string.
* @returns {string}
*/
export function textOverflow(code) {
if (code === 'clip') {
return '';
} else if (code === 'ellipsis') {
return ELLIPSIS;
} else if (typeof code === 'string') {
return code;
}
return '';
}
/**
* Returns true if a @param char can be used as a break between words.
*/
export function isWordBound(char) {
return /[\s-–—]/.test(char);
}
export function isHyphen(char) {
return /[-–]/.test(char);
}