@rainte/js 0.0.10 → 0.0.12

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/src/http/index.ts CHANGED
@@ -1,21 +1,21 @@
1
- import { axios } from './axios'
2
- import { AxiosRequestConfig } from 'axios'
3
-
4
- export * from './axios'
5
-
6
- export const get = (url: string, params?: Record<string, any>) => {
7
- return request({ url, method: 'GET', params })
8
- }
9
-
10
- export const post = (url: string, data?: Record<string, any>) => {
11
- return request({ url, method: 'POST', data })
12
- }
13
-
14
- export const download = (config: AxiosRequestConfig) => {
15
- config.responseType = config.responseType || 'blob'
16
- return request(config)
17
- }
18
-
19
- export const request = (config: AxiosRequestConfig) => {
20
- return axios.request(config)
21
- }
1
+ import { axios } from './axios'
2
+ import { AxiosRequestConfig } from 'axios'
3
+
4
+ export * from './axios'
5
+
6
+ export const get = (url: string, params?: Record<string, any>) => {
7
+ return request({ url, method: 'GET', params })
8
+ }
9
+
10
+ export const post = (url: string, data?: Record<string, any>) => {
11
+ return request({ url, method: 'POST', data })
12
+ }
13
+
14
+ export const download = (config: AxiosRequestConfig) => {
15
+ config.responseType = config.responseType || 'blob'
16
+ return request(config)
17
+ }
18
+
19
+ export const request = (config: AxiosRequestConfig) => {
20
+ return axios.request(config)
21
+ }
package/src/main.ts CHANGED
@@ -1,20 +1,21 @@
1
- import * as date from './date'
2
- import * as fast from './fast'
3
-
4
- const make = (content: string, tag: keyof HTMLElementTagNameMap = 'li') => {
5
- const ele = document.createElement(tag)
6
- ele.textContent = content
7
- return ele
8
- }
9
-
10
- const list = [
11
- { label: 'label1', value: 'value1' },
12
- { label: 'label2', value: 'value2' },
13
- { label: 'label3', value: 'value3' }
14
- ]
15
-
16
- document
17
- .querySelector<HTMLDivElement>('#app')
18
- ?.appendChild(document.createElement('ul'))
19
- ?.appendChild(make(date.dayjs().format(date.FORMAT.DATETIME)))
20
- ?.appendChild(make(fast.find(list, 'value3', '无知')))
1
+ import * as date from './date'
2
+ import * as fast from './fast'
3
+
4
+ const make = (content: string, tag: keyof HTMLElementTagNameMap = 'li') => {
5
+ const ele = document.createElement(tag)
6
+ ele.textContent = content
7
+ return ele
8
+ }
9
+
10
+ const list = [
11
+ { label: 'label1', value: 'value1' },
12
+ { label: 'label2', value: 'value2' },
13
+ { label: 'label3', value: 'value3' }
14
+ ]
15
+
16
+ document
17
+ .querySelector<HTMLDivElement>('#app')
18
+ ?.appendChild(document.createElement('ul'))
19
+ ?.appendChild(make(date.dayjs().format(date.FORMAT.DATETIME)))
20
+ ?.appendChild(make(fast.find(list, 'value3', '无知')))
21
+ ?.appendChild(make(fast.find(list, 'value0', '无知')))
@@ -1,29 +1,29 @@
1
- import jsan from 'jsan'
2
-
3
- const cache = (storage?: Storage) => {
4
- return {
5
- getRaw: (key: string, defaultValue: any = null) => {
6
- return storage?.getItem(key) || defaultValue
7
- },
8
- setRaw: (key: string, value: string) => {
9
- storage?.setItem(key, value)
10
- },
11
- get: (key: string, defaultValue: any = null) => {
12
- const res = storage?.getItem(key)
13
- return res ? jsan.parse(res) : defaultValue
14
- },
15
- set: (key: string, value: any) => {
16
- const serialize = jsan.stringify(value, undefined, undefined, true)
17
- storage?.setItem(key, serialize)
18
- },
19
- del: (key: string) => {
20
- storage?.removeItem(key)
21
- },
22
- clear: () => {
23
- storage?.clear()
24
- }
25
- }
26
- }
27
-
28
- export const session = cache(sessionStorage)
29
- export const local = cache(localStorage)
1
+ import jsan from 'jsan'
2
+
3
+ const cache = (storage?: Storage) => {
4
+ return {
5
+ getRaw: (key: string, defaultValue: any = null) => {
6
+ return storage?.getItem(key) || defaultValue
7
+ },
8
+ setRaw: (key: string, value: string) => {
9
+ storage?.setItem(key, value)
10
+ },
11
+ get: (key: string, defaultValue: any = null) => {
12
+ const res = storage?.getItem(key)
13
+ return res ? jsan.parse(res) : defaultValue
14
+ },
15
+ set: (key: string, value: any) => {
16
+ const serialize = jsan.stringify(value, undefined, undefined, true)
17
+ storage?.setItem(key, serialize)
18
+ },
19
+ del: (key: string) => {
20
+ storage?.removeItem(key)
21
+ },
22
+ clear: () => {
23
+ storage?.clear()
24
+ }
25
+ }
26
+ }
27
+
28
+ export const session = cache(sessionStorage)
29
+ export const local = cache(localStorage)
package/src/vite-env.d.ts CHANGED
@@ -1 +1 @@
1
- /// <reference types="vite/client" />
1
+ /// <reference types="vite/client" />
package/tsconfig.json CHANGED
@@ -1,26 +1,26 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "skipLibCheck": true,
8
- "declaration": true, // 自动生成声明文件.
9
- "declarationDir": "dist/types", // 声明文件输出的目录.
10
- "emitDeclarationOnly": true, // 只输出声明文件,不转译ts文件.
11
-
12
- /* Bundler mode */
13
- "moduleResolution": "bundler",
14
- "allowImportingTsExtensions": true,
15
- "isolatedModules": true,
16
- "moduleDetection": "force",
17
- // "noEmit": true,
18
-
19
- /* Linting */
20
- "strict": true,
21
- "noUnusedLocals": true,
22
- "noUnusedParameters": true,
23
- "noFallthroughCasesInSwitch": true
24
- },
25
- "include": ["src", "lib", "vite.config.ts"]
26
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "skipLibCheck": true,
8
+ "declaration": true, // 自动生成声明文件.
9
+ "declarationDir": "dist/types", // 声明文件输出的目录.
10
+ "emitDeclarationOnly": true, // 只输出声明文件,不转译ts文件.
11
+
12
+ /* Bundler mode */
13
+ "moduleResolution": "bundler",
14
+ "allowImportingTsExtensions": true,
15
+ "isolatedModules": true,
16
+ "moduleDetection": "force",
17
+ // "noEmit": true,
18
+
19
+ /* Linting */
20
+ "strict": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "noFallthroughCasesInSwitch": true
24
+ },
25
+ "include": ["src", "lib", "vite.config.ts"]
26
+ }
package/vite.config.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { defineConfig } from 'vite'
2
- import { resolve } from 'path'
3
-
4
- export default defineConfig({
5
- build: {
6
- lib: {
7
- entry: resolve(__dirname, 'lib/index.ts'),
8
- name: '@rainte/js',
9
- fileName: 'index'
10
- }
11
- }
12
- })
1
+ import { defineConfig } from 'vite'
2
+ import { resolve } from 'path'
3
+
4
+ export default defineConfig({
5
+ build: {
6
+ lib: {
7
+ entry: resolve(__dirname, 'lib/index.ts'),
8
+ name: '@rainte/js',
9
+ fileName: 'index'
10
+ }
11
+ }
12
+ })