shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
crop
Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.string
Allows you to crop a string at a certain length (this length take care of the croping characters like ”…”)
Params
- text*-String
The text to crop
- length*-Number
The text length to have after the croping process
- settings{}Object
An object of settings described bellow:
Return
- -String
The cropped text
Example
import { crop } from '@blackbyte/sugar/string';
crop('Hello World', 10); // => Hello w...Settings
- chars…String
The characters to use to signal the crop
- splitWordsfalseBoolean
Specify if you want to split words or not. If not, the function will make sure the final text does not exceeds the wanted length
Todo
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space