1.0.3 • Published 7 years ago

cut-string v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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 })
//=> '👨‍👩‍👧😀'