1.0.18 • Published 6 years ago

str_shorten v1.0.18

Weekly downloads
214
License
MIT
Repository
github
Last release
6 years ago

str_shorten

Build Status bitHound Score Coverage Status bitHound Code npm version Downloads

Shorten string by character length with word boundary supported

NPM

Install the module with:

npm install --save str_shorten

Yarn

Install the module with:

yarn add str_shorten

Usage

str_shorten(string, maxChars, options)

Options

namedefaultrequiredtypedescription
wordBoundarytruefalsebooleanIndicate whether using word boundary or not.
endSymbols'...'falsestringSymbols indicate there is more text.

Example

Basic

var strShorten = require("str_shorten")
var str = "We will win if we want";
var shortenStr = strShorten(str, 11);

The return value will be "We will win..."

Customize end symbols

var strShorten = require("str_shorten")
var str = "We will win if we want";
var shortenStr = strShorten(str, 11, {endSymbols: ' -->'});

The return value will be "We will win -->"

Without end symbols

var strShorten = require("str_shorten")
var str = "We will win if we want";
var shortenStr = strShorten(str, 11, {endSymbols: ''});

The return value will be "We will win"

See Demo

License

Copyright (c) 2018 Binh Quan

Licensed under the MIT license.

1.0.18

6 years ago

1.0.17

6 years ago

1.0.15

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

1.0.0

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago