UNPKG

@types/ellipsize

Version:
74 lines (67 loc) 1.99 kB
# 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](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ellipsize/index.d.ts) ````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](https://github.com/natterstefan).