@pallasoft/ps-utilities 2.0.0 → 2.2.0
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/client/debounce-service.d.ts +8 -0
- package/dist/client/debounce-service.js +45 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -0
- package/dist/common/date-service.d.ts +3 -0
- package/dist/common/date-service.js +9 -0
- package/dist/models/encrypted-value-payload.d.ts +3 -0
- package/dist/models/encrypted-value-payload.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface DebouncedCall<Args extends unknown[]> {
|
|
2
|
+
cancel: () => void;
|
|
3
|
+
flush: () => void;
|
|
4
|
+
run: (...args: Args) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare class DebounceService {
|
|
7
|
+
static create<Args extends unknown[]>(action: (...args: Args) => void, waitMs: number): DebouncedCall<Args>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebounceService = void 0;
|
|
4
|
+
var DebounceService = /** @class */ (function () {
|
|
5
|
+
function DebounceService() {
|
|
6
|
+
}
|
|
7
|
+
DebounceService.create = function (action, waitMs) {
|
|
8
|
+
var timer = null;
|
|
9
|
+
var pending = null;
|
|
10
|
+
var clear = function () {
|
|
11
|
+
if (timer !== null)
|
|
12
|
+
clearTimeout(timer);
|
|
13
|
+
timer = null;
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
cancel: function () {
|
|
17
|
+
clear();
|
|
18
|
+
pending = null;
|
|
19
|
+
},
|
|
20
|
+
flush: function () {
|
|
21
|
+
if (pending === null)
|
|
22
|
+
return;
|
|
23
|
+
var args = pending;
|
|
24
|
+
clear();
|
|
25
|
+
pending = null;
|
|
26
|
+
action.apply(void 0, args);
|
|
27
|
+
},
|
|
28
|
+
run: function () {
|
|
29
|
+
var args = [];
|
|
30
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
31
|
+
args[_i] = arguments[_i];
|
|
32
|
+
}
|
|
33
|
+
pending = args;
|
|
34
|
+
clear();
|
|
35
|
+
timer = setTimeout(function () {
|
|
36
|
+
timer = null;
|
|
37
|
+
pending = null;
|
|
38
|
+
action.apply(void 0, args);
|
|
39
|
+
}, waitMs);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
return DebounceService;
|
|
44
|
+
}());
|
|
45
|
+
exports.DebounceService = DebounceService;
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./debounce-service"), exports);
|
|
17
18
|
__exportStar(require("./http-service"), exports);
|
|
@@ -9,6 +9,9 @@ export declare class DateService {
|
|
|
9
9
|
static getNextMonth(): string;
|
|
10
10
|
static getNextYear(): string;
|
|
11
11
|
static formatDate(date: string | number, format: string): string;
|
|
12
|
+
static formatDateInTimezone(date: string | number, zone: string, format: string): string;
|
|
13
|
+
static calendarDateInTimezone(date: string | number, zone: string): string;
|
|
14
|
+
static todayInTimezone(zone: string): string;
|
|
12
15
|
static formatDateToString(date: string | number, short?: boolean): string;
|
|
13
16
|
static formatTimeToString(date: string | number, short?: boolean): string;
|
|
14
17
|
static diffInMins(startDate: string | number, endDate: string | number): number;
|
|
@@ -65,6 +65,15 @@ var DateService = /** @class */ (function () {
|
|
|
65
65
|
DateService.formatDate = function (date, format) {
|
|
66
66
|
return (0, dayjs_1.default)(date).format(format);
|
|
67
67
|
};
|
|
68
|
+
DateService.formatDateInTimezone = function (date, zone, format) {
|
|
69
|
+
return (0, dayjs_1.default)(date).tz(zone).format(format);
|
|
70
|
+
};
|
|
71
|
+
DateService.calendarDateInTimezone = function (date, zone) {
|
|
72
|
+
return (0, dayjs_1.default)(date).tz(zone).format('YYYY-MM-DD');
|
|
73
|
+
};
|
|
74
|
+
DateService.todayInTimezone = function (zone) {
|
|
75
|
+
return (0, dayjs_1.default)().tz(zone).format('YYYY-MM-DD');
|
|
76
|
+
};
|
|
68
77
|
DateService.formatDateToString = function (date, short) {
|
|
69
78
|
return (0, dayjs_1.default)(date).format(short ? 'DD MMM, YYYY' : 'DD MMMM, YYYY');
|
|
70
79
|
};
|