zavadil-ts-common 1.2.67 → 1.2.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/util/ObjectUtil.d.ts +1 -1
- package/dist/util/StringUtil.d.ts +3 -3
- package/package.json +1 -1
- package/src/util/ObjectUtil.ts +1 -1
- package/src/util/StringUtil.ts +4 -6
@@ -1,12 +1,12 @@
|
|
1
1
|
export declare class StringUtil {
|
2
2
|
static toString(s: any): string;
|
3
|
-
static isEmpty(str: string | null | undefined):
|
3
|
+
static isEmpty(str: string | null | undefined): str is null | undefined;
|
4
4
|
static notEmpty(str: string | null | undefined): str is string;
|
5
|
-
static isBlank(str: string | null | undefined):
|
5
|
+
static isBlank(str: string | null | undefined): str is null | undefined | "";
|
6
6
|
static notBlank(str: string | null | undefined): str is string;
|
7
7
|
static substr(str: string | null | undefined, start: number, length?: number): string;
|
8
8
|
static replace(str: string | null | undefined, find?: null | string, replace?: string): string;
|
9
|
-
static containsLineBreaks(str: string | null | undefined):
|
9
|
+
static containsLineBreaks(str: string | null | undefined): str is string;
|
10
10
|
static trimLeadingSlashes(str: string | null): string;
|
11
11
|
static trimTrailingSlashes(str: string | null): string;
|
12
12
|
static trimSlashes(str: string | null): string;
|
package/package.json
CHANGED
package/src/util/ObjectUtil.ts
CHANGED
package/src/util/StringUtil.ts
CHANGED
@@ -4,7 +4,7 @@ export class StringUtil {
|
|
4
4
|
return typeof s === 'string' ? s : s?.toString?.() ?? '';
|
5
5
|
}
|
6
6
|
|
7
|
-
static isEmpty(str: string | null | undefined):
|
7
|
+
static isEmpty(str: string | null | undefined): str is null | undefined {
|
8
8
|
if (typeof str !== 'string') return StringUtil.isEmpty(StringUtil.toString(str));
|
9
9
|
return str.length === 0;
|
10
10
|
}
|
@@ -13,7 +13,7 @@ export class StringUtil {
|
|
13
13
|
return !StringUtil.isEmpty(str);
|
14
14
|
}
|
15
15
|
|
16
|
-
static isBlank(str: string | null | undefined):
|
16
|
+
static isBlank(str: string | null | undefined): str is null | undefined | "" {
|
17
17
|
return StringUtil.isEmpty(StringUtil.safeTrim(str));
|
18
18
|
}
|
19
19
|
|
@@ -30,13 +30,11 @@ export class StringUtil {
|
|
30
30
|
|
31
31
|
static replace(str: string | null | undefined, find?: null | string, replace?: string): string {
|
32
32
|
if (this.isEmpty(str) || this.isEmpty(find)) return '';
|
33
|
-
|
34
|
-
// @ts-ignore
|
35
33
|
return str.replace(find, String(replace));
|
36
34
|
}
|
37
35
|
|
38
|
-
static containsLineBreaks(str: string | null | undefined):
|
39
|
-
if (
|
36
|
+
static containsLineBreaks(str: string | null | undefined): str is string {
|
37
|
+
if (StringUtil.isBlank(str)) return false;
|
40
38
|
return str.includes("\n");
|
41
39
|
}
|
42
40
|
|