1- # LiteRT/Utils- String
1+ # LiteRT/Utils - String
22
33[ ![ Strict TypeScript Checked] ( https://badgen.net/badge/TS/Strict " Strict TypeScript Checked ")] ( https://www.typescriptlang.org )
44[ ![ npm version] ( https://img.shields.io/npm/v/@litert/utils-string.svg?colorB=brightgreen )] ( https://www.npmjs.com/package/@litert/utils-string " Stable Version ")
77[ ![ GitHub issues] ( https://img.shields.io/github/issues/litert/utils.js.svg )] ( https://github.com/litert/utils.js/issues )
88[ ![ GitHub Releases] ( https://img.shields.io/github/release/litert/utils.js.svg )] ( https://github.com/litert/utils.js/releases " Stable Release ")
99
10- The string utility functions/classes/constants for JavaScript/TypeScript.
10+ The utility functions/classes/constants about string for JavaScript/TypeScript.
1111
1212## Requirement
1313
@@ -19,91 +19,6 @@ The string utility functions/classes/constants for JavaScript/TypeScript.
1919``` sh
2020npm i @litert/utils-string --save
2121```
22- ## Features
23-
24- ### Classes
25-
26- - ` class UnitParser `
27-
28- A helper class for extracting the value and the unit from a string, by the given format.
29-
30- ### Functions
31-
32- - ` function includeEvilSpaceChars(str: string): boolean; `
33-
34- Check if the string contains some evil space characters, including:
35-
36- - Unicode ` \u0000-\u0008 `
37- - Unicode ` \u000B-\u000C `
38- - Unicode ` \u000E-\u001F `
39- - Unicode ` \u0080-\u00A0 `
40- - Unicode ` \u2000-\u200F `
41-
42- - ` function replaceEvilSpaceChars(str: string, to: string = ''): string; `
43-
44- Replace the evil space characters in the string.
45-
46- - ` function htmlEscape(text: string, extraReplacement?: Array<[from: string, to: string]>): string; `
47-
48- Escape the HTML special characters in the string.
49-
50- The built-in replacements are:
51-
52- - ` & ` to ` & `
53- - ` < ` to ` < `
54- - ` > ` to ` > `
55- - ` " ` to ` " `
56- - ` ' ` to ` ' `
57-
58- Some extra replacements can be passed in the ` extraReplacement ` parameter.
59-
60- - ` function splitIntoLines(text: string, eol: string | RegExp = /\r\n|\r|\n/): string[]; `
61-
62- Split the string into lines.
63-
64- The default EOL is ` /\r\n|\r|\n/ ` , but you can pass in a custom EOL string or a regular expression.
65-
66- - ` function toUnixString(text: string): string; `
67-
68- Convert the string to a Unix-style string, using ` \n ` as the EOL.
69-
70- - ` function toWindowsString(text: string): string; `
71-
72- Convert the string to a Windows-style (DOS-style) string, using ` \r\n ` as the EOL.
73-
74- - ` function toMacString(text: string): string; `
75-
76- Convert the string to a MacOS-style string, using ` \r ` as the EOL.
77-
78- - ` function random(length: number, charset: string = DEFAULT_RANDOM_CHARSET): string; `
79-
80- Generate a random string with the specified length and charset.
81-
82- The default charset is ` 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ` .
83-
84- - ` function regexpEscape(str: string): string; `
85-
86- Escape a string for use in a regular expression, all below characters will be escaped.
87-
88- ` [.*+?^${}()|[\]/\\] `
89-
90- ### Constants
91-
92- - ` const DEFAULT_RANDOM_CHARSET: string; `
93-
94- The default charset for the ` random ` function.
95-
96- - ` enum ERandomStringCharset `
97-
98- The enum for the charset of the ` random ` function.
99-
100- - ` UPPER_ALPHA ` : ` ABCDEFGHIJKLMNOPQRSTUVWXYZ `
101- - ` LOWER_ALPHA ` : ` abcdefghijklmnopqrstuvwxyz `
102- - ` DEC_DIGIT ` : ` 0123456789 `
103- - ` UPPER_HEX_DIGIT ` : ` 0123456789ABCDEF `
104- - ` LOWER_HEX_DIGIT ` : ` 0123456789abcdef `
105-
106- > You can combine the charset by concatenating them as a string, e.g. ` ERandomStringCharset.UPPER_ALPHA + ERandomStringCharset.LOWER_ALPHA ` .
10722
10823## License
10924
0 commit comments