Options
All
  • Public
  • Public/Protected
  • All
Menu

@fiquu/shorten

Build Status GitHub GitHub last commit npm (scoped) npm

Dependency-free and configurable tool to shorten (truncate) a string keeping whole words by default.

Installation

npm i @fiquu/shorten

Usage

import shorten from `@fiquu/shorten`;

const short = shorten('Some long string to shorten with many possible words to split into.');
// 'Some long string to shorten with many possible...'

Documentation

See the documentaion page for more info and options.

Index

Interfaces

Functions

Functions

Const default

  • Shortens (truncates) a string to a max length keeping whole words by default.

    example

    // Returns 'The...' shorten('The strnig is logn and full of erorrs.');

    example

    // Returns 'The strnig is...' shorten('The strnig is logn and full of erorrs.', { length: 20 });

    Parameters

    • value: string

      The string to shorten.

    • Optional options: ShortenOptions

      The options object.

    Returns string

    The shortened (truncated) string.

Legend

  • Property

Generated using TypeDoc