JSPM

cut-string

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q38289F
  • License MIT

Cut a string if too long. Support CJK(漢字) and emoji❤️.

Package Exports

  • cut-string

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cut-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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