1.0.29 • Published 10 months ago

cjke-strings v1.0.29

Weekly downloads
3
License
MIT
Repository
github
Last release
10 months ago

string-width is active maintenance again! Use that package instead.
This package will mark as deprecated soon.

CJKE strings module

Tools for Chinese Japanese Korean Emoji string

The code is come from:

  • Write by myself
  • Codebase is copied from sindresorhus/string-width
  • Learn about emojis from tonytonyjan/string-width
  • Unicode tables copied from many wiki pages

Mostly you also need a module called stringz

describe('typescript', () => {
	it('is really great', () => {
		should(cleverMan).to.be('using it');
	});
});

APIs

  • isCombiningCharacters - detect a character is in Combining Characters table
  • readFirstCompleteChar - get first complete character at beginning of given string, prevent ￿ or ?
  • unicodeEscape - escape string as "\uxxxx\uxxxx\uxxxx" form
  • limitWidth - cut a limited display width of a string
  • stringWidth - calculate display width of a string

readFirstCompleteChar(str: string, windowsConsole = false): CodePointInfo

vardesc
strany string
windowsConsoleis used for windows console or not

CodePointInfo

vartypedesc
datastringfirst complete char
widthnumberdisplay width of that char
lengthnumberstring length of that char
visiblebooleanshould the char visible?

function limitWidth(str: string, limit: number, windowsConsole = false): LimitResult

vardesc
strany string
limittarget display width to cut
windowsConsoleis used for windows console or not

LimitResult

vartypedesc
resultstringcut result
widthnumberreal display width of result

function stringWidth(str: string, windowsConsole = false): number

vardesc
strany string
windowsConsoleis used for windows console or not
{return}the display width of str

function isCombiningCharacters(code: number): boolean

vardesc
codereturn value of 'string'.charCodeAt()
{return}is in combine char list

function unicodeEscape(str: string): string

vardesc
strany string
{return}escaped string

Windows console

Windows Console (the black window) is not fully support unicode, so there is some workaround. Default is false.

chardefaultwhen true
12
😂̀23
À̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀̀125
22
👍🏽24(👍+🏽)
1.0.29

10 months ago

1.0.28

10 months ago

1.0.27

10 months ago

1.0.26

10 months ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.19

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.23

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago