Naivete Precedes Misrepresentation

    @konforti/truncate

    1.0.1 • Public • Published

    ✂️ Truncate long texts by number of lines

    Features

    • Truncate text by number of lines.
    • Truncate form end, start or middle.
    • Custom ellipsis.

    🔧 Installation

    npm i -S @konforti/truncate
    yarn add @konforti/truncate

    ✏️ Usage

    import truncate from '@konforti/truncate';
    
    const res = truncate(
        longTextWrapper,
        longText, // default "".
        lines, // default 1.
        truncFrom, // default "end".
        ellipsis, // default "...".
        wrapperOffset // default 5
    );

    🔖 Types Definition

    function truncate(
        longTextWrapper: HTMLElement,
        longText: string
        lines: number
        truncFrom: 'start' | 'middle' | 'end'
        ellipsis:  string
        wrapperOffset:  number
    ): {text: string, truncated: boolean} {}

    Install

    npm i @konforti/truncate

    DownloadsWeekly Downloads

    169

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    68.4 kB

    Total Files

    11

    Last publish

    Collaborators

    • konforti