Utilities for transforming and formatting text (i.e. strings).
npm install @acusti/textual
# or
yarn add @acusti/textual
Import the utilities by name. The package only has named exports, making it maximally tree-shakeable:
import { capitalize, getInitials } from '@acusti/textual';
The exported utilities are:
returns input text with equivalent formatting to the
text-transform: capitalize;
CSS property
returns uppercase initials from the input string, e.g.
getInitials('franklin delano Roosevelt') // => 'FDR'
returns a formatted name from an email address, treating .
and +
as
space separators, e.g.
getNameFromEmail('franklin.delano+roosevelt@gmail.com') // => 'Franklin Delano Roosevelt'