https://github.com/zboris12/kaigyo.js
A little javascript module to make sentence of CJK characters more human-friendly by breaking line at appropriate position.
https://github.com/zboris12/kaigyo.js
Last synced: 12 months ago
JSON representation
A little javascript module to make sentence of CJK characters more human-friendly by breaking line at appropriate position.
- Host: GitHub
- URL: https://github.com/zboris12/kaigyo.js
- Owner: zboris12
- License: mit
- Created: 2023-11-17T12:14:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-17T12:41:30.000Z (over 2 years ago)
- Last Synced: 2025-06-24T23:11:13.211Z (12 months ago)
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kaigyo.js
A little javascript module to make sentence of CJK characters more human-friendly by breaking line at appropriate position.
## How to use
1. ### Install
```
npm install kaigyo.js
```
2. ### Import
```js
// CommonJS module mode
const { breakLine } = require("kaigyo.js");
```
OR
```js
// ES module mode
import { breakLine } from "kaigyo.js";
```
## Function Definitions
### calcWidth
:fondue::fondue::fondue:
calcWidth(str) :arrow_right: number
Calculate the width of a string.
(1 for CJK characters, 0.5 for others)
Name | Type | Attributes | Description
--- | --- | --- | ---
str | string | required | The target string
### breakLine
:fondue::fondue::fondue:
breakLine(str, cpl, lc, lf) :arrow_right: string
Insert break line to a string.
Name | Type | Attributes | Description
--- | --- | --- | ---
str | string | required | The target string
cpl | number | required | Width per line
lc | number | required | The count of lines
lf | string | optional | The symbol of line break
Default is "\n"
## License
This module is available under the
[MIT license](https://opensource.org/licenses/MIT).