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

  1. text*-String

    The text to crop

  2. length*-Number

    The text length to have after the croping process

  3. settings{}Object

    An object of settings described bellow:

Return

  1. -String

    The cropped text

Example

import { crop } from '@blackbyte/sugar/string';
crop('Hello World', 10); // => Hello w...

Settings

  1. charsString

    The characters to use to signal the crop

  2. 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