
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Truncates text. Prevents embarassing word splices. Truncation + business rules = FUNcation!

Truncates text. Prevents embarassing word splices. Truncation + business rules = FUNcation!
npm install legal-ass --save
LegalAss(phrase, options), where phrase is the string you'd like truncated and options is an object specifying the following:
| Key | Value | Required? |
|---|---|---|
| length | (Integer) The maximum number of characters in the truncated return string, including any ellipses string that follows. | Yes |
| splitWords | (Boolean) Should the library truncate in the middle of a word? Defaults to false, meaning that the return string may be shorter than length if that's necessary to split between words. | No |
| ellipses | (String) A string to append to the end of the truncated text. Its length will be factored in to where a string truncates. Defaults to a single-character ellipses (…). | No |
var LegalAss = require('legal-ass');
LegalAss('So this is a story all about how', {length: 22});
// -> 'So this is a story…'
Note that the returned string is only 19 characters long, since a longer string would have split in the middle of the word "all". If you don't care about this, pass {splitWords: true}:
LegalAss('So this is a story all about how', {length: 22, splitWords: true});
// -> 'So this is a story al…'
If you'd like to use your own string instead of ellipses, pass that as ellipses:
LegalAss('So this is a story all about how', {length: 22, ellipses: ' (More >)'});
// -> 'So this is a (More >)'
Note that the original phrase above was truncated with a trailing space and the library made the end result an additional character shorter by eliminating it.
FAQs
Truncates text. Prevents embarassing word splices. Truncation + business rules = FUNcation!
We found that legal-ass demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.