We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ff8fe80 commit e9f648dCopy full SHA for e9f648d
lib/utils/index.js
@@ -30,6 +30,33 @@ export function isFunction(item) {
30
return (item && typeof item === 'function');
31
}
32
33
+/**
34
+ *
35
+ * @param string
36
+ * @returns {*}
37
+ */
38
+export function tryJSONParse(string) {
39
+ try {
40
+ return JSON.parse(string);
41
+ } catch (jsonError) {
42
+ return string;
43
+ }
44
+}
45
+
46
47
48
+ * @param data
49
50
51
+export function tryJSONStringify(data) {
52
53
+ return JSON.stringify(data);
54
55
+ return undefined;
56
57
58
59
60
// noinspection Eslint
61
export const windowOrGlobal = (typeof self === 'object' && self.self === self && self) || (typeof global === 'object' && global.global === global && global) || this;
62
0 commit comments