Skip to content
Break string into lines according to visual width.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
example
test
.coveralls.yml
.editorconfig
.gitignore
LICENSE
README.md
azure-pipelines.yml
index.js
package-lock.json
package.json

README.md

String-Break

NPM version Build status Coverage status npm download

String-Break 是命令行字符串格式化工具,可以方便的将长字符串按照宽度分段。

特点:

  • 支持中文,英文,中英文混排
  • 英文不会被截断
  • 标点不会出现在行首

Install

npm install string-break --save

Usage

const stringBreak = require('string-break');
const str = '远处海港传来阵阵船笛 我一直飘零到被你拣起 如今望著反映窗户玻璃 有个我陌生又熟悉';

let lines = stringBreak(str, 30);
/**
 * lines: [ 
 *   '远处海港传来阵阵船笛 我一直飘',
 *   '零到被你拣起 如今望著反映窗户',
 *   '玻璃 有个我陌生又熟悉'
 * ]
 */

License

MIT.

You can’t perform that action at this time.