jdev_helpers 1.2.4 → 1.3.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/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +27 -0
- package/dist/index.mjs +25 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HttpParams } from '@angular/common/module.d-CnjH8Dlt';
|
|
1
2
|
import { HttpClient } from '@angular/common/http';
|
|
2
3
|
|
|
3
4
|
declare const debug: (message?: any, ...optionalParams: any[]) => void;
|
|
@@ -7,9 +8,17 @@ declare const WRITE_TO_SESSION_STORAGE: (storageName: string, obj: any) => void;
|
|
|
7
8
|
declare const READ_FROM_LOCAL_STORAGE: (storageName: string) => any;
|
|
8
9
|
declare const READ_FROM_SESSION_STORAGE: (storageName: string) => any;
|
|
9
10
|
|
|
11
|
+
interface CustomHttpParam {
|
|
12
|
+
key: string;
|
|
13
|
+
value: any;
|
|
14
|
+
needToCheckValue?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare function createHttpParams(customHttpParams: CustomHttpParam[]): HttpParams;
|
|
17
|
+
declare function addHttpParams(hp: HttpParams, customHttpParams: CustomHttpParam): HttpParams;
|
|
18
|
+
|
|
10
19
|
declare abstract class HttpParentService {
|
|
11
20
|
protected readonly http: HttpClient;
|
|
12
21
|
constructor();
|
|
13
22
|
}
|
|
14
23
|
|
|
15
|
-
export { HttpParentService, READ_FROM_LOCAL_STORAGE, READ_FROM_SESSION_STORAGE, WRITE_TO_LOCAL_STORAGE, WRITE_TO_SESSION_STORAGE, debug };
|
|
24
|
+
export { type CustomHttpParam, HttpParentService, READ_FROM_LOCAL_STORAGE, READ_FROM_SESSION_STORAGE, WRITE_TO_LOCAL_STORAGE, WRITE_TO_SESSION_STORAGE, addHttpParams, createHttpParams, debug };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HttpParams } from '@angular/common/module.d-CnjH8Dlt';
|
|
1
2
|
import { HttpClient } from '@angular/common/http';
|
|
2
3
|
|
|
3
4
|
declare const debug: (message?: any, ...optionalParams: any[]) => void;
|
|
@@ -7,9 +8,17 @@ declare const WRITE_TO_SESSION_STORAGE: (storageName: string, obj: any) => void;
|
|
|
7
8
|
declare const READ_FROM_LOCAL_STORAGE: (storageName: string) => any;
|
|
8
9
|
declare const READ_FROM_SESSION_STORAGE: (storageName: string) => any;
|
|
9
10
|
|
|
11
|
+
interface CustomHttpParam {
|
|
12
|
+
key: string;
|
|
13
|
+
value: any;
|
|
14
|
+
needToCheckValue?: boolean;
|
|
15
|
+
}
|
|
16
|
+
declare function createHttpParams(customHttpParams: CustomHttpParam[]): HttpParams;
|
|
17
|
+
declare function addHttpParams(hp: HttpParams, customHttpParams: CustomHttpParam): HttpParams;
|
|
18
|
+
|
|
10
19
|
declare abstract class HttpParentService {
|
|
11
20
|
protected readonly http: HttpClient;
|
|
12
21
|
constructor();
|
|
13
22
|
}
|
|
14
23
|
|
|
15
|
-
export { HttpParentService, READ_FROM_LOCAL_STORAGE, READ_FROM_SESSION_STORAGE, WRITE_TO_LOCAL_STORAGE, WRITE_TO_SESSION_STORAGE, debug };
|
|
24
|
+
export { type CustomHttpParam, HttpParentService, READ_FROM_LOCAL_STORAGE, READ_FROM_SESSION_STORAGE, WRITE_TO_LOCAL_STORAGE, WRITE_TO_SESSION_STORAGE, addHttpParams, createHttpParams, debug };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,8 @@ __export(index_exports, {
|
|
|
25
25
|
READ_FROM_SESSION_STORAGE: () => READ_FROM_SESSION_STORAGE,
|
|
26
26
|
WRITE_TO_LOCAL_STORAGE: () => WRITE_TO_LOCAL_STORAGE,
|
|
27
27
|
WRITE_TO_SESSION_STORAGE: () => WRITE_TO_SESSION_STORAGE,
|
|
28
|
+
addHttpParams: () => addHttpParams,
|
|
29
|
+
createHttpParams: () => createHttpParams,
|
|
28
30
|
debug: () => debug
|
|
29
31
|
});
|
|
30
32
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -69,6 +71,29 @@ var writeToStorage = (storageName, obj, isLocalStorage) => {
|
|
|
69
71
|
}
|
|
70
72
|
};
|
|
71
73
|
|
|
74
|
+
// src/js/http-helper.ts
|
|
75
|
+
var import_module = require("@angular/common/module.d-CnjH8Dlt");
|
|
76
|
+
function createHttpParams(customHttpParams) {
|
|
77
|
+
return addParamsToHttpParamsProcess(new import_module.HttpParams(), customHttpParams);
|
|
78
|
+
}
|
|
79
|
+
function addHttpParams(hp, customHttpParams) {
|
|
80
|
+
if (customHttpParams.needToCheckValue) {
|
|
81
|
+
if (customHttpParams.value) {
|
|
82
|
+
return hp.append(customHttpParams.key, customHttpParams.value);
|
|
83
|
+
} else {
|
|
84
|
+
return hp;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
return hp.append(customHttpParams.key, customHttpParams.value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function addParamsToHttpParamsProcess(hp, customHttpParams) {
|
|
91
|
+
customHttpParams.forEach((currentCustomHttpParam) => {
|
|
92
|
+
hp = addHttpParams(hp, currentCustomHttpParam);
|
|
93
|
+
});
|
|
94
|
+
return hp;
|
|
95
|
+
}
|
|
96
|
+
|
|
72
97
|
// src/angular/http-parent.service.ts
|
|
73
98
|
var import_http = require("@angular/common/http");
|
|
74
99
|
var import_core = require("@angular/core");
|
|
@@ -84,5 +109,7 @@ var HttpParentService = class {
|
|
|
84
109
|
READ_FROM_SESSION_STORAGE,
|
|
85
110
|
WRITE_TO_LOCAL_STORAGE,
|
|
86
111
|
WRITE_TO_SESSION_STORAGE,
|
|
112
|
+
addHttpParams,
|
|
113
|
+
createHttpParams,
|
|
87
114
|
debug
|
|
88
115
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,29 @@ var writeToStorage = (storageName, obj, isLocalStorage) => {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
// src/js/http-helper.ts
|
|
42
|
+
import { HttpParams } from "@angular/common/module.d-CnjH8Dlt";
|
|
43
|
+
function createHttpParams(customHttpParams) {
|
|
44
|
+
return addParamsToHttpParamsProcess(new HttpParams(), customHttpParams);
|
|
45
|
+
}
|
|
46
|
+
function addHttpParams(hp, customHttpParams) {
|
|
47
|
+
if (customHttpParams.needToCheckValue) {
|
|
48
|
+
if (customHttpParams.value) {
|
|
49
|
+
return hp.append(customHttpParams.key, customHttpParams.value);
|
|
50
|
+
} else {
|
|
51
|
+
return hp;
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
return hp.append(customHttpParams.key, customHttpParams.value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function addParamsToHttpParamsProcess(hp, customHttpParams) {
|
|
58
|
+
customHttpParams.forEach((currentCustomHttpParam) => {
|
|
59
|
+
hp = addHttpParams(hp, currentCustomHttpParam);
|
|
60
|
+
});
|
|
61
|
+
return hp;
|
|
62
|
+
}
|
|
63
|
+
|
|
41
64
|
// src/angular/http-parent.service.ts
|
|
42
65
|
import { HttpClient } from "@angular/common/http";
|
|
43
66
|
import { inject } from "@angular/core";
|
|
@@ -52,5 +75,7 @@ export {
|
|
|
52
75
|
READ_FROM_SESSION_STORAGE,
|
|
53
76
|
WRITE_TO_LOCAL_STORAGE,
|
|
54
77
|
WRITE_TO_SESSION_STORAGE,
|
|
78
|
+
addHttpParams,
|
|
79
|
+
createHttpParams,
|
|
55
80
|
debug
|
|
56
81
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jdev_helpers",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "jdev helpers for js and angular",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
"tsup": "^8.5.0",
|
|
29
29
|
"typescript": "^5.8.3"
|
|
30
30
|
}
|
|
31
|
-
}
|
|
31
|
+
}
|