@rainte/js 0.0.2 → 0.0.10
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/index.html +1 -1
- package/package.json +2 -2
- package/src/fast/index.ts +2 -2
- package/src/file/index.ts +12 -5
- package/src/http/index.ts +5 -0
- package/dist/index.js +0 -2631
- 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 -2
- package/dist/types/src/http/axios.d.ts +0 -6
- package/dist/types/src/http/index.d.ts +0 -5
- 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/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainte/js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.umd.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"dev": "vite",
|
|
10
10
|
"build": "vite build && tsc",
|
|
11
|
-
"release": "
|
|
11
|
+
"release": "npm version patch && npm publish --access public --registry=https://registry.npmjs.org",
|
|
12
12
|
"preview": "vite preview"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
package/src/fast/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export const find = (list: any[], value: any,
|
|
1
|
+
export const find = (list: any[], value: any, label = '') => {
|
|
2
2
|
return (
|
|
3
3
|
list.find((item: any) => {
|
|
4
4
|
return item.value == (Array.isArray(value) ? value[0] : value)
|
|
5
|
-
})?.label ??
|
|
5
|
+
})?.label ?? label
|
|
6
6
|
)
|
|
7
7
|
}
|
|
8
8
|
|
package/src/file/index.ts
CHANGED
|
@@ -8,11 +8,18 @@ export const toBase64 = (blob: Blob) => {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const toBlob = (base64: string) => {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const bytes = []
|
|
11
|
+
const character = atob(base64.split(',')[1] || base64)
|
|
12
|
+
const bytes = new Uint8Array(character.length)
|
|
14
13
|
for (let i = 0; i < character.length; i++) {
|
|
15
|
-
bytes
|
|
14
|
+
bytes[i] = character.charCodeAt(i)
|
|
16
15
|
}
|
|
17
|
-
return new Blob([
|
|
16
|
+
return new Blob([bytes])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const download = (filename: string, obj: Blob | MediaSource) => {
|
|
20
|
+
const link = document.createElement('a')
|
|
21
|
+
link.href = URL.createObjectURL(obj)
|
|
22
|
+
link.download = filename
|
|
23
|
+
link.click()
|
|
24
|
+
URL.revokeObjectURL(link.href)
|
|
18
25
|
}
|
package/src/http/index.ts
CHANGED
|
@@ -11,6 +11,11 @@ export const post = (url: string, data?: Record<string, any>) => {
|
|
|
11
11
|
return request({ url, method: 'POST', data })
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export const download = (config: AxiosRequestConfig) => {
|
|
15
|
+
config.responseType = config.responseType || 'blob'
|
|
16
|
+
return request(config)
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
export const request = (config: AxiosRequestConfig) => {
|
|
15
20
|
return axios.request(config)
|
|
16
21
|
}
|