nmce-func 1.5.0 → 1.5.1
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/index.d.ts +338 -3
- package/package.json +2 -2
- package/_func/addressFunc.d.ts +0 -31
- package/_func/currencyFunc.d.ts +0 -30
- package/_func/dateFunc.d.ts +0 -122
- package/_func/htmlPrintFunc.d.ts +0 -18
- package/_func/index.d.ts +0 -9
- package/_func/javascriptFunc.d.ts +0 -10
- package/_func/jsonFunc.d.ts +0 -31
- package/_func/stringAusFunc.d.ts +0 -40
- package/_func/stringFunc.d.ts +0 -41
- package/_func/uuidFunc.d.ts +0 -7
- package/public-api.d.ts +0 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,340 @@
|
|
|
1
|
+
declare class AddressFunc {
|
|
2
|
+
/**
|
|
3
|
+
* Compose to one line separated by comma
|
|
4
|
+
* @param st1
|
|
5
|
+
* @param st2
|
|
6
|
+
* @param city
|
|
7
|
+
* @param state
|
|
8
|
+
* @param postcode
|
|
9
|
+
*/
|
|
10
|
+
static composeOneLineAddress(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, postcode: string | undefined): string;
|
|
11
|
+
/**
|
|
12
|
+
* Compose to multiple separated by \n
|
|
13
|
+
* @param st1
|
|
14
|
+
* @param st2
|
|
15
|
+
* @param city
|
|
16
|
+
* @param state
|
|
17
|
+
* @param postcode
|
|
18
|
+
*/
|
|
19
|
+
static composeMultiLineAddress(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, postcode: string | undefined): string;
|
|
20
|
+
/**
|
|
21
|
+
* Compose with separator
|
|
22
|
+
* @param st1
|
|
23
|
+
* @param st2
|
|
24
|
+
* @param city
|
|
25
|
+
* @param state
|
|
26
|
+
* @param postcode
|
|
27
|
+
* @param sep
|
|
28
|
+
*/
|
|
29
|
+
static composeAddress(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, postcode: string | undefined, sep: string | undefined): string;
|
|
30
|
+
static composeGoogleMapsAuUrl(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, country: string | undefined): string;
|
|
31
|
+
}
|
|
32
|
+
|
|
1
33
|
/**
|
|
2
|
-
*
|
|
34
|
+
* Currency calculations. Undefined input of number is considered zero, just like null.
|
|
35
|
+
* Simple functions for currency before you decide to use more comprehensive ones:
|
|
36
|
+
* https://github.com/scurker/currency.js
|
|
37
|
+
* https://github.com/dinerojs/dinero.js Up to date and popular
|
|
3
38
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
39
|
+
declare class CurrencyFunc {
|
|
40
|
+
private static DECIMAL_SEPARATOR;
|
|
41
|
+
private static THOUSANDS_SEPARATOR;
|
|
42
|
+
private static PADDING;
|
|
43
|
+
/**
|
|
44
|
+
* Banker rounding
|
|
45
|
+
* @param num
|
|
46
|
+
* @param decimalPlace default 0
|
|
47
|
+
*/
|
|
48
|
+
static bankerRound(num: number | null | undefined, decimalPlace?: number): number;
|
|
49
|
+
/**
|
|
50
|
+
* Banker rounding to 5 cents
|
|
51
|
+
* @param num
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
static bankerRoundTo5cents(num: number | null | undefined): number;
|
|
55
|
+
static pad(num: number | null | undefined, size: number): string;
|
|
56
|
+
/**
|
|
57
|
+
* Sum array of numbers
|
|
58
|
+
* @param ns
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
static sum(ns: (number | null | undefined)[]): number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class DateFunc {
|
|
65
|
+
/**
|
|
66
|
+
* At runtime, there's no simple guarantee that the input is Date. Sometimes you codes expect date, but the response from the Web service may give you string or number.
|
|
67
|
+
* This function give you safe parse of date data from I/O, not of your control.
|
|
68
|
+
* If the data is invalid, throws RangeError or TypeError.
|
|
69
|
+
* @param dt
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
static dateDataToDate(dt: Date | string | number): Date;
|
|
73
|
+
/**
|
|
74
|
+
* Similar to dateDataToDate, but allow null and defined semantically.
|
|
75
|
+
* @param dt
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
static dateDataToDateOrNull(dt: Date | string | number | null | undefined): Date | null | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Transform UTC DateTime to local date without H, M and S. For example, the month day of 2018-01-23T22:00:00Z is 24 in Australia.
|
|
81
|
+
* @param dtUtc
|
|
82
|
+
*/
|
|
83
|
+
static dateTimeUtcToLocalDateNumber(dtUtc: Date | string | number | null | undefined): number | null | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Date only. However, the date may still be in UTC.
|
|
86
|
+
* @param dtUtc
|
|
87
|
+
* @returns new Date object.
|
|
88
|
+
*/
|
|
89
|
+
static dateTimeUtcToLocalDate(dtUtc: Date | string | number | null | undefined): Date | null | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* '2018-01-23T22:00:00Z' will become '2018-01-24' in Australia.
|
|
92
|
+
* @param dtUtc
|
|
93
|
+
* @returns new Date object.
|
|
94
|
+
*/
|
|
95
|
+
static localISODateString(dtUtc: Date | string | number | null | undefined): string | null | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* local date ONLY (no time) to UTC date.
|
|
98
|
+
* The input could be a string of yyyy-MM-dd, or a Date Object.
|
|
99
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
100
|
+
* While the time value at the heart of a Date object is UTC, the basic methods to fetch the date and time
|
|
101
|
+
* or its components all work in the local (i.e. host system) time zone and offset.
|
|
102
|
+
* @param dt if dt contain time info, it will become dt.setHours(0, 0, 0, 0)
|
|
103
|
+
*/
|
|
104
|
+
static localDateToUtc(d: Date | string | number | null | undefined | string): Date | null | undefined;
|
|
105
|
+
static getEndOfWeek(dt: Date | string | number): Date;
|
|
106
|
+
static getStartOfWeek(dt: Date | string | number): Date;
|
|
107
|
+
static getEndOfMonth(dt: Date | string | number): Date;
|
|
108
|
+
static getStartOfMonth(dt: Date | string | number): Date;
|
|
109
|
+
static getEndOfDate(dt: Date | string | number): Date;
|
|
110
|
+
static getStartOfDate(dt: Date | string | number): Date;
|
|
111
|
+
static getEndOfToday(): Date | null | undefined;
|
|
112
|
+
static getStartOfToday(): Date;
|
|
113
|
+
static getDaysBetween(d1: Date | string | number, d2: Date | string | number): number;
|
|
114
|
+
static addDays(dt: Date | string | number, days: number): Date;
|
|
115
|
+
static addMonths(dt: Date | string | number, months: number): Date;
|
|
116
|
+
static addYears(dt: Date | string | number, years: number): Date;
|
|
117
|
+
static addHours(dt: Date | string | number, hours: number): Date;
|
|
118
|
+
static addMinutes(dt: Date | string | number, minutes: number): Date;
|
|
119
|
+
/**
|
|
120
|
+
* Start of today
|
|
121
|
+
*/
|
|
122
|
+
static get today(): Date;
|
|
123
|
+
static get now(): Date;
|
|
124
|
+
/**
|
|
125
|
+
* From now, next 5 minute mark. For example 2:23:44 will be 2:25:00;
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
static getNext5MinuteMark(): Date;
|
|
129
|
+
static getYMD(d: Date | string | number): string;
|
|
130
|
+
static getDMYWithSlash(d: Date | string | number): string;
|
|
131
|
+
static getDMYHmWithSlash(d: Date | string | number): string;
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @param dtUtc In 24 hour format, and the date separator depending on the system or Luxon default locale
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
static getDateTime24Simple(dtUtc: Date | string | number | null | undefined): string | null | undefined;
|
|
138
|
+
static setDefaultLocale(locale: string): void;
|
|
139
|
+
static getDefaultLocale(): string;
|
|
140
|
+
static setDefaultZone(zone: string): void;
|
|
141
|
+
static getDefaultZone(): string;
|
|
142
|
+
static isZoneValid(): boolean;
|
|
143
|
+
/**
|
|
144
|
+
* For example, in AEST, it is -600.
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
static getLocalTimezoneOffset(): number;
|
|
148
|
+
/**
|
|
149
|
+
* Get hour of the date. If Date is not defined, the hour will be current hour.
|
|
150
|
+
* @param dtUtc
|
|
151
|
+
*/
|
|
152
|
+
static getHour(dtUtc: Date | string | number): number;
|
|
153
|
+
static getMinute(dtUtc: Date | string | number): number;
|
|
154
|
+
static GetHM(dtUtc: Date | string | number): {
|
|
155
|
+
h: number;
|
|
156
|
+
m: number;
|
|
157
|
+
};
|
|
158
|
+
static composeDateTime(dt: Date | string | number, h?: number, minute?: number, second?: number): Date;
|
|
159
|
+
static olderThan24Hours(d: Date | string | number): boolean;
|
|
160
|
+
static olderThanHours(d: Date | string | number, hours: number): boolean;
|
|
161
|
+
static olderThanMinutes(d: Date | string | number, minutes: number): boolean;
|
|
162
|
+
/**
|
|
163
|
+
* It could be 11PM yesterday, and 1 AM today. Actually based on local today.
|
|
164
|
+
*/
|
|
165
|
+
static olderThan1Day(dtUtc: Date | string | number): boolean;
|
|
166
|
+
static getHourAge(d: Date | string | number): number;
|
|
167
|
+
/**
|
|
168
|
+
* Compare date with now.
|
|
169
|
+
* @param dtUtc
|
|
170
|
+
*/
|
|
171
|
+
static getDayAge(d: Date | string | number): number;
|
|
172
|
+
/**
|
|
173
|
+
* How many years from now.
|
|
174
|
+
* @param d
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
static getAge(d: Date | string | number): number;
|
|
178
|
+
/**
|
|
179
|
+
* Convert minutes from midnight to HH:mm text
|
|
180
|
+
* @param minutes
|
|
181
|
+
*/
|
|
182
|
+
static getHMFromMins(minutes: number): string;
|
|
183
|
+
static getMinutesSinceMidnight(d: Date | string | number): number;
|
|
184
|
+
static getMinutesBetween(start: Date | string | number, end: Date | string | number): number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
declare class HtmlPrintFunc {
|
|
188
|
+
/**
|
|
189
|
+
* Print with CSS for internal reports
|
|
190
|
+
* @param htmlTags
|
|
191
|
+
* @param cssUrl
|
|
192
|
+
*/
|
|
193
|
+
static printWithCSS(htmlTags: string, cssUrl: string): boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Print for external documents.
|
|
196
|
+
* @param htmlTags
|
|
197
|
+
*/
|
|
198
|
+
static print(htmlTags: string): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Print image url through html img.
|
|
201
|
+
* @param url
|
|
202
|
+
*/
|
|
203
|
+
static printImage(url: string): void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
declare class JavaScriptFunc {
|
|
207
|
+
/**
|
|
208
|
+
* Some business functions depend on external JavaScript libraries. Lazy loading of respective business modules is good,
|
|
209
|
+
* and this function supports lazy loading of JS libraries.
|
|
210
|
+
* @param scriptUrl
|
|
211
|
+
* @param type things like module.
|
|
212
|
+
* @returns Promise for subsequent JS function calls.
|
|
213
|
+
*/
|
|
214
|
+
static loadExternalScript(scriptUrl: string, type?: string): Promise<unknown>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Basic JSON functions
|
|
219
|
+
*/
|
|
220
|
+
declare class JsonFunc {
|
|
221
|
+
/**
|
|
222
|
+
*
|
|
223
|
+
* @param array Group by a property of array element.
|
|
224
|
+
* @param propertyName
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
static groupBy<T>(array: Array<T>, propertyName: string): any;
|
|
228
|
+
/**
|
|
229
|
+
* Group by a date property. The key is always of string type and representing milliseconds.
|
|
230
|
+
* The client should convert the string to number.
|
|
231
|
+
* Angular date pipe could actually consume such string without explicitly converting to number.
|
|
232
|
+
* @param array
|
|
233
|
+
* @param propertyName
|
|
234
|
+
*/
|
|
235
|
+
static groupByDate<T>(array: Array<T>, propertyName: string): any;
|
|
236
|
+
/**
|
|
237
|
+
* Remove null or empty fields including those in nested objects.
|
|
238
|
+
* This is useful for reducing payload of AJAX serialization.
|
|
239
|
+
* @param obj
|
|
240
|
+
*/
|
|
241
|
+
static removeNullOrEmptyFields(obj: any): void;
|
|
242
|
+
/**
|
|
243
|
+
*
|
|
244
|
+
* @param obj Remove null fields of object at only the 1st level.
|
|
245
|
+
*/
|
|
246
|
+
static removeNullFields(obj: any): void;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* String functions specific to Australia
|
|
251
|
+
*/
|
|
252
|
+
declare class StringAusFunc {
|
|
253
|
+
private static acnWeights;
|
|
254
|
+
private static weights;
|
|
255
|
+
private static suggestLookup;
|
|
256
|
+
/**
|
|
257
|
+
* Validate medicare number
|
|
258
|
+
* @param n
|
|
259
|
+
* @returns validation error message
|
|
260
|
+
*/
|
|
261
|
+
static validateMedicare(n: string | null | undefined): {
|
|
262
|
+
code: number;
|
|
263
|
+
message: string;
|
|
264
|
+
} | null;
|
|
265
|
+
static validateMedicareProviderNumber(providerNumber: string | null | undefined): {
|
|
266
|
+
code: number;
|
|
267
|
+
message: string;
|
|
268
|
+
} | null;
|
|
269
|
+
static validateDVAFileNumber(dva: string | null | undefined): {
|
|
270
|
+
code: number;
|
|
271
|
+
message: string;
|
|
272
|
+
} | null;
|
|
273
|
+
static validateTFN(n: string | null | undefined): {
|
|
274
|
+
code: number;
|
|
275
|
+
message: string;
|
|
276
|
+
} | null;
|
|
277
|
+
private static addWeighted;
|
|
278
|
+
private static addAcnWeighted;
|
|
279
|
+
private static generateLookup;
|
|
280
|
+
static validateABN(abn: string | null | undefined): {
|
|
281
|
+
code: number;
|
|
282
|
+
message: string;
|
|
283
|
+
} | null;
|
|
284
|
+
static validateACN(acn: string | null | undefined): {
|
|
285
|
+
code: number;
|
|
286
|
+
message: string;
|
|
287
|
+
} | null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
declare class StringFunc {
|
|
291
|
+
/**
|
|
292
|
+
* Up to 2 letters. For John Smith, returns JS, for Huang, Zijian, returns ZH
|
|
293
|
+
* @param s
|
|
294
|
+
*/
|
|
295
|
+
static getAbbr(s: string | null | undefined): string;
|
|
296
|
+
/**
|
|
297
|
+
* A substring with line breaks replaced by space.
|
|
298
|
+
* @param s
|
|
299
|
+
* @param length
|
|
300
|
+
* @returns result, or empty string if the input is empty, null or undefined
|
|
301
|
+
*/
|
|
302
|
+
static getOneLineDigest(s: string | null | undefined, length: number): string;
|
|
303
|
+
/**
|
|
304
|
+
* Remove line breaks and econde with encodeURI() so the data could be saved in Azure as meta. If the string is truncated, the return will have ... suffix.
|
|
305
|
+
* @param s
|
|
306
|
+
* @param length
|
|
307
|
+
* @returns result, or empty string if the input is empty, null or undefined
|
|
308
|
+
*/
|
|
309
|
+
static getOneLineDigestOfHtml(s: string | null | undefined, length: number): string;
|
|
310
|
+
/**
|
|
311
|
+
* Pad number with zero
|
|
312
|
+
* @param num
|
|
313
|
+
* @param size
|
|
314
|
+
* @returns
|
|
315
|
+
*/
|
|
316
|
+
static pad(num: number | undefined, size: number): string;
|
|
317
|
+
/**
|
|
318
|
+
* get plain text of HTML content
|
|
319
|
+
* @param s
|
|
320
|
+
* @returns result. If input is empty, null, or undefined, return the same.
|
|
321
|
+
*/
|
|
322
|
+
static getHtmlPlainText(s: string | null | undefined): string | null;
|
|
323
|
+
/**
|
|
324
|
+
*
|
|
325
|
+
* @param s
|
|
326
|
+
* @returns result. If input is empty, null, or undefined, return the same.
|
|
327
|
+
*/
|
|
328
|
+
static capitalizeWords(s: string | null | undefined): string | null | undefined;
|
|
329
|
+
static validateEmail(email: string | null | undefined): boolean;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
declare class UuidFunc {
|
|
333
|
+
/**
|
|
334
|
+
* 36 UUID string including 4 hyphens. MySql stores GUID as 36 bytes anyway rather than 16bytes.
|
|
335
|
+
*/
|
|
336
|
+
static newUUID(): string;
|
|
337
|
+
static newUUIDStartWith0(): string;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { AddressFunc, CurrencyFunc, DateFunc, HtmlPrintFunc, JavaScriptFunc, JsonFunc, StringAusFunc, StringFunc, UuidFunc };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmce-func",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Z"
|
|
6
6
|
},
|
|
7
7
|
"description": "Common simple functions used in business applications.",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
|
-
"url": "https://github.com/zijianhuang/nmce.git"
|
|
10
|
+
"url": "git+https://github.com/zijianhuang/nmce.git"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"angular"
|
package/_func/addressFunc.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare class AddressFunc {
|
|
2
|
-
/**
|
|
3
|
-
* Compose to one line separated by comma
|
|
4
|
-
* @param st1
|
|
5
|
-
* @param st2
|
|
6
|
-
* @param city
|
|
7
|
-
* @param state
|
|
8
|
-
* @param postcode
|
|
9
|
-
*/
|
|
10
|
-
static composeOneLineAddress(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, postcode: string | undefined): string;
|
|
11
|
-
/**
|
|
12
|
-
* Compose to multiple separated by \n
|
|
13
|
-
* @param st1
|
|
14
|
-
* @param st2
|
|
15
|
-
* @param city
|
|
16
|
-
* @param state
|
|
17
|
-
* @param postcode
|
|
18
|
-
*/
|
|
19
|
-
static composeMultiLineAddress(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, postcode: string | undefined): string;
|
|
20
|
-
/**
|
|
21
|
-
* Compose with separator
|
|
22
|
-
* @param st1
|
|
23
|
-
* @param st2
|
|
24
|
-
* @param city
|
|
25
|
-
* @param state
|
|
26
|
-
* @param postcode
|
|
27
|
-
* @param sep
|
|
28
|
-
*/
|
|
29
|
-
static composeAddress(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, postcode: string | undefined, sep: string | undefined): string;
|
|
30
|
-
static composeGoogleMapsAuUrl(st1: string | undefined, st2: string | undefined, city: string | undefined, state: string | undefined, country: string | undefined): string;
|
|
31
|
-
}
|
package/_func/currencyFunc.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Currency calculations. Undefined input of number is considered zero, just like null.
|
|
3
|
-
* Simple functions for currency before you decide to use more comprehensive ones:
|
|
4
|
-
* https://github.com/scurker/currency.js
|
|
5
|
-
* https://github.com/dinerojs/dinero.js Up to date and popular
|
|
6
|
-
*/
|
|
7
|
-
export declare class CurrencyFunc {
|
|
8
|
-
private static DECIMAL_SEPARATOR;
|
|
9
|
-
private static THOUSANDS_SEPARATOR;
|
|
10
|
-
private static PADDING;
|
|
11
|
-
/**
|
|
12
|
-
* Banker rounding
|
|
13
|
-
* @param num
|
|
14
|
-
* @param decimalPlace default 0
|
|
15
|
-
*/
|
|
16
|
-
static bankerRound(num: number | null | undefined, decimalPlace?: number): number;
|
|
17
|
-
/**
|
|
18
|
-
* Banker rounding to 5 cents
|
|
19
|
-
* @param num
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
static bankerRoundTo5cents(num: number | null | undefined): number;
|
|
23
|
-
static pad(num: number | null | undefined, size: number): string;
|
|
24
|
-
/**
|
|
25
|
-
* Sum array of numbers
|
|
26
|
-
* @param ns
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
static sum(ns: (number | null | undefined)[]): number;
|
|
30
|
-
}
|
package/_func/dateFunc.d.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
export declare class DateFunc {
|
|
2
|
-
/**
|
|
3
|
-
* At runtime, there's no simple guarantee that the input is Date. Sometimes you codes expect date, but the response from the Web service may give you string or number.
|
|
4
|
-
* This function give you safe parse of date data from I/O, not of your control.
|
|
5
|
-
* If the data is invalid, throws RangeError or TypeError.
|
|
6
|
-
* @param dt
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
static dateDataToDate(dt: Date | string | number): Date;
|
|
10
|
-
/**
|
|
11
|
-
* Similar to dateDataToDate, but allow null and defined semantically.
|
|
12
|
-
* @param dt
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
static dateDataToDateOrNull(dt: Date | string | number | null | undefined): Date | null | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Transform UTC DateTime to local date without H, M and S. For example, the month day of 2018-01-23T22:00:00Z is 24 in Australia.
|
|
18
|
-
* @param dtUtc
|
|
19
|
-
*/
|
|
20
|
-
static dateTimeUtcToLocalDateNumber(dtUtc: Date | string | number | null | undefined): number | null | undefined;
|
|
21
|
-
/**
|
|
22
|
-
* Date only. However, the date may still be in UTC.
|
|
23
|
-
* @param dtUtc
|
|
24
|
-
* @returns new Date object.
|
|
25
|
-
*/
|
|
26
|
-
static dateTimeUtcToLocalDate(dtUtc: Date | string | number | null | undefined): Date | null | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* '2018-01-23T22:00:00Z' will become '2018-01-24' in Australia.
|
|
29
|
-
* @param dtUtc
|
|
30
|
-
* @returns new Date object.
|
|
31
|
-
*/
|
|
32
|
-
static localISODateString(dtUtc: Date | string | number | null | undefined): string | null | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* local date ONLY (no time) to UTC date.
|
|
35
|
-
* The input could be a string of yyyy-MM-dd, or a Date Object.
|
|
36
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
37
|
-
* While the time value at the heart of a Date object is UTC, the basic methods to fetch the date and time
|
|
38
|
-
* or its components all work in the local (i.e. host system) time zone and offset.
|
|
39
|
-
* @param dt if dt contain time info, it will become dt.setHours(0, 0, 0, 0)
|
|
40
|
-
*/
|
|
41
|
-
static localDateToUtc(d: Date | string | number | null | undefined | string): Date | null | undefined;
|
|
42
|
-
static getEndOfWeek(dt: Date | string | number): Date;
|
|
43
|
-
static getStartOfWeek(dt: Date | string | number): Date;
|
|
44
|
-
static getEndOfMonth(dt: Date | string | number): Date;
|
|
45
|
-
static getStartOfMonth(dt: Date | string | number): Date;
|
|
46
|
-
static getEndOfDate(dt: Date | string | number): Date;
|
|
47
|
-
static getStartOfDate(dt: Date | string | number): Date;
|
|
48
|
-
static getEndOfToday(): Date | null | undefined;
|
|
49
|
-
static getStartOfToday(): Date;
|
|
50
|
-
static getDaysBetween(d1: Date | string | number, d2: Date | string | number): number;
|
|
51
|
-
static addDays(dt: Date | string | number, days: number): Date;
|
|
52
|
-
static addMonths(dt: Date | string | number, months: number): Date;
|
|
53
|
-
static addYears(dt: Date | string | number, years: number): Date;
|
|
54
|
-
static addHours(dt: Date | string | number, hours: number): Date;
|
|
55
|
-
static addMinutes(dt: Date | string | number, minutes: number): Date;
|
|
56
|
-
/**
|
|
57
|
-
* Start of today
|
|
58
|
-
*/
|
|
59
|
-
static get today(): Date;
|
|
60
|
-
static get now(): Date;
|
|
61
|
-
/**
|
|
62
|
-
* From now, next 5 minute mark. For example 2:23:44 will be 2:25:00;
|
|
63
|
-
* @returns
|
|
64
|
-
*/
|
|
65
|
-
static getNext5MinuteMark(): Date;
|
|
66
|
-
static getYMD(d: Date | string | number): string;
|
|
67
|
-
static getDMYWithSlash(d: Date | string | number): string;
|
|
68
|
-
static getDMYHmWithSlash(d: Date | string | number): string;
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
* @param dtUtc In 24 hour format, and the date separator depending on the system or Luxon default locale
|
|
72
|
-
* @returns
|
|
73
|
-
*/
|
|
74
|
-
static getDateTime24Simple(dtUtc: Date | string | number | null | undefined): string | null | undefined;
|
|
75
|
-
static setDefaultLocale(locale: string): void;
|
|
76
|
-
static getDefaultLocale(): string;
|
|
77
|
-
static setDefaultZone(zone: string): void;
|
|
78
|
-
static getDefaultZone(): string;
|
|
79
|
-
static isZoneValid(): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* For example, in AEST, it is -600.
|
|
82
|
-
* @returns
|
|
83
|
-
*/
|
|
84
|
-
static getLocalTimezoneOffset(): number;
|
|
85
|
-
/**
|
|
86
|
-
* Get hour of the date. If Date is not defined, the hour will be current hour.
|
|
87
|
-
* @param dtUtc
|
|
88
|
-
*/
|
|
89
|
-
static getHour(dtUtc: Date | string | number): number;
|
|
90
|
-
static getMinute(dtUtc: Date | string | number): number;
|
|
91
|
-
static GetHM(dtUtc: Date | string | number): {
|
|
92
|
-
h: number;
|
|
93
|
-
m: number;
|
|
94
|
-
};
|
|
95
|
-
static composeDateTime(dt: Date | string | number, h?: number, minute?: number, second?: number): Date;
|
|
96
|
-
static olderThan24Hours(d: Date | string | number): boolean;
|
|
97
|
-
static olderThanHours(d: Date | string | number, hours: number): boolean;
|
|
98
|
-
static olderThanMinutes(d: Date | string | number, minutes: number): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* It could be 11PM yesterday, and 1 AM today. Actually based on local today.
|
|
101
|
-
*/
|
|
102
|
-
static olderThan1Day(dtUtc: Date | string | number): boolean;
|
|
103
|
-
static getHourAge(d: Date | string | number): number;
|
|
104
|
-
/**
|
|
105
|
-
* Compare date with now.
|
|
106
|
-
* @param dtUtc
|
|
107
|
-
*/
|
|
108
|
-
static getDayAge(d: Date | string | number): number;
|
|
109
|
-
/**
|
|
110
|
-
* How many years from now.
|
|
111
|
-
* @param d
|
|
112
|
-
* @returns
|
|
113
|
-
*/
|
|
114
|
-
static getAge(d: Date | string | number): number;
|
|
115
|
-
/**
|
|
116
|
-
* Convert minutes from midnight to HH:mm text
|
|
117
|
-
* @param minutes
|
|
118
|
-
*/
|
|
119
|
-
static getHMFromMins(minutes: number): string;
|
|
120
|
-
static getMinutesSinceMidnight(d: Date | string | number): number;
|
|
121
|
-
static getMinutesBetween(start: Date | string | number, end: Date | string | number): number;
|
|
122
|
-
}
|
package/_func/htmlPrintFunc.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './addressFunc';
|
|
2
|
-
export * from './currencyFunc';
|
|
3
|
-
export * from './dateFunc';
|
|
4
|
-
export * from './htmlPrintFunc';
|
|
5
|
-
export * from './javascriptFunc';
|
|
6
|
-
export * from './jsonFunc';
|
|
7
|
-
export * from './stringAusFunc';
|
|
8
|
-
export * from './stringFunc';
|
|
9
|
-
export * from './uuidFunc';
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
* @param type things like module.
|
|
7
|
-
* @returns Promise for subsequent JS function calls.
|
|
8
|
-
*/
|
|
9
|
-
static loadExternalScript(scriptUrl: string, type?: string): Promise<unknown>;
|
|
10
|
-
}
|
package/_func/jsonFunc.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
*/
|
|
11
|
-
static groupBy<T>(array: Array<T>, propertyName: string): any;
|
|
12
|
-
/**
|
|
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.
|
|
15
|
-
* Angular date pipe could actually consume such string without explicitly converting to number.
|
|
16
|
-
* @param array
|
|
17
|
-
* @param propertyName
|
|
18
|
-
*/
|
|
19
|
-
static groupByDate<T>(array: Array<T>, propertyName: string): any;
|
|
20
|
-
/**
|
|
21
|
-
* Remove null or empty fields including those in nested objects.
|
|
22
|
-
* This is useful for reducing payload of AJAX serialization.
|
|
23
|
-
* @param obj
|
|
24
|
-
*/
|
|
25
|
-
static removeNullOrEmptyFields(obj: any): void;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param obj Remove null fields of object at only the 1st level.
|
|
29
|
-
*/
|
|
30
|
-
static removeNullFields(obj: any): void;
|
|
31
|
-
}
|
package/_func/stringAusFunc.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}
|
package/_func/stringFunc.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export declare class StringFunc {
|
|
2
|
-
/**
|
|
3
|
-
* Up to 2 letters. For John Smith, returns JS, for Huang, Zijian, returns ZH
|
|
4
|
-
* @param s
|
|
5
|
-
*/
|
|
6
|
-
static getAbbr(s: string | null | undefined): string;
|
|
7
|
-
/**
|
|
8
|
-
* A substring with line breaks replaced by space.
|
|
9
|
-
* @param s
|
|
10
|
-
* @param length
|
|
11
|
-
* @returns result, or empty string if the input is empty, null or undefined
|
|
12
|
-
*/
|
|
13
|
-
static getOneLineDigest(s: string | null | undefined, length: number): string;
|
|
14
|
-
/**
|
|
15
|
-
* Remove line breaks and econde with encodeURI() so the data could be saved in Azure as meta. If the string is truncated, the return will have ... suffix.
|
|
16
|
-
* @param s
|
|
17
|
-
* @param length
|
|
18
|
-
* @returns result, or empty string if the input is empty, null or undefined
|
|
19
|
-
*/
|
|
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
|
-
*/
|
|
27
|
-
static pad(num: number | undefined, size: number): string;
|
|
28
|
-
/**
|
|
29
|
-
* get plain text of HTML content
|
|
30
|
-
* @param s
|
|
31
|
-
* @returns result. If input is empty, null, or undefined, return the same.
|
|
32
|
-
*/
|
|
33
|
-
static getHtmlPlainText(s: string | null | undefined): string | null;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @param s
|
|
37
|
-
* @returns result. If input is empty, null, or undefined, return the same.
|
|
38
|
-
*/
|
|
39
|
-
static capitalizeWords(s: string | null | undefined): string | null | undefined;
|
|
40
|
-
static validateEmail(email: string | null | undefined): boolean;
|
|
41
|
-
}
|
package/_func/uuidFunc.d.ts
DELETED
package/public-api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './_func/index';
|