@react-pakistan/util-functions 1.10.16 → 1.11.2
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/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/local-storage/get-storage-value.d.ts +2 -0
- package/local-storage/get-storage-value.js +21 -0
- package/local-storage/index.d.ts +4 -0
- package/local-storage/index.js +20 -0
- package/local-storage/remove-storage-value.d.ts +1 -0
- package/local-storage/remove-storage-value.js +14 -0
- package/local-storage/set-storage-value.d.ts +1 -0
- package/local-storage/set-storage-value.js +14 -0
- package/local-storage/type.d.ts +1 -0
- package/local-storage/type.js +2 -0
- package/package.json +13 -13
package/hooks/index.d.ts
CHANGED
package/hooks/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./use-change"), exports);
|
|
18
|
+
__exportStar(require("./use-force-render"), exports);
|
|
18
19
|
__exportStar(require("./use-selector"), exports);
|
|
20
|
+
__exportStar(require("./use-sticky"), exports);
|
|
19
21
|
__exportStar(require("./use-toggle-state"), exports);
|
|
20
22
|
__exportStar(require("./use-window-event-listener"), exports);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./action-creator-factories"), exports);
|
|
|
18
18
|
__exportStar(require("./constants"), exports);
|
|
19
19
|
__exportStar(require("./general"), exports);
|
|
20
20
|
__exportStar(require("./hooks"), exports);
|
|
21
|
+
__exportStar(require("./local-storage"), exports);
|
|
21
22
|
__exportStar(require("./storybook"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable consistent-return */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getStorageValue = void 0;
|
|
5
|
+
const getStorageValue = (key) => {
|
|
6
|
+
try {
|
|
7
|
+
const value = localStorage.getItem(key);
|
|
8
|
+
try {
|
|
9
|
+
return value === null ? value : JSON.parse(value);
|
|
10
|
+
}
|
|
11
|
+
catch (_a) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
if (e instanceof Error && e.name === 'NS_ERROR_FILE_CORRUPTED') {
|
|
17
|
+
localStorage.clear();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.getStorageValue = getStorageValue;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./get-storage-value"), exports);
|
|
18
|
+
__exportStar(require("./remove-storage-value"), exports);
|
|
19
|
+
__exportStar(require("./set-storage-value"), exports);
|
|
20
|
+
__exportStar(require("./type"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const removeStorageValue: (key: string) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeStorageValue = void 0;
|
|
4
|
+
const removeStorageValue = (key) => {
|
|
5
|
+
try {
|
|
6
|
+
localStorage.removeItem(key);
|
|
7
|
+
}
|
|
8
|
+
catch (e) {
|
|
9
|
+
if (e instanceof Error && e.name === 'NS_ERROR_FILE_CORRUPTED') {
|
|
10
|
+
localStorage.clear();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.removeStorageValue = removeStorageValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setStorageValue: (key: string, value: unknown) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setStorageValue = void 0;
|
|
4
|
+
const setStorageValue = (key, value) => {
|
|
5
|
+
try {
|
|
6
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
7
|
+
}
|
|
8
|
+
catch (e) {
|
|
9
|
+
if (e instanceof Error && e.name === 'NS_ERROR_FILE_CORRUPTED') {
|
|
10
|
+
localStorage.clear();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
exports.setStorageValue = setStorageValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type AllowedTypes = boolean | string | number | Record<string, unknown> | null | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-pakistan/util-functions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "A library of all util functions",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,32 +38,32 @@
|
|
|
38
38
|
"homepage": "https://github.com/react-pakistan/util-functions#readme",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@microsoft/tsdoc": "^0.14.1",
|
|
41
|
-
"date-fns": "^2.
|
|
42
|
-
"date-fns-tz": "^1.3.
|
|
41
|
+
"date-fns": "^2.29.1",
|
|
42
|
+
"date-fns-tz": "^1.3.6",
|
|
43
43
|
"lodash.curry": "^4.1.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@babel/core": "^7.18.
|
|
47
|
-
"@babel/eslint-parser": "^7.18.
|
|
46
|
+
"@babel/core": "^7.18.9",
|
|
47
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
48
48
|
"@babel/preset-typescript": "^7.18.6",
|
|
49
|
-
"@react-pakistan/eslint-config-shared": "^1.4.
|
|
50
|
-
"@types/jest": "^28.1.
|
|
49
|
+
"@react-pakistan/eslint-config-shared": "^1.4.31",
|
|
50
|
+
"@types/jest": "^28.1.6",
|
|
51
51
|
"@types/lodash.curry": "^4.1.7",
|
|
52
|
-
"@types/node": "^18.0.
|
|
52
|
+
"@types/node": "^18.0.6",
|
|
53
53
|
"@types/react-redux": "^7.1.24",
|
|
54
54
|
"@types/styled-components": "^5.1.25",
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^5.30.
|
|
56
|
-
"@typescript-eslint/parser": "^5.30.
|
|
57
|
-
"eslint": "^8.
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
56
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
57
|
+
"eslint": "^8.20.0",
|
|
58
58
|
"eslint-plugin-import": "^2.26.0",
|
|
59
59
|
"husky": "^8.0.1",
|
|
60
|
-
"jest": "^28.1.
|
|
60
|
+
"jest": "^28.1.3",
|
|
61
61
|
"lint-staged": "^13.0.3",
|
|
62
62
|
"lodash.isequal": "^4.5.0",
|
|
63
63
|
"react": "^18.2.0",
|
|
64
64
|
"react-redux": "^8.0.2",
|
|
65
65
|
"rimraf": "^3.0.2",
|
|
66
|
-
"ts-jest": "^28.0.
|
|
66
|
+
"ts-jest": "^28.0.7",
|
|
67
67
|
"ts-loader": "^9.3.1",
|
|
68
68
|
"typescript": "^4.7.4"
|
|
69
69
|
},
|