nmce-func 0.0.6 → 0.0.7

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.
@@ -63,7 +63,7 @@ export declare class DateFunc {
63
63
  static getHour(dtUtc: Date | null | undefined | number): number;
64
64
  static getMinute(dtUtc: Date | null | undefined | number): number;
65
65
  static composeDateTime(dt: Date | null | undefined, h?: number, minute?: number): Date;
66
- static olderThan24Hours(d: Date): boolean;
66
+ static olderThan24Hours(d: Date | null | undefined): boolean;
67
67
  static olderThan24HoursUtc(dtUtc: Date | null | undefined): boolean;
68
68
  static olderThanHours(d: Date, hours: number): boolean;
69
69
  static olderThanHoursUtc(dtUtc: Date | null | undefined, hours: number): boolean;
@@ -79,7 +79,17 @@ export declare class DateFunc {
79
79
  * @param dtUtc
80
80
  */
81
81
  static getDayAgeUtc(dtUtc: Date | null | undefined): number;
82
+ /**
83
+ * How many years from now.
84
+ * @param d
85
+ * @returns
86
+ */
82
87
  static getAge(d: Date): number;
88
+ /**
89
+ * Year of date.
90
+ * @param d
91
+ * @returns
92
+ */
83
93
  static getYear(d: Date): number;
84
94
  static getUtcNow(): Date;
85
95
  static addMinutes(d: Date, m: number): Date;
@@ -0,0 +1,18 @@
1
+ export declare class HtmlPrintFunc {
2
+ /**
3
+ * Print with CSS for internal reports
4
+ * @param htmlTags
5
+ * @param cssUrl
6
+ */
7
+ static printWithCSS(htmlTags: string, cssUrl: string): boolean;
8
+ /**
9
+ * Print for external documents.
10
+ * @param htmlTags
11
+ */
12
+ static print(htmlTags: string): boolean;
13
+ /**
14
+ * Print image url through html img.
15
+ * @param url
16
+ */
17
+ static printImage(url: string): void;
18
+ }
package/_func/index.d.ts CHANGED
@@ -2,7 +2,9 @@ export * from './addressFunc';
2
2
  export * from './authentication.service';
3
3
  export * from './currencyFunc';
4
4
  export * from './dateFunc';
5
- export * from './helperFunc';
6
- export * from './htmlFunc';
7
- export * from './jsFunc';
5
+ export * from './htmlPrintFunc';
6
+ export * from './javascriptFunc';
7
+ export * from './jsonFunc';
8
+ export * from './stringAusFunc';
8
9
  export * from './stringFunc';
10
+ export * from './uuidFunc';
@@ -0,0 +1,9 @@
1
+ export declare class JavaScriptFunc {
2
+ /**
3
+ * Some business functions depend on external JavaScript libraries. Lazy loading of respective business modules is good,
4
+ * and this function supports lazy loading of JS libraries.
5
+ * @param scriptUrl
6
+ * @returns Promise for subsequent JS function calls.
7
+ */
8
+ static loadExternalScript(scriptUrl: string): Promise<unknown>;
9
+ }
@@ -1,7 +1,17 @@
1
- export declare class JSFunc {
1
+ /**
2
+ * Basic JSON functions
3
+ */
4
+ export declare class JsonFunc {
5
+ /**
6
+ *
7
+ * @param array Group by a property of array element.
8
+ * @param propertyName
9
+ * @returns
10
+ */
2
11
  static groupBy<T>(array: Array<T>, propertyName: string): any;
3
12
  /**
4
- * Group by a date property. The key is always of string type and representing milliseconds. The client should convert the string to number.
13
+ * Group by a date property. The key is always of string type and representing milliseconds.
14
+ * The client should convert the string to number.
5
15
  * Angular date pipe could actually consume such string without explicitly converting to number.
6
16
  * @param array
7
17
  * @param propertyName
@@ -9,8 +19,13 @@ export declare class JSFunc {
9
19
  static groupByDate<T>(array: Array<T>, propertyName: string): any;
10
20
  /**
11
21
  * Remove null or empty fields including those in nested objects.
22
+ * This is useful for reducing payload of AJAX serialization.
12
23
  * @param obj
13
24
  */
14
25
  static removeNullOrEmptyFields(obj: any): void;
26
+ /**
27
+ *
28
+ * @param obj Remove null fields of object at only the 1st level.
29
+ */
15
30
  static removeNullFields(obj: any): void;
16
31
  }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * String functions specific to Australia
3
+ */
4
+ export declare class StringAusFunc {
5
+ private static acnWeights;
6
+ private static weights;
7
+ private static suggestLookup;
8
+ /**
9
+ * Validate medicare number
10
+ * @param n
11
+ * @returns validation error message
12
+ */
13
+ static validateMedicare(n: string | null | undefined): {
14
+ code: number;
15
+ message: string;
16
+ } | null;
17
+ static validateMedicareProviderNumber(providerNumber: string | null | undefined): {
18
+ code: number;
19
+ message: string;
20
+ } | null;
21
+ static validateDVAFileNumber(dva: string | null | undefined): {
22
+ code: number;
23
+ message: string;
24
+ } | null;
25
+ static validateTFN(n: string | null | undefined): {
26
+ code: number;
27
+ message: string;
28
+ } | null;
29
+ private static addWeighted;
30
+ private static addAcnWeighted;
31
+ private static generateLookup;
32
+ static validateABN(abn: string | null | undefined): {
33
+ code: number;
34
+ message: string;
35
+ } | null;
36
+ static validateACN(acn: string | null | undefined): {
37
+ code: number;
38
+ message: string;
39
+ } | null;
40
+ }
@@ -1,7 +1,4 @@
1
1
  export declare class StringFunc {
2
- private static acnWeights;
3
- private static weights;
4
- private static suggestLookup;
5
2
  /**
6
3
  * Up to 2 letters. For John Smith, returns JS, for Huang, Zijian, returns ZH
7
4
  * @param s
@@ -21,6 +18,12 @@ export declare class StringFunc {
21
18
  * @returns result, or empty string if the input is empty, null or undefined
22
19
  */
23
20
  static getOneLineDigestOfHtml(s: string | null | undefined, length: number): string;
21
+ /**
22
+ * Pad number with zero
23
+ * @param num
24
+ * @param size
25
+ * @returns
26
+ */
24
27
  static pad(num: number | undefined, size: number): string;
25
28
  /**
26
29
  * get plain text of HTML content
@@ -34,37 +37,5 @@ export declare class StringFunc {
34
37
  * @returns result. If input is empty, null, or undefined, return the same.
35
38
  */
36
39
  static capitalizeWords(s: string | null | undefined): string | null | undefined;
37
- /**
38
- * Validate medicare number
39
- * @param n
40
- * @returns validation error message
41
- */
42
- static validateMedicare(n: string | null | undefined): {
43
- code: number;
44
- message: string;
45
- } | null;
46
- static validateMedicareProviderNumber(providerNumber: string | null | undefined): {
47
- code: number;
48
- message: string;
49
- } | null;
50
- static validateDVAFileNumber(dva: string | null | undefined): {
51
- code: number;
52
- message: string;
53
- } | null;
54
- static validateTFN(n: string | null | undefined): {
55
- code: number;
56
- message: string;
57
- } | null;
58
- private static addWeighted;
59
- private static addAcnWeighted;
60
- private static generateLookup;
61
- static validateABN(abn: string | null | undefined): {
62
- code: number;
63
- message: string;
64
- } | null;
65
- static validateACN(acn: string | null | undefined): {
66
- code: number;
67
- message: string;
68
- } | null;
69
- validateEmail(email: string | null | undefined): boolean;
40
+ static validateEmail(email: string | null | undefined): boolean;
70
41
  }
@@ -1,5 +1,4 @@
1
- export declare class HelperFunc {
2
- static loadExternalScript(scriptUrl: string): Promise<unknown>;
1
+ export declare class UuidFunc {
3
2
  /**
4
3
  * 36 UUID string including 4 hyphens. MySql stores GUID as 36 bytes anyway rather than 16bytes.
5
4
  */