1.0.0 • Published 6 months ago

kaigyo.js v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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
  1. Import

// CommonJS module mode
const { breakLine } = require("kaigyo.js");

OR

//  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)

NameTypeAttributesDescription
strstringrequiredThe target string

breakLine

:fondue::fondue::fondue:
breakLine(str, cpl, lc, lf) :arrow_right: string
Insert break line to a string.

NameTypeAttributesDescription
strstringrequiredThe target string
cplnumberrequiredWidth per line
lcnumberrequiredThe count of lines
lfstringoptionalThe symbol of line break Default is "\n"

License

This module is available under the MIT license.