@rainte/js 0.0.12 → 0.0.13
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/lib/index.ts +1 -0
- package/package.json +25 -25
- package/src/http/axios.ts +2 -2
- package/src/json/index.ts +14 -0
- package/src/storage/index.ts +3 -4
- package/dist/index.js +0 -2635
- package/dist/index.umd.cjs +0 -6
- package/dist/types/lib/index.d.ts +0 -5
- package/dist/types/src/date/index.d.ts +0 -11
- package/dist/types/src/fast/index.d.ts +0 -8
- package/dist/types/src/file/index.d.ts +0 -3
- package/dist/types/src/http/axios.d.ts +0 -6
- package/dist/types/src/http/index.d.ts +0 -6
- package/dist/types/src/main.d.ts +0 -1
- package/dist/types/src/storage/index.d.ts +0 -16
- package/dist/types/vite.config.d.ts +0 -2
- package/dist/vite.svg +0 -1
package/lib/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@rainte/js",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.umd.cjs",
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"typings": "dist/types/lib/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dev": "vite",
|
|
10
|
-
"build": "vite build && tsc",
|
|
11
|
-
"release": "npm version patch && npm publish --access public --registry=https://registry.npmjs.org",
|
|
12
|
-
"preview": "vite preview"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/jsan": "^3.1.5",
|
|
16
|
-
"@types/node": "^22.13.5",
|
|
17
|
-
"typescript": "^5.7.3",
|
|
18
|
-
"vite": "^6.1.1"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"axios": "^1.7.9",
|
|
22
|
-
"dayjs": "^1.11.13",
|
|
23
|
-
"jsan": "^3.1.14"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@rainte/js",
|
|
3
|
+
"version": "0.0.13",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.umd.cjs",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"typings": "dist/types/lib/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"build": "vite build && tsc",
|
|
11
|
+
"release": "npm version patch && npm publish --access public --registry=https://registry.npmjs.org",
|
|
12
|
+
"preview": "vite preview"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/jsan": "^3.1.5",
|
|
16
|
+
"@types/node": "^22.13.5",
|
|
17
|
+
"typescript": "^5.7.3",
|
|
18
|
+
"vite": "^6.1.1"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"axios": "^1.7.9",
|
|
22
|
+
"dayjs": "^1.11.13",
|
|
23
|
+
"jsan": "^3.1.14"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/http/axios.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Axios from 'axios'
|
|
2
|
-
import
|
|
2
|
+
import { local } from '../storage'
|
|
3
3
|
|
|
4
4
|
export const ACCESS_TOKEN = 'access_token'
|
|
5
5
|
|
|
@@ -15,7 +15,7 @@ export const axios = Axios.create({
|
|
|
15
15
|
|
|
16
16
|
export const tokenRequestInterceptor = () => {
|
|
17
17
|
return axios.interceptors.request.use((config) => {
|
|
18
|
-
const token =
|
|
18
|
+
const token = local.get(ACCESS_TOKEN)
|
|
19
19
|
token && (config.headers.Authorization = `Bearer ${token}`)
|
|
20
20
|
return config
|
|
21
21
|
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import jsan, { Options } from 'jsan'
|
|
2
|
+
|
|
3
|
+
export const stringify = (
|
|
4
|
+
value: unknown = null,
|
|
5
|
+
replacer?: (key: string, value: unknown) => unknown | Array<number | string> | null,
|
|
6
|
+
space?: string | number,
|
|
7
|
+
_options: Options | boolean = true
|
|
8
|
+
) => {
|
|
9
|
+
return jsan.stringify(value, replacer, space, _options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const parse = (text: string, reviver?: (key: string, value: unknown) => unknown) => {
|
|
13
|
+
return jsan.parse(text, reviver)
|
|
14
|
+
}
|
package/src/storage/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as json from '../json'
|
|
2
2
|
|
|
3
3
|
const cache = (storage?: Storage) => {
|
|
4
4
|
return {
|
|
@@ -10,11 +10,10 @@ const cache = (storage?: Storage) => {
|
|
|
10
10
|
},
|
|
11
11
|
get: (key: string, defaultValue: any = null) => {
|
|
12
12
|
const res = storage?.getItem(key)
|
|
13
|
-
return res ?
|
|
13
|
+
return res ? json.parse(res) : defaultValue
|
|
14
14
|
},
|
|
15
15
|
set: (key: string, value: any) => {
|
|
16
|
-
|
|
17
|
-
storage?.setItem(key, serialize)
|
|
16
|
+
storage?.setItem(key, json.stringify(value))
|
|
18
17
|
},
|
|
19
18
|
del: (key: string) => {
|
|
20
19
|
storage?.removeItem(key)
|