zavadil-ts-common 1.2.75 → 1.2.76

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.
@@ -16,6 +16,7 @@ export declare class StringUtil {
16
16
  static safeTrim(str: string | null | undefined): string;
17
17
  static safeLowercase(str: string | null | undefined): string;
18
18
  static safeUppercase(str: string | null | undefined): string;
19
+ static capitalizeFirstLetter(str: string | null | undefined): string;
19
20
  static toBigInt(str: string | null): bigint | null;
20
21
  static getNonEmpty(...args: Array<string | null | undefined>): string;
21
22
  static getNonBlank(...args: Array<string | null | undefined>): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zavadil-ts-common",
3
- "version": "1.2.75",
3
+ "version": "1.2.76",
4
4
  "description": "Common types and components for Typescript UI apps.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -4,7 +4,7 @@ import {StringUtil} from "./StringUtil";
4
4
  export class OAuthUtil {
5
5
 
6
6
  static isValidToken(token?: TokenResponsePayloadBase | null): boolean {
7
- return token !== undefined && token !== null && StringUtil.notEmpty(token.token) && !OAuthUtil.isTokenExpired(token);
7
+ return token !== undefined && token !== null && StringUtil.notBlank(token.token) && !OAuthUtil.isTokenExpired(token);
8
8
  }
9
9
 
10
10
  static isTokenExpired(token?: TokenResponsePayloadBase | null): boolean {
@@ -85,6 +85,11 @@ export class StringUtil {
85
85
  return StringUtil.toString(str).toUpperCase();
86
86
  }
87
87
 
88
+ static capitalizeFirstLetter(str: string | null | undefined): string {
89
+ if (StringUtil.isBlank(str)) return '';
90
+ return StringUtil.safeUppercase(str.charAt(0)) + StringUtil.safeLowercase(StringUtil.substr(str, 1));
91
+ }
92
+
88
93
  static toBigInt(str: string | null): bigint | null {
89
94
  if (this.isEmpty(str)) return null;
90
95
 
@@ -1,6 +1,4 @@
1
- import { StringUtil } from '../src/util/StringUtil';
2
- import {JsonUtil} from "../src/util/JsonUtil";
3
- import {RestClient} from "../src";
1
+ import { StringUtil, JsonUtil, RestClient } from '../src';
4
2
 
5
3
  describe('testing StringUtil', () => {
6
4
  test('isEmpty', () => {
@@ -23,6 +21,13 @@ describe('testing StringUtil', () => {
23
21
  expect(StringUtil.getNonEmpty('', null, undefined, 'test')).toBe('test');
24
22
  expect(StringUtil.getNonEmpty('', 'test', undefined, 'test2')).toBe('test');
25
23
  });
24
+ test('capitalizeFirstLetter', () => {
25
+ expect(StringUtil.capitalizeFirstLetter('test')).toBe('Test');
26
+ expect(StringUtil.capitalizeFirstLetter('TesT')).toBe('Test');
27
+ expect(StringUtil.capitalizeFirstLetter('')).toBe('');
28
+ expect(StringUtil.capitalizeFirstLetter(null)).toBe('');
29
+
30
+ });
26
31
  });
27
32
 
28
33
  describe('testing JsonUtil', () => {