From 6e66a5aea60f149450ba84b31d60edaef0554777 Mon Sep 17 00:00:00 2001 From: yookue Date: Tue, 16 Apr 2024 17:33:51 +0800 Subject: [PATCH] Updates --- ArrayUtils.html | 4 +- ArrayUtils.js.html | 4 +- BooleanUtils.html | 6 +- BooleanUtils.js.html | 6 +- DateUtils.html | 4 +- DateUtils.js.html | 4 +- JsonUtils.html | 4 +- JsonUtils.js.html | 4 +- NumberUtils.html | 4 +- NumberUtils.js.html | 4 +- ObjectUtils.html | 4 +- ObjectUtils.js.html | 4 +- RandomUtils.html | 4 +- RandomUtils.js.html | 4 +- RegexUtils.html | 4 +- RegexUtils.js.html | 4 +- StringUtils.html | 681 +++++++++++++++++++++++++++++++++++++++---- StringUtils.js.html | 114 ++++++-- ThreadUtils.html | 4 +- ThreadUtils.js.html | 4 +- TreeUtils.html | 4 +- TreeUtils.js.html | 4 +- index.html | 4 +- 23 files changed, 763 insertions(+), 120 deletions(-) diff --git a/ArrayUtils.html b/ArrayUtils.html index 35ef5fa..7c5dbfd 100644 --- a/ArrayUtils.html +++ b/ArrayUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -2705,7 +2705,7 @@
Parameters:

diff --git a/ArrayUtils.js.html b/ArrayUtils.js.html index 066c1c8..641b6ba 100644 --- a/ArrayUtils.js.html +++ b/ArrayUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -347,7 +347,7 @@

ArrayUtils.js


diff --git a/BooleanUtils.html b/BooleanUtils.html index 8e1a406..48bd070 100644 --- a/BooleanUtils.html +++ b/BooleanUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -2713,7 +2713,7 @@

Example

-
BooleanUtils.toStringTF(true);    // "T"
+
BooleanUtils.toStringTF(true);    // 'T'
@@ -3317,7 +3317,7 @@
Returns:

diff --git a/BooleanUtils.js.html b/BooleanUtils.js.html index 638c4eb..5745e0f 100644 --- a/BooleanUtils.js.html +++ b/BooleanUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -373,7 +373,7 @@

BooleanUtils.js

* @return {string} the string value of 'T'/'F' from the boolean value * * @example - * BooleanUtils.toStringTF(true); // "T" + * BooleanUtils.toStringTF(true); // 'T' */ static toStringTF(value) { return this.toString(value, 'T', 'F', undefined); @@ -406,7 +406,7 @@

BooleanUtils.js


diff --git a/DateUtils.html b/DateUtils.html index 65cce66..9074d1f 100644 --- a/DateUtils.html +++ b/DateUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -4101,7 +4101,7 @@
Returns:

diff --git a/DateUtils.js.html b/DateUtils.js.html index 28e1f0b..53f7e6b 100644 --- a/DateUtils.js.html +++ b/DateUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -450,7 +450,7 @@

DateUtils.js


diff --git a/JsonUtils.html b/JsonUtils.html index 94c7f62..c02eabf 100644 --- a/JsonUtils.html +++ b/JsonUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -438,7 +438,7 @@
Returns:

diff --git a/JsonUtils.js.html b/JsonUtils.js.html index 56e5253..4a6b02b 100644 --- a/JsonUtils.js.html +++ b/JsonUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -149,7 +149,7 @@

JsonUtils.js


diff --git a/NumberUtils.html b/NumberUtils.html index ffdf042..ff3b31a 100644 --- a/NumberUtils.html +++ b/NumberUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -1253,7 +1253,7 @@
Returns:

diff --git a/NumberUtils.js.html b/NumberUtils.js.html index 70da3c4..baa044c 100644 --- a/NumberUtils.js.html +++ b/NumberUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -227,7 +227,7 @@

NumberUtils.js


diff --git a/ObjectUtils.html b/ObjectUtils.html index 143c1f2..30cb503 100644 --- a/ObjectUtils.html +++ b/ObjectUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -4298,7 +4298,7 @@
Returns:

diff --git a/ObjectUtils.js.html b/ObjectUtils.js.html index ca202b9..677c7ee 100644 --- a/ObjectUtils.js.html +++ b/ObjectUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -487,7 +487,7 @@

ObjectUtils.js


diff --git a/RandomUtils.html b/RandomUtils.html index f565348..fb27be4 100644 --- a/RandomUtils.html +++ b/RandomUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -1371,7 +1371,7 @@
Returns:

