Skip to content

starkwang/cut-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Cut a string if too long. Support CJK and emoji❤️.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published