cut-string
v1.0.2 string truncate ellipsis
cut-string
Cut a string if too long. Support CJK and emoji❤️.
Install
$ npm install cut-string
Usage
const cutString = require('cut-string')
cutString('ABCDEFG', 4)
//=> 'ABCD'
cutString('我在东北玩泥巴', 4)
//=> '我在'
cutString('👨👩👧😀❣️😸', 6)
//=> '👨👩👧😀❣️'
cutString('我在东北玩泥巴', 6, { ellipsis: true })
//=> '我在...'
cutString('👨👩👧😀❣️😸', 6, { emojiWidth: 3 })
//=> '👨👩👧😀'