diff --git a/RandomUtils.js.html b/RandomUtils.js.html index 73ce7ca..084225b 100644 --- a/RandomUtils.js.html +++ b/RandomUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -229,7 +229,7 @@

RandomUtils.js


diff --git a/RegexUtils.html b/RegexUtils.html index 0b64398..22beb06 100644 --- a/RegexUtils.html +++ b/RegexUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -314,7 +314,7 @@
Returns:

diff --git a/RegexUtils.js.html b/RegexUtils.js.html index bc9cc40..0cf5bc9 100644 --- a/RegexUtils.js.html +++ b/RegexUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -110,7 +110,7 @@

RegexUtils.js


diff --git a/StringUtils.html b/StringUtils.html index b338d22..e8f4a98 100644 --- a/StringUtils.html +++ b/StringUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -113,7 +113,7 @@

Source:
@@ -439,7 +439,7 @@

Source:
@@ -928,7 +928,7 @@

Source:
@@ -1254,7 +1254,7 @@

Source:
@@ -4064,13 +4064,339 @@
Parameters:
- comparison + comparison + + + + + +string + + + + + + + + + + +

the target string to compare

+ + + + + + + + + + + + + + + + + + + + + +
Returns:
+ + +
+

whether the given strings are equal, case-insensitive

+
+ + + +
+
+ Type +
+
+ +boolean + + + +
+
+ + + + + + + + + + +

(static) filterIgnoreBlank(texts) → {Array.<string>}

+ + + + + + +
+ +
Description:
+
  • Returns the filtered array of the gaven strings, without blanks

+ + + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Example
+ +
StringUtils.filterIgnoreEmpty([null, undefined, ' ', 'foobar']);    //  ['foobar']
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
texts + + +Array.<string> + + + + +

the source string to inspect

+ + + + + + + + + + + + + + + + +
Returns:
+ + +
+

the filtered array of the gaven strings, without blanks

+
+ + + +
+
+ Type +
+
+ +Array.<string> + + + +
+
+ + + + + + + + + + +

(static) filterIgnoreEmpty(texts) → {Array.<string>}

+ + + + + + +
+ +
Description:
+
  • Returns the filtered array of the gaven strings, without empties

+ + + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Example
+ +
StringUtils.filterIgnoreEmpty([null, undefined, '', 'foobar']);    //  ['foobar']
+ + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4107,7 +4433,7 @@
Returns:
-

whether the given strings are equal, case-insensitive

+

the filtered array of the gaven strings, without empties

@@ -4118,7 +4444,7 @@
Returns:
-boolean +Array.<string> @@ -4150,7 +4476,7 @@

Source:
@@ -4357,7 +4683,7 @@

Source:
@@ -4571,7 +4897,7 @@

Source:
@@ -4758,7 +5084,7 @@

Source:
@@ -4916,7 +5242,7 @@

Source:
@@ -5103,7 +5429,7 @@

Source:
@@ -5290,7 +5616,7 @@

Source:
@@ -5477,7 +5803,7 @@

Source:
@@ -5664,7 +5990,7 @@

Source:
@@ -5827,7 +6153,7 @@

Source:
@@ -5990,7 +6316,7 @@

Source:
@@ -6153,7 +6479,7 @@

Source:
@@ -6316,7 +6642,7 @@

Source:
@@ -6530,7 +6856,7 @@

Source:
@@ -6717,7 +7043,7 @@

Source:
@@ -6904,7 +7230,7 @@

Source:
@@ -7094,7 +7420,7 @@

Source:
@@ -7284,7 +7610,7 @@

Source:
@@ -7458,7 +7784,7 @@

Source:
@@ -7632,7 +7958,7 @@

Source:
@@ -7822,7 +8148,7 @@

Source:
@@ -8012,7 +8338,7 @@

Source:
@@ -8186,7 +8512,7 @@

Source:
@@ -8360,7 +8686,7 @@

Source:
@@ -8574,7 +8900,7 @@

Source:
@@ -8788,7 +9114,7 @@

Source:
@@ -9002,7 +9328,7 @@

Source:
@@ -9200,6 +9526,263 @@
Returns:
+

(static) split(text, delimiter, max, trim) → {Array.<string>}

+ + + + + + +
+ +
Description:
+
  • Returns the split array of the given string by the given delimiter

+ + + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
Example
+ +
StringUtils.split('foo,bar');    // ['foo', 'bar']
StringUtils.split('hello | world | wonderful', '|', 2);    // ['hello', 'world']
+ + + + +
Parameters:
+ + +

