truncate-path

    1.0.1 • Public • Published

    Why

    Sometimes you need to display truncated paths in your application. This module does just that.

        let truncatePath = require('.');
        
        let file = '/home/mugz/projects/node/my-modules/test-module/node_modules/chokidar/types/index.d.ts';
        
        console.log(truncatePath(file));

    This outputs /home/mugz/projects/[..]/index.d.ts

    API

    truncatePath( file, [length] )

    The default length is 20 characters.

    Please note that the path generated is not always the length defined but the closest (complete) path that can be generated.

    By complete path, we mean that directory and file names are not split midway.

    As such "/this/that/those/file.ext" can never be "/this/that/th[...]/fi.ext" or something like that. Because that would be a very ugly path indeed!

    Enjoy!

    Install

    npm i truncate-path

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    4.09 kB

    Total Files

    4

    Last publish

    Collaborators

    • nguru