diff --git a/core/util/package.json b/core/util/package.json index ea868dfc7..11566edf7 100644 --- a/core/util/package.json +++ b/core/util/package.json @@ -32,6 +32,8 @@ "url": "https://github.com/AliMD/alwatr/issues" }, "dependencies": { - "tslib": "^2.5.0" + "tslib": "^2.5.0", + "@alwatr/math": "^0.29.0", + "@alwatr/type": "^0.29.0" } } diff --git a/core/util/src/index.ts b/core/util/src/index.ts index e36815a83..bc5a45ebe 100644 --- a/core/util/src/index.ts +++ b/core/util/src/index.ts @@ -1 +1,4 @@ export * from './delay.js'; +export * from './json.js'; +export * from './local-storage.js'; +export * from './client-id.js'; diff --git a/core/util/src/json.ts b/core/util/src/json.ts new file mode 100644 index 000000000..6a2d441e4 --- /dev/null +++ b/core/util/src/json.ts @@ -0,0 +1,11 @@ +import type {Stringifyable} from '@alwatr/type'; + +export const parseJson = (str: string): T | null => { + try { + return JSON.parse(str) as T; + } + catch (err) { + console.error(err); + return null; + } +}; diff --git a/core/util/tsconfig.json b/core/util/tsconfig.json index d26028499..f3c2df152 100644 --- a/core/util/tsconfig.json +++ b/core/util/tsconfig.json @@ -9,5 +9,8 @@ "include": ["src/**/*.ts"], "exclude": [], - "references": [{"path": "../math"}] + "references": [ + {"path": "../type"}, + {"path": "../math"}, + ] }