NameTypeDescription
texts -string +Array.<string> @@ -4081,7 +4407,7 @@
Parameters:
-

the target string to compare

the source string to inspect

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
text + + +string + + + + + + +

the source string to inspect

delimiter + + +string + + + + + + + , + +

the delimiter to split strings, defaults to comma

max + + +number + + + + + + +

the max elements expected, negative means unlimited, defaults to -1

trim + + +boolean + + + + + + + true + +

whether trim each element before returning, defaults to true

+ + + + + + + + + + + + + + + + +
Returns:
+ + +
+

the split array of the given string by the given delimiter

+
+ + + +
+
+ Type +
+
+ +Array.<string> + + + +
+
+ + + + + + + + + +

(static) startsWith(text, prefix) → {boolean}

@@ -9216,7 +9799,7 @@

Source:
@@ -9403,7 +9986,7 @@

Source:
@@ -9590,7 +10173,7 @@

Source:
@@ -9777,7 +10360,7 @@

Source:
@@ -9964,7 +10547,7 @@

Source:
@@ -10151,7 +10734,7 @@

Source:
@@ -10338,7 +10921,7 @@

Source:
@@ -10525,7 +11108,7 @@

Source:
@@ -10712,7 +11295,7 @@

Source:
@@ -10902,7 +11485,7 @@

Source:
@@ -11092,7 +11675,7 @@

