@rainte/js 0.0.11 → 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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Js
1
+ # js
2
2
 
3
3
  ```sh
4
4
  npm config set proxy http://127.0.0.1:1080
package/lib/index.ts CHANGED
@@ -2,4 +2,5 @@ export * as date from '../src/date'
2
2
  export * as fast from '../src/fast'
3
3
  export * as file from '../src/file'
4
4
  export * as http from '../src/http'
5
+ export * as json from '../src/json'
5
6
  export * as storage from '../src/storage'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainte/js",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.umd.cjs",
6
6
  "module": "dist/index.js",
@@ -13,12 +13,12 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/jsan": "^3.1.5",
16
- "@types/node": "^22.7.3",
17
- "typescript": "^5.5.3",
18
- "vite": "^5.4.1"
16
+ "@types/node": "^22.13.5",
17
+ "typescript": "^5.7.3",
18
+ "vite": "^6.1.1"
19
19
  },
20
20
  "dependencies": {
21
- "axios": "^1.7.7",
21
+ "axios": "^1.7.9",
22
22
  "dayjs": "^1.11.13",
23
23
  "jsan": "^3.1.14"
24
24
  }
package/src/http/axios.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Axios from 'axios'
2
- import * as storage from '../storage'
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 = storage.session.get(ACCESS_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/main.ts CHANGED
@@ -18,3 +18,4 @@ document
18
18
  ?.appendChild(document.createElement('ul'))
19
19
  ?.appendChild(make(date.dayjs().format(date.FORMAT.DATETIME)))
20
20
  ?.appendChild(make(fast.find(list, 'value3', '无知')))
21
+ ?.appendChild(make(fast.find(list, 'value0', '无知')))
@@ -1,4 +1,4 @@
1
- import jsan from 'jsan'
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 ? jsan.parse(res) : defaultValue
13
+ return res ? json.parse(res) : defaultValue
14
14
  },
15
15
  set: (key: string, value: any) => {
16
- const serialize = jsan.stringify(value, undefined, undefined, true)
17
- storage?.setItem(key, serialize)
16
+ storage?.setItem(key, json.stringify(value))
18
17
  },
19
18
  del: (key: string) => {
20
19
  storage?.removeItem(key)