New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

legal-ass

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legal-ass

Truncates text. Prevents embarassing word splices. Truncation + business rules = FUNcation!

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

Truncates text. Prevents embarassing word splices. Truncation + business rules = FUNcation!

Build Status

Installation

npm install legal-ass --save

Usage

LegalAss(phrase, options), where phrase is the string you'd like truncated and options is an object specifying the following:

KeyValueRequired?
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

Package last updated on 06 Oct 2014

Did you know?

Socket

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.

Install

Related posts