/ellipsisis

Pass a string and max number of characters, and receive string that ends with ellipsis. This function doesn't truncate a word, only at spaces.

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

ellipsisis

This is a simple function for truncating text. Pass a string and max number of characters, and receive a string that ends with ellipsis. This function doesn't cut off a word, only truncates at a space.

Installation

$ npm install ellipsisis

Usage

const ellipsisis = require('ellipsisis');
console.log(ellipsisis('Hello world\'s end is coming to an end!',12));
// Hello world ...
// Adds ... after a space

console.log(ellipsisis('Hello world\'s end is coming to an end!',12,'***'));
// Hello world***
// adds the third argument as the ellipsis