This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
breakword with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Get index i.e. 0,1,2,... of the character where a word must be broken given it must be wrapped within a certain length of spaces.
npm install breakword
var Breakword = require ("breakword"); var word = "打破我的角色三"; var breakIndex = Breakword(word,3); console.log(breakIndex) //0
The result here - 0 - means all the characters before index 0 (in this case only the character 打) can fit in a line 3 spaces long.
npm --save run test
npm --display run test
npm run-script build