Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.truncate

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.truncate

The lodash method `_.truncate` exported as a module.

  • 4.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.6M
decreased by-29.74%
Maintainers
3
Weekly downloads
 
Created

What is lodash.truncate?

The lodash.truncate package is a utility module provided by lodash, a popular JavaScript library, that allows for truncating a string if it is longer than the given maximum string length. It provides options to customize the truncation, such as setting the length, omission string, and where to split the string.

What are lodash.truncate's main functionalities?

Basic truncation

Truncates the string to a specified length. In this example, the string 'Hello world' is truncated to 'Hello...'.

_.truncate('Hello world', { length: 5 });

Custom omission

Allows customization of the omission string that indicates text has been omitted. Here, 'Hello world' is truncated to 'Hello w---'.

_.truncate('Hello world', { length: 8, omission: '---' });

Custom separator

Truncates at the nearest character that matches the separator without breaking the word. In this case, 'Hello world' is truncated to 'Hello...'.

_.truncate('Hello world', { length: 8, separator: ' ' });

Other packages similar to lodash.truncate

Keywords

FAQs

Package last updated on 13 Aug 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc