@pallasoft/ps-utilities 2.1.0 → 2.3.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/http-service.d.ts +1 -0
- package/dist/client/http-service.js +3 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +1 -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;
|
|
@@ -49,7 +49,7 @@ var HttpService = /** @class */ (function () {
|
|
|
49
49
|
HttpService.createApiClient = function (options) {
|
|
50
50
|
var _this = this;
|
|
51
51
|
if (options === void 0) { options = {}; }
|
|
52
|
-
var apiKey = options.apiKey, _a = options.apiKeyHeader, apiKeyHeader = _a === void 0 ? 'X-API-Key' : _a, baseURL = options.baseURL;
|
|
52
|
+
var apiKey = options.apiKey, _a = options.apiKeyHeader, apiKeyHeader = _a === void 0 ? 'X-API-Key' : _a, baseURL = options.baseURL, defaultHeaders = options.headers;
|
|
53
53
|
var request = function (method, url, data, config) { return __awaiter(_this, void 0, void 0, function () {
|
|
54
54
|
var fullUrl, sendsBinaryBody, headers, body, response, responseData, error;
|
|
55
55
|
return __generator(this, function (_a) {
|
|
@@ -60,6 +60,8 @@ var HttpService = /** @class */ (function () {
|
|
|
60
60
|
headers = sendsBinaryBody
|
|
61
61
|
? {}
|
|
62
62
|
: { 'Content-Type': 'application/json' };
|
|
63
|
+
if (defaultHeaders)
|
|
64
|
+
Object.assign(headers, defaultHeaders);
|
|
63
65
|
if (apiKey)
|
|
64
66
|
headers[apiKeyHeader] = apiKey;
|
|
65
67
|
if (config === null || config === void 0 ? void 0 : config.headers)
|
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);
|