@rainte/js 0.0.55 → 0.0.58
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/dist/index.js +4708 -5958
- package/dist/index.umd.cjs +13 -15
- package/dist/types/array/index.d.ts +31 -1
- package/dist/types/blob/index.d.ts +50 -0
- package/dist/types/date/index.d.ts +29 -9
- package/dist/types/hash/index.d.ts +37 -1
- package/dist/types/http/axios.d.ts +33 -0
- package/dist/types/http/index.d.ts +41 -5
- package/dist/types/json/index.d.ts +25 -3
- package/dist/types/lib.d.ts +0 -2
- package/dist/types/system/index.d.ts +27 -3
- package/dist/types/url/index.d.ts +35 -2
- package/package.json +6 -8
- package/dist/types/database/index.d.ts +0 -14
- package/dist/types/storage/index.d.ts +0 -13
|
@@ -1,2 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将树形结构扁平化为一维数组(深度优先,父节点在前)。
|
|
3
|
+
*
|
|
4
|
+
* @param tree 树形数组
|
|
5
|
+
* @param prop 子节点字段名,默认 'children'
|
|
6
|
+
* @returns 扁平化后的数组,元素类型为去掉子节点字段后的 T
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const tree = [
|
|
10
|
+
* { value: 1, children: [{ value: 2 }, { value: 3, children: [{ value: 4 }] }] },
|
|
11
|
+
* { value: 5 },
|
|
12
|
+
* ]
|
|
13
|
+
* flattenTree(tree)
|
|
14
|
+
* // => [{ value: 1 }, { value: 2 }, { value: 3 }, { value: 4 }, { value: 5 }]
|
|
15
|
+
*/
|
|
1
16
|
export declare const flattenTree: <T, K extends string = 'children'>(tree: T[], prop?: K) => Omit<T, K>[];
|
|
2
|
-
|
|
17
|
+
/**
|
|
18
|
+
* 在数组中按指定字段查找第一个匹配项。
|
|
19
|
+
* 若传入的 value 是数组,则取其第一个元素作为目标值。
|
|
20
|
+
*
|
|
21
|
+
* @param list 待查找的数组
|
|
22
|
+
* @param value 目标值(或值数组,取第一个)
|
|
23
|
+
* @param prop 用于比较的字段名,默认 'value';支持点路径,如 'meta.id'
|
|
24
|
+
* @returns 匹配项,未找到返回 undefined
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* findByValue([{ value: 1 }, { value: 2 }], 2) // => { value: 2 }
|
|
28
|
+
* findByValue([{ value: 1 }, { value: 2 }], [2, 3]) // => { value: 2 }
|
|
29
|
+
* findByValue([{ id: 1 }], 1, 'id') // => { id: 1 }
|
|
30
|
+
* findByValue([{ meta: { id: 1 } }], 1, 'meta.id') // => { meta: { id: 1 } }
|
|
31
|
+
*/
|
|
32
|
+
export declare const findByValue: <T = unknown>(list: T[], value: unknown, prop?: string) => T | undefined;
|
|
@@ -1,3 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将 Blob 转为 base64 Data URL 字符串。
|
|
3
|
+
*
|
|
4
|
+
* @param blob 待转换的 Blob
|
|
5
|
+
* @returns Promise<string>,resolve 为 data URL(如 "data:image/png;base64,...")
|
|
6
|
+
* @throws FileReader 读取失败时 reject 对应的 DOMException
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const dataUrl = await toBase64(new Blob(['hi'], { type: 'text/plain' }))
|
|
10
|
+
*/
|
|
1
11
|
export declare const toBase64: (blob: Blob) => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* 将 base64 字符串(或 Data URL)转为 Blob。
|
|
14
|
+
* 支持三种输入:
|
|
15
|
+
* - 完整 Data URL:`data:[<mime>][;base64],<payload>`
|
|
16
|
+
* - 裸 base64 前缀:`[<mime>];base64,<payload>`
|
|
17
|
+
* - 纯 base64 字符串:`<payload>`(按 base64 解码,mime 为空)
|
|
18
|
+
*
|
|
19
|
+
* @param base64 base64 字符串或 Data URL
|
|
20
|
+
* @param options 可选的 BlobPropertyBag,其 type 优先级高于从字符串解析出的 mime
|
|
21
|
+
* @returns Blob
|
|
22
|
+
* @throws payload 非法 base64 时 atob 抛 DOMException
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* toBlob('data:text/plain;base64,aGk=') // Blob { type: 'text/plain', ... }
|
|
26
|
+
* toBlob('aGk=', { type: 'text/plain' }) // Blob { type: 'text/plain', ... }
|
|
27
|
+
*/
|
|
2
28
|
export declare const toBlob: (base64: string, options?: BlobPropertyBag) => Blob;
|
|
29
|
+
/**
|
|
30
|
+
* 将 base64 字符串(或 Data URL)转为 File。
|
|
31
|
+
* 复用 toBlob 的解析逻辑,支持与 toBlob 相同的三种输入。
|
|
32
|
+
*
|
|
33
|
+
* @param base64 base64 字符串或 Data URL
|
|
34
|
+
* @param filename 文件名(File.name)
|
|
35
|
+
* @param options 可选的 FilePropertyBag,其 type 优先级高于从字符串解析出的 mime
|
|
36
|
+
* @returns File
|
|
37
|
+
* @throws payload 非法 base64 时 atob 抛 DOMException
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* toFile('data:image/png;base64,iVBORw0KG...', 'a.png')
|
|
41
|
+
* toFile('aGk=', 'a.txt', { type: 'text/plain' })
|
|
42
|
+
*/
|
|
43
|
+
export declare const toFile: (base64: string, filename: string, options?: FilePropertyBag) => File;
|
|
44
|
+
/**
|
|
45
|
+
* 触发浏览器下载。
|
|
46
|
+
*
|
|
47
|
+
* @param filename 下载文件名
|
|
48
|
+
* @param obj Blob 或 MediaSource
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* download('a.txt', new Blob(['hello'], { type: 'text/plain' }))
|
|
52
|
+
*/
|
|
3
53
|
export declare const download: (filename: string, obj: Blob | MediaSource) => void;
|
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
/**
|
|
3
|
+
* 常用日期时间格式常量(Luxon format token)。
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* now().toFormat(FORMAT.DATETIME) // '2026-11-08 12:34:56'
|
|
7
|
+
*/
|
|
3
8
|
export declare const FORMAT: {
|
|
4
|
-
DATETIME:
|
|
5
|
-
DATE:
|
|
6
|
-
TIME:
|
|
7
|
-
YEAR:
|
|
8
|
-
MONTH:
|
|
9
|
-
HOUR:
|
|
10
|
-
MINUTE:
|
|
9
|
+
readonly DATETIME: 'yyyy-MM-dd HH:mm:ss';
|
|
10
|
+
readonly DATE: 'yyyy-MM-dd';
|
|
11
|
+
readonly TIME: 'HH:mm:ss';
|
|
12
|
+
readonly YEAR: 'yyyy';
|
|
13
|
+
readonly MONTH: 'yyyy-MM';
|
|
14
|
+
readonly HOUR: 'yyyy-MM-dd HH';
|
|
15
|
+
readonly MINUTE: 'yyyy-MM-dd HH:mm';
|
|
11
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* 常用时区常量(IANA 时区名)。
|
|
19
|
+
*/
|
|
20
|
+
export declare const ZONE: {
|
|
21
|
+
readonly CN: 'Asia/Shanghai';
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 获取当前时间,并设置为中国时区(Asia/Shanghai)。
|
|
25
|
+
*
|
|
26
|
+
* @returns 处于 Asia/Shanghai 时区的当前 DateTime
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* now().toFormat(FORMAT.DATETIME) // '2026-11-08 12:34:56'(上海时间)
|
|
30
|
+
*/
|
|
31
|
+
export declare const now: () => DateTime;
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 计算 SHA-256 摘要,返回小写十六进制字符串(64 字符)。
|
|
3
|
+
*
|
|
4
|
+
* @param text 待哈希的字符串
|
|
5
|
+
* @returns Promise<string>,64 位小写十六进制摘要
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* await SHA256('hello')
|
|
9
|
+
* await SHA256(JSON.stringify({ a: 1 }))
|
|
10
|
+
*/
|
|
11
|
+
export declare function SHA256(text: string): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* 对任意值先做原生 JSON 序列化,再计算 SHA-256 摘要。
|
|
14
|
+
*
|
|
15
|
+
* @param input 待哈希内容,必须是 JSON 可表达的值
|
|
16
|
+
* @returns Promise<string>,64 位小写十六进制摘要
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* await SHA256Json({ a: 1 }) // 等价于 SHA256('{"a":1}')
|
|
20
|
+
*/
|
|
21
|
+
export declare const SHA256Json: (input: unknown) => Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* 生成一个 32 位无符号随机整数([0, 2^32 - 1]),使用 crypto.getRandomValues。
|
|
24
|
+
*
|
|
25
|
+
* @returns 随机整数
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* random() // 例如 3735928559
|
|
29
|
+
*/
|
|
2
30
|
export declare const random: () => number;
|
|
31
|
+
/**
|
|
32
|
+
* 生成一个 22 位 Base62 字符串 ID,随机熵与 UUID v4 相同(122 位)。
|
|
33
|
+
*
|
|
34
|
+
* @returns 22 位 Base62 字符串
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* id() // 例如 '4kX9mP2nQ7rT1sV5wY8zA3'
|
|
38
|
+
*/
|
|
3
39
|
export declare const id: () => string;
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
export declare const ACCESS_TOKEN = "access_token";
|
|
2
|
+
/**
|
|
3
|
+
* 从后端返回体中提取错误信息,兼容 `message` / `msg` 字段。
|
|
4
|
+
*
|
|
5
|
+
* @param data 响应体或错误对象
|
|
6
|
+
* @param text 兜底文案
|
|
7
|
+
* @returns 错误信息字符串
|
|
8
|
+
*/
|
|
2
9
|
export declare const message: <T = string>(data: any, text?: string) => T;
|
|
3
10
|
export declare const axios: import("axios").AxiosInstance;
|
|
11
|
+
/**
|
|
12
|
+
* 请求拦截器:自动从本地存储读取 token,注入 Authorization 头。
|
|
13
|
+
*
|
|
14
|
+
* @returns 拦截器 id,可用于 `axios.interceptors.request.eject`
|
|
15
|
+
*/
|
|
4
16
|
export declare const tokenRequestInterceptor: () => number;
|
|
17
|
+
/** 响应拦截器透传的响应体类型 */
|
|
18
|
+
export type ResponseData<T = unknown> = {
|
|
19
|
+
data: T;
|
|
20
|
+
} & Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* 响应拦截器:
|
|
23
|
+
* - 2xx:若响应体是 `{ data: ... }` 信封则解包,否则原样返回;
|
|
24
|
+
* - 非 2xx:构造 Error 交给 onRejected 或 reject;
|
|
25
|
+
* - 网络/超时错误:交给 onRejected 或 reject。
|
|
26
|
+
*
|
|
27
|
+
* @param onRejected 可选的统一错误处理函数
|
|
28
|
+
* @returns 拦截器 id,可用于 `axios.interceptors.response.eject`
|
|
29
|
+
*/
|
|
5
30
|
export declare const responseInterceptor: (onRejected?: ((error: any) => any) | null) => number;
|
|
31
|
+
/**
|
|
32
|
+
* 401 重试逻辑:token 刷新期间到达的请求进入队列,刷新成功后统一重放;
|
|
33
|
+
* 刷新失败则队列内所有请求统一 reject。
|
|
34
|
+
*
|
|
35
|
+
* @param error Axios 抛出的错误
|
|
36
|
+
* @param refreshRequest 刷新 token 的函数
|
|
37
|
+
* @returns 重放后的响应,或 reject
|
|
38
|
+
*/
|
|
6
39
|
export declare const retry: (error: any, refreshRequest: () => Promise<unknown>) => Promise<unknown>;
|
|
7
40
|
export default axios;
|
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
import type { AxiosRequestConfig } from 'axios';
|
|
1
|
+
import type { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
2
|
export * from './axios';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* GET 请求。
|
|
5
|
+
*
|
|
6
|
+
* @param url 请求地址
|
|
7
|
+
* @param params 查询参数
|
|
8
|
+
* @returns Axios 响应 Promise
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* get('/api/user', { id: 1 })
|
|
12
|
+
*/
|
|
13
|
+
export declare const get: <T = unknown>(url: string, params?: ObjectProps) => Promise<AxiosResponse<T>>;
|
|
14
|
+
/**
|
|
15
|
+
* POST 请求,默认 `Content-Type: application/json`。
|
|
16
|
+
*
|
|
17
|
+
* @param url 请求地址
|
|
18
|
+
* @param data 请求体
|
|
19
|
+
* @returns Axios 响应 Promise
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* post('/api/user', { name: 'foo' })
|
|
23
|
+
*/
|
|
24
|
+
export declare const post: <T = unknown>(url: string, data?: ObjectProps) => Promise<AxiosResponse<T>>;
|
|
25
|
+
/**
|
|
26
|
+
* 下载请求,强制 `responseType = 'blob'`(除非调用方显式指定了其他值)。
|
|
27
|
+
*
|
|
28
|
+
* @param config 请求配置
|
|
29
|
+
* @returns 响应 Promise,`data` 为 Blob(或调用方指定的其他类型)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const res = await download({ url: '/api/export', method: 'GET' })
|
|
33
|
+
* const blob = res.data as Blob
|
|
34
|
+
*/
|
|
35
|
+
export declare const download: <T = Blob>(config: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
36
|
+
/**
|
|
37
|
+
* 统一请求入口:注入默认 `Content-Type`,透传给 Axios 实例。
|
|
38
|
+
*
|
|
39
|
+
* @param config 请求配置
|
|
40
|
+
* @returns 响应 Promise
|
|
41
|
+
*/
|
|
42
|
+
export declare const request: <T = unknown>(config: AxiosRequestConfig) => Promise<AxiosResponse<T>>;
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 基于 superjson 的 JSON 序列化,支持 Date、RegExp、Map、Set、BigInt、undefined 等
|
|
3
|
+
* 原生 JSON.stringify 会丢失或报错的数据类型。
|
|
4
|
+
*
|
|
5
|
+
* @param value 待序列化的值
|
|
6
|
+
* @returns 序列化后的字符串,结构为 `{"json": ..., "meta": ...}`
|
|
7
|
+
* @throws 值包含不可序列化内容(如函数、DOM 节点、循环引用中 superjson 不支持的部分)时抛错
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* stringify({ a: 1, b: undefined, c: new Date(0) })
|
|
11
|
+
* // => '{"json":{"a":1,"c":"1970-01-01T00:00:00.000Z"},"meta":{"values":{"b":["undefined"],"c":["Date"]}}}'
|
|
12
|
+
*/
|
|
13
|
+
export declare const stringify: (value: unknown) => string;
|
|
14
|
+
/**
|
|
15
|
+
* 基于 superjson 的反序列化,能还原 superjson.stringify 产生的特殊类型。
|
|
16
|
+
*
|
|
17
|
+
* @param text 待解析的字符串
|
|
18
|
+
* @returns 解析后的值,泛型 T 由调用方指定(默认 unknown)
|
|
19
|
+
* @throws 字符串不是合法 JSON 或不是 superjson 信封格式时抛错
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* parse<{ date: Date }>('{"json":{"date":"1970-01-01T00:00:00.000Z"},"meta":{"values":{"date":["Date"]}}}')
|
|
23
|
+
* // => { date: Date(0) }
|
|
24
|
+
*/
|
|
25
|
+
export declare const parse: <T = unknown>(text: string) => T;
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
export * as array from './array';
|
|
2
2
|
export * as blob from './blob';
|
|
3
|
-
export * as database from './database';
|
|
4
3
|
export * as date from './date';
|
|
5
4
|
export * as hash from './hash';
|
|
6
5
|
export * as http from './http';
|
|
7
6
|
export * as json from './json';
|
|
8
|
-
export * as storage from './storage';
|
|
9
7
|
export * as system from './system';
|
|
10
8
|
export * as url from './url';
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 延迟指定毫秒。
|
|
3
|
+
*
|
|
4
|
+
* @param ms 毫秒数,负数按 0 处理
|
|
5
|
+
* @param signal 可选的 AbortSignal,abort 时 Promise 以 AbortError reject
|
|
6
|
+
* @returns Promise<void>,到时 resolve
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* await sleep(1000)
|
|
10
|
+
*
|
|
11
|
+
* const ctrl = new AbortController()
|
|
12
|
+
* setTimeout(() => ctrl.abort(), 100)
|
|
13
|
+
* await sleep(1000, ctrl.signal).catch(() => {})
|
|
14
|
+
*/
|
|
15
|
+
export declare const sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* 抛出错误,用于表达"此处不应继续"。
|
|
18
|
+
*
|
|
19
|
+
* @param message 错误信息
|
|
20
|
+
* @returns 永不返回(类型为 never)
|
|
21
|
+
* @throws 总是抛出 Error
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* function assert(cond: unknown): asserts cond {
|
|
25
|
+
* if (!cond) fail('assertion failed')
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
3
28
|
export declare const fail: (message: string) => never;
|
|
4
|
-
export declare const loadModules: (modules: ObjectProps) => Promise<ObjectProps>;
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 将 query 字符串解析为 URLSearchParams。
|
|
3
|
+
*
|
|
4
|
+
* @param query 待解析的 query 字符串,默认取当前页面 `location.search`
|
|
5
|
+
* @returns URLSearchParams 实例
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* search('?a=1&b=2').get('a') // '1'
|
|
9
|
+
* search().get('a') // 当前页面 URL 中的 a 参数
|
|
10
|
+
*/
|
|
11
|
+
export declare const search: (query?: string) => URLSearchParams;
|
|
12
|
+
/**
|
|
13
|
+
* 将 query 字符串解析为普通对象。
|
|
14
|
+
* 同名参数会合并为数组,单个参数保持字符串。
|
|
15
|
+
*
|
|
16
|
+
* @param query 待解析的 query 字符串,默认取当前页面 `location.search`
|
|
17
|
+
* @returns 键值对对象;无参数时返回空对象
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* params('?a=1&b=2&b=3') // { a: '1', b: ['2', '3'] }
|
|
21
|
+
* params() // 当前页面的 query 对象
|
|
22
|
+
*/
|
|
23
|
+
export declare const params: (query?: string) => ObjectProps;
|
|
24
|
+
/**
|
|
25
|
+
* 打开新窗口/标签页。
|
|
26
|
+
*
|
|
27
|
+
* @param url 目标地址,默认 `about:blank`
|
|
28
|
+
* @param target 窗口名,默认 `'_blank'`
|
|
29
|
+
* @param features 窗口特性字符串
|
|
30
|
+
* @returns 新窗口的 Window 引用;被浏览器拦截时返回 null
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* open('https://example.com')
|
|
34
|
+
* open('/detail/1', '_self')
|
|
35
|
+
*/
|
|
3
36
|
export declare const open: (url?: string | URL, target?: string, features?: string) => Window | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainte/js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.58",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -36,18 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"axios": "^1.21.0",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"jsan": "^3.1.14"
|
|
39
|
+
"luxon": "^3.7.2",
|
|
40
|
+
"superjson": "^2.2.6"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@types/
|
|
43
|
+
"@types/luxon": "^3.7.6",
|
|
45
44
|
"@types/node": "^26.6.6",
|
|
46
|
-
"fake-indexeddb": "^6.2.7",
|
|
47
45
|
"happy-dom": "^21.0.4",
|
|
48
|
-
"oxlint": "^1.
|
|
46
|
+
"oxlint": "^1.92.0",
|
|
49
47
|
"typescript": "^7.0.2",
|
|
50
|
-
"vite": "^8.3.
|
|
48
|
+
"vite": "^8.3.6",
|
|
51
49
|
"vitest": "^5.1.0"
|
|
52
50
|
}
|
|
53
51
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Dexie, { type Table } from 'dexie';
|
|
2
|
-
export interface DexieRow {
|
|
3
|
-
id?: number;
|
|
4
|
-
key: string;
|
|
5
|
-
value: any;
|
|
6
|
-
}
|
|
7
|
-
export declare class SubDexie extends Dexie {
|
|
8
|
-
rows: Table<DexieRow, number>;
|
|
9
|
-
constructor(name?: string);
|
|
10
|
-
}
|
|
11
|
-
export declare const getDB: (name?: string) => SubDexie;
|
|
12
|
-
export declare const db: SubDexie;
|
|
13
|
-
export declare const get: <T = any>(key: string, raw?: boolean) => Promise<T | undefined>;
|
|
14
|
-
export declare const set: (key: string, value: any) => import("dexie").PromiseExtended<number>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare class Cache {
|
|
2
|
-
private storage?;
|
|
3
|
-
constructor(storage?: Storage);
|
|
4
|
-
getRaw(key: string, defaultValue?: string | null): string | null;
|
|
5
|
-
setRaw(key: string, value: string): void;
|
|
6
|
-
get<T = any>(key: string, defaultValue?: T | null): T | null;
|
|
7
|
-
set(key: string, value: any): void;
|
|
8
|
-
del(key: string): void;
|
|
9
|
-
clear(): void;
|
|
10
|
-
}
|
|
11
|
-
export declare const local: Cache;
|
|
12
|
-
export declare const session: Cache;
|
|
13
|
-
export {};
|