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

gentle-path-truncate

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

gentle-path-truncate

A package which nicely truncates path strings.

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Gentle path truncate

This robust library is built to gently cut (truncate) path strings.

The function truncatePath(path, maxlen, [ellipsis]) accepts three arguments:

  • path - a string which is a path itself
  • maxlen - a maximum length of resulting string
  • ellipsis - an ellipsis which has a default value of ...

This function is removing parts of a path one at a time putting the ellipsis in instead. In case if even showing a single path item is over the maxlen it just results in something like this .../filename.js. In case a file name is too long to be shown it gets truncated too. In that case this: plugin/connect/modules/beans/filenameWhichIsSuperLongAndWayLongerThanItShouldBe.json will result into this .../filenameWhichI...ThanItShouldBe.json. This library also handles files without extention, files with multiple edxtentions (e.g. *.min.js and hidden files .gitignore).

Installation

npm i gentle-path-truncate

Usage

import truncatePath from 'gentle-path-truncate'

or in Common.js

const truncatePath = require('gentle-path-truncate')

Running tests

npm test

Publish

npm run build
npm version
npm publish

Keywords

FAQs

Package last updated on 08 Oct 2018

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