jdev_helpers 1.0.0 → 1.0.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/README.MD +0 -3
- package/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +50 -5
- package/dist/index.mjs +43 -4
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -33,9 +33,6 @@ docker run -it -v $(pwd):/myWorkDir nodejs-util:node22 install typescript
|
|
|
33
33
|
docker run -it -v $(pwd):/myWorkDir nodejs-util:node22 install -D typescript tsup
|
|
34
34
|
docker run -it -v $(pwd):/myWorkDir nodejs-util:node22 run build
|
|
35
35
|
|
|
36
|
-
docker run -it -v $(pwd):/myWorkDir nodejs-util:node22 adduser && npm publish
|
|
37
|
-
docker run -it -v $(pwd):/myWorkDir nodejs-util:node22 whoami
|
|
38
|
-
|
|
39
36
|
|
|
40
37
|
npm adduser
|
|
41
38
|
npm whoami
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @returns The sum of a and b.
|
|
6
|
-
*/
|
|
7
|
-
declare function add(a: number, b: number): number;
|
|
1
|
+
declare const WRITE_TO_LOCAL_STORAGE: (storageName: string, obj: any) => void;
|
|
2
|
+
declare const WRITE_TO_SESSION_STORAGE: (storageName: string, obj: any) => void;
|
|
3
|
+
declare const READ_FROM_LOCAL_STORAGE: (storageName: string) => any;
|
|
4
|
+
declare const READ_FROM_SESSION_STORAGE: (storageName: string) => any;
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
declare const debug: (message?: any, ...optionalParams: any[]) => void;
|
|
7
|
+
|
|
8
|
+
export { READ_FROM_LOCAL_STORAGE, READ_FROM_SESSION_STORAGE, WRITE_TO_LOCAL_STORAGE, WRITE_TO_SESSION_STORAGE, debug };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @returns The sum of a and b.
|
|
6
|
-
*/
|
|
7
|
-
declare function add(a: number, b: number): number;
|
|
1
|
+
declare const WRITE_TO_LOCAL_STORAGE: (storageName: string, obj: any) => void;
|
|
2
|
+
declare const WRITE_TO_SESSION_STORAGE: (storageName: string, obj: any) => void;
|
|
3
|
+
declare const READ_FROM_LOCAL_STORAGE: (storageName: string) => any;
|
|
4
|
+
declare const READ_FROM_SESSION_STORAGE: (storageName: string) => any;
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
declare const debug: (message?: any, ...optionalParams: any[]) => void;
|
|
7
|
+
|
|
8
|
+
export { READ_FROM_LOCAL_STORAGE, READ_FROM_SESSION_STORAGE, WRITE_TO_LOCAL_STORAGE, WRITE_TO_SESSION_STORAGE, debug };
|
package/dist/index.js
CHANGED
|
@@ -20,13 +20,58 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
23
|
+
READ_FROM_LOCAL_STORAGE: () => READ_FROM_LOCAL_STORAGE,
|
|
24
|
+
READ_FROM_SESSION_STORAGE: () => READ_FROM_SESSION_STORAGE,
|
|
25
|
+
WRITE_TO_LOCAL_STORAGE: () => WRITE_TO_LOCAL_STORAGE,
|
|
26
|
+
WRITE_TO_SESSION_STORAGE: () => WRITE_TO_SESSION_STORAGE,
|
|
27
|
+
debug: () => debug
|
|
24
28
|
});
|
|
25
29
|
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
// src/storage-helper.ts
|
|
32
|
+
var WRITE_TO_LOCAL_STORAGE = (storageName, obj) => {
|
|
33
|
+
writeToStorage(storageName, obj, true);
|
|
34
|
+
};
|
|
35
|
+
var WRITE_TO_SESSION_STORAGE = (storageName, obj) => {
|
|
36
|
+
writeToStorage(storageName, obj, false);
|
|
37
|
+
};
|
|
38
|
+
var READ_FROM_LOCAL_STORAGE = (storageName) => {
|
|
39
|
+
return readFromStorage(storageName, true);
|
|
40
|
+
};
|
|
41
|
+
var READ_FROM_SESSION_STORAGE = (storageName) => {
|
|
42
|
+
return readFromStorage(storageName, false);
|
|
43
|
+
};
|
|
44
|
+
var readFromStorage = (storageName, isLocalStorage) => {
|
|
45
|
+
if (typeof window === "undefined") {
|
|
46
|
+
throw Error("Cannot find window!");
|
|
47
|
+
} else {
|
|
48
|
+
if (isLocalStorage) {
|
|
49
|
+
return window.localStorage.getItem(storageName);
|
|
50
|
+
}
|
|
51
|
+
return window.sessionStorage.getItem(storageName);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var writeToStorage = (storageName, obj, isLocalStorage) => {
|
|
55
|
+
if (typeof window === "undefined") {
|
|
56
|
+
throw Error("Cannot find window!");
|
|
57
|
+
} else {
|
|
58
|
+
if (isLocalStorage) {
|
|
59
|
+
window.localStorage.setItem(storageName, JSON.stringify(obj));
|
|
60
|
+
} else {
|
|
61
|
+
window.sessionStorage.setItem(storageName, JSON.stringify(obj));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/index.ts
|
|
67
|
+
var debug = (message, ...optionalParams) => {
|
|
68
|
+
console.log(message, ...optionalParams);
|
|
69
|
+
};
|
|
29
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
71
|
0 && (module.exports = {
|
|
31
|
-
|
|
72
|
+
READ_FROM_LOCAL_STORAGE,
|
|
73
|
+
READ_FROM_SESSION_STORAGE,
|
|
74
|
+
WRITE_TO_LOCAL_STORAGE,
|
|
75
|
+
WRITE_TO_SESSION_STORAGE,
|
|
76
|
+
debug
|
|
32
77
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
|
+
// src/storage-helper.ts
|
|
2
|
+
var WRITE_TO_LOCAL_STORAGE = (storageName, obj) => {
|
|
3
|
+
writeToStorage(storageName, obj, true);
|
|
4
|
+
};
|
|
5
|
+
var WRITE_TO_SESSION_STORAGE = (storageName, obj) => {
|
|
6
|
+
writeToStorage(storageName, obj, false);
|
|
7
|
+
};
|
|
8
|
+
var READ_FROM_LOCAL_STORAGE = (storageName) => {
|
|
9
|
+
return readFromStorage(storageName, true);
|
|
10
|
+
};
|
|
11
|
+
var READ_FROM_SESSION_STORAGE = (storageName) => {
|
|
12
|
+
return readFromStorage(storageName, false);
|
|
13
|
+
};
|
|
14
|
+
var readFromStorage = (storageName, isLocalStorage) => {
|
|
15
|
+
if (typeof window === "undefined") {
|
|
16
|
+
throw Error("Cannot find window!");
|
|
17
|
+
} else {
|
|
18
|
+
if (isLocalStorage) {
|
|
19
|
+
return window.localStorage.getItem(storageName);
|
|
20
|
+
}
|
|
21
|
+
return window.sessionStorage.getItem(storageName);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var writeToStorage = (storageName, obj, isLocalStorage) => {
|
|
25
|
+
if (typeof window === "undefined") {
|
|
26
|
+
throw Error("Cannot find window!");
|
|
27
|
+
} else {
|
|
28
|
+
if (isLocalStorage) {
|
|
29
|
+
window.localStorage.setItem(storageName, JSON.stringify(obj));
|
|
30
|
+
} else {
|
|
31
|
+
window.sessionStorage.setItem(storageName, JSON.stringify(obj));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
1
36
|
// src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
37
|
+
var debug = (message, ...optionalParams) => {
|
|
38
|
+
console.log(message, ...optionalParams);
|
|
39
|
+
};
|
|
5
40
|
export {
|
|
6
|
-
|
|
41
|
+
READ_FROM_LOCAL_STORAGE,
|
|
42
|
+
READ_FROM_SESSION_STORAGE,
|
|
43
|
+
WRITE_TO_LOCAL_STORAGE,
|
|
44
|
+
WRITE_TO_SESSION_STORAGE,
|
|
45
|
+
debug
|
|
7
46
|
};
|