Export
slugify and truncate as plain functions from a moduleExport plain functions. The module is already the namespace: import { slugify } from "./strings". Unused functions can be removed by bundlers, and there is nothing to construct.
"Turn it into a singleton with getInstance()" is tempting, but it adds global state and ceremony to code that has no state at all. Injecting it is only worth it when you need to swap the implementation, which pure string helpers never need.
Read more