cut-string

1.0.3 • Public • Published

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

/cut-string/

    Package Sidebar

    Install

    npm i cut-string

    Weekly Downloads

    10

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    12.8 kB

    Total Files

    7

    Last publish

    Collaborators

    • starkwang