(
Source:
@@ -11278,7 +11861,7 @@
Returns:

- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.
diff --git a/StringUtils.js.html b/StringUtils.js.html index 4d761b1..5503d88 100644 --- a/StringUtils.js.html +++ b/StringUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -114,61 +114,61 @@

StringUtils.js

return !!texts && texts.length > 0 && texts.every(item => this.isNotEmpty(item)); } /** - * Returns whether any of the given texts is empty + * Returns whether all the given texts are blank * * @param {Array<string>} texts the texts to check * - * @return {boolean} whether any of the given texts is empty + * @return {boolean} whether all the given texts are blank * * @example - * StringUtils.anyEmpty([null, undefined]); // true - * StringUtils.anyEmpty(['foo', 'bar']); // false + * StringUtils.allBlank([null, undefined]); // true + * StringUtils.allBlank([null, 'true']); // false */ - static anyEmpty(texts) { - return !texts || texts.length === 0 || texts.some(item => this.isEmpty(item)); + static allBlank(texts) { + return !texts || texts.length === 0 || texts.every(item => this.isBlank(item)); } /** - * Returns whether any of the given texts is not empty + * Returns whether all the given texts are not blank * * @param {Array<string>} texts the texts to check * - * @return {boolean} whether any of the given texts is not empty + * @return {boolean} whether all the given texts are not blank * * @example - * StringUtils.anyNotEmpty([null, undefined]); // false - * StringUtils.anyNotEmpty([null, 'world']); // true + * StringUtils.allNotBlank([null, undefined]); // false + * StringUtils.allNotBlank([null, 'world']); // false + * StringUtils.allNotBlank(['foo', 'bar']); // true */ - static anyNotEmpty(texts) { - return !!texts && (texts === null || texts === void 0 ? void 0 : texts.length) > 0 && texts.some(item => this.isNotEmpty(item)); + static allNotBlank(texts) { + return !!texts && texts.length > 0 && texts.every(item => this.isNotBlank(item)); } /** - * Returns whether all the given texts are blank + * Returns whether any of the given texts is empty * * @param {Array<string>} texts the texts to check * - * @return {boolean} whether all the given texts are blank + * @return {boolean} whether any of the given texts is empty * * @example - * StringUtils.allBlank([null, undefined]); // true - * StringUtils.allBlank([null, 'true']); // false + * StringUtils.anyEmpty([null, undefined]); // true + * StringUtils.anyEmpty(['foo', 'bar']); // false */ - static allBlank(texts) { - return !texts || texts.length === 0 || texts.every(item => this.isBlank(item)); + static anyEmpty(texts) { + return !texts || texts.length === 0 || texts.some(item => this.isEmpty(item)); } /** - * Returns whether all the given texts are not blank + * Returns whether any of the given texts is not empty * * @param {Array<string>} texts the texts to check * - * @return {boolean} whether all the given texts are not blank + * @return {boolean} whether any of the given texts is not empty * * @example - * StringUtils.allNotBlank([null, undefined]); // false - * StringUtils.allNotBlank([null, 'world']); // false - * StringUtils.allNotBlank(['foo', 'bar']); // true + * StringUtils.anyNotEmpty([null, undefined]); // false + * StringUtils.anyNotEmpty([null, 'world']); // true */ - static allNotBlank(texts) { - return !!texts && texts.length > 0 && texts.every(item => this.isNotBlank(item)); + static anyNotEmpty(texts) { + return !!texts && (texts === null || texts === void 0 ? void 0 : texts.length) > 0 && texts.some(item => this.isNotEmpty(item)); } /** * Returns whether any of the given texts is blank @@ -448,6 +448,42 @@

StringUtils.js

} return comparisons.some(comparison => this.equalsIgnoreCase(text, comparison)); } + /** + * Returns the filtered array of the gaven strings, without empties + * + * @param {Array<string>} texts the source string to inspect + * + * @return {Array<string>} the filtered array of the gaven strings, without empties + * + * @example + * StringUtils.filterIgnoreEmpty([null, undefined, '', 'foobar']); // ['foobar'] + */ + static filterIgnoreEmpty(texts) { + if (!texts || texts.length === 0) { + return undefined; + } + const result = texts.filter(item => this.isNotEmpty(item)); + // @ts-ignore + return (!result || result.length === 0) ? undefined : result; + } + /** + * Returns the filtered array of the gaven strings, without blanks + * + * @param {Array<string>} texts the source string to inspect + * + * @return {Array<string>} the filtered array of the gaven strings, without blanks + * + * @example + * StringUtils.filterIgnoreEmpty([null, undefined, ' ', 'foobar']); // ['foobar'] + */ + static filterIgnoreBlank(texts) { + if (!texts || texts.length === 0) { + return undefined; + } + const result = texts.filter(item => this.isNotBlank(item)); + // @ts-ignore + return (!result || result.length === 0) ? undefined : result; + } /** * Returns the replaced string of the source string ("{}" placeholder) with the given parameters * @@ -981,6 +1017,30 @@

StringUtils.js

static replaceFirstIgnoreCase(text, search, replace) { return (this.isEmpty(text) || !search) ? text : text === null || text === void 0 ? void 0 : text.replace(new RegExp(search, 'i'), (replace !== null && replace !== void 0 ? replace : '')); } + /** + * Returns the split array of the given string by the given delimiter + * + * @param {string} text the source string to inspect + * @param {string} delimiter the delimiter to split strings, defaults to comma + * @param {number} max the max elements expected, negative means unlimited, defaults to -1 + * @param {boolean} trim whether trim each element before returning, defaults to true + * + * @return {Array<string>} the split array of the given string by the given delimiter + * + * @example + * StringUtils.split('foo,bar'); // ['foo', 'bar'] + * StringUtils.split('hello | world | wonderful', '|', 2); // ['hello', 'world'] + */ + static split(text, delimiter = ',', max = -1, trim = true) { + if (!text) { + return undefined; + } + const result = text.split(delimiter, max); + if (!result || result.length === 0) { + return undefined; + } + return !trim ? result : result.map(item => !item ? item : item.trim()); + } /** * Returns whether the given string starts with the prefix * @@ -1206,7 +1266,7 @@

StringUtils.js


- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.
diff --git a/ThreadUtils.html b/ThreadUtils.html index fba3095..6420a59 100644 --- a/ThreadUtils.html +++ b/ThreadUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -283,7 +283,7 @@
Returns:

- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.
diff --git a/ThreadUtils.js.html b/ThreadUtils.js.html index b0e806f..4e60275 100644 --- a/ThreadUtils.js.html +++ b/ThreadUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -112,7 +112,7 @@

ThreadUtils.js


- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.
diff --git a/TreeUtils.html b/TreeUtils.html index 885d38e..8c5ab39 100644 --- a/TreeUtils.html +++ b/TreeUtils.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -311,7 +311,7 @@
Parameters:

- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.
diff --git a/TreeUtils.js.html b/TreeUtils.js.html index 2bab502..d3b5f7b 100644 --- a/TreeUtils.js.html +++ b/TreeUtils.js.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -116,7 +116,7 @@

TreeUtils.js


- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.
diff --git a/index.html b/index.html index a080a85..558a4a5 100644 --- a/index.html +++ b/index.html @@ -43,7 +43,7 @@ -

Home

Github

Classes

+

Home

Github

Classes

@@ -123,7 +123,7 @@

Website


- Documentation generated by JSDoc 4.0.2 on Mon Apr 15 2024 20:06:27 GMT+0800 using the docdash theme. + Documentation generated by JSDoc 4.0.2 on Tue Apr 16 2024 20:39:44 GMT+0800 using the docdash theme.