@types/ellipsize
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Installation

npm install --save @types/ellipsize

Summary

This package contains type definitions for ellipsize (https://github.com/mvhenten/ellipsize).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ellipsize.

index.d.ts

/**
 * Ellipsizes a string near a word boundary.
 *
 * An ellipsized text looks much better if the ellipsize was added at the end of
 * the last full word instead of somewhere in the middle - especially if there
 * are very few characters remaining.
 *
 * @example
 * ellipsize('one two three four', 8);
 * // 'one two…'
 *
 * ellipsize('one two three four', 100);
 * // 'one two three four'
 *
 * ellipsize('12345678910')
 * // '1234567…'
 *
 * ellipsize( 'one two&three four', 8, { chars: [' ', '&'], ellipse: '→' });
 * // 'one two→'
 *
 * // its default settings
 * ellipsize( '123456789ABCDEF', 8, { truncate: true });
 * // '1234567…'
 */
declare function ellipsize(
    /**
     * text to ellipsize.
     */
    text?: string,
    /**
     * maxLength of the text before it is ellipsized (default: 140)
     */
    maxLength?: number,
    /**
     * additional options to customize the result and rules
     */
    options?: {
        /**
         * after this char(s) the text can be ellipsized and the ellipse
         * rendered. (default: [' ', '-'])
         */
        chars?: string[] | undefined;
        /**
         * ellipse element (default: '...')
         */
        ellipse?: string | undefined;
        /**
         * truncate the text or not (default: true)
         */
        truncate?: boolean | undefined;
    },
): string;

export = ellipsize;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by Stefan Natter.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/ellipsize

Weekly Downloads

3,262

Version

0.1.3

License

MIT

Unpacked Size

5.31 kB

Total Files

5

Last publish

Collaborators

  • types