0.0.4 • Published 6 years ago

gentle-path-truncate v0.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

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
0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.0.0

6 years ago