jinbi-utils 1.0.0-beta.1

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.
Files changed (72) hide show
  1. package/.babelrc +19 -0
  2. package/.cz-config.js +55 -0
  3. package/.dockerignore +3 -0
  4. package/.editorconfig +12 -0
  5. package/.eslintignore +8 -0
  6. package/.eslintrc.js +54 -0
  7. package/Dockerfile +3 -0
  8. package/README.md +160 -0
  9. package/api-extractor.json +15 -0
  10. package/commitlint.config.js +3 -0
  11. package/dist/index.esm.js +1277 -0
  12. package/dist/index.esm.min.js +15 -0
  13. package/dist/index.umd.js +1348 -0
  14. package/dist/index.umd.min.js +16 -0
  15. package/docs/assets/images/icons.png +0 -0
  16. package/docs/assets/images/icons@2x.png +0 -0
  17. package/docs/assets/images/widgets.png +0 -0
  18. package/docs/assets/images/widgets@2x.png +0 -0
  19. package/docs/assets/js/main.js +1 -0
  20. package/docs/assets/js/search.json +1 -0
  21. package/docs/globals.html +144 -0
  22. package/docs/index.html +147 -0
  23. package/docs/interfaces/file.compressimgqualitycallback.html +212 -0
  24. package/docs/interfaces/file.compressimgscalecallback.html +206 -0
  25. package/docs/interfaces/file.exportbyblobparams.html +294 -0
  26. package/docs/interfaces/file.filesizeobject.html +227 -0
  27. package/docs/interfaces/file.genexportbyblobparams.html +237 -0
  28. package/docs/modules/common.html +188 -0
  29. package/docs/modules/date.html +364 -0
  30. package/docs/modules/file.html +452 -0
  31. package/docs/modules/number.html +356 -0
  32. package/docs/modules/object.html +245 -0
  33. package/docs/modules/print.html +183 -0
  34. package/docs/modules/string.html +352 -0
  35. package/docs/modules/validate.html +389 -0
  36. package/jest.config.js +15 -0
  37. package/package.json +76 -0
  38. package/rollup.config.js +65 -0
  39. package/src/common/index.ts +323 -0
  40. package/src/constant/common.constant.ts +13 -0
  41. package/src/date/index.ts +143 -0
  42. package/src/file/index.ts +296 -0
  43. package/src/http/http.ts +79 -0
  44. package/src/http/httpEnums.ts +61 -0
  45. package/src/index.ts +10 -0
  46. package/src/number/index.ts +190 -0
  47. package/src/object/index.ts +54 -0
  48. package/src/print/index.ts +102 -0
  49. package/src/string/index.ts +111 -0
  50. package/src/validate/index.ts +78 -0
  51. package/src/wecom/wecom.ts +75 -0
  52. package/test/common/index.test.ts +19 -0
  53. package/test/date/index.test.ts +107 -0
  54. package/test/file/index.test.ts +104 -0
  55. package/test/number/index.test.ts +108 -0
  56. package/test/object/index.test.ts +20 -0
  57. package/test/string/index.test.ts +82 -0
  58. package/tsconfig.json +39 -0
  59. package/typedoc.json +9 -0
  60. package/types/common/index.d.ts +47 -0
  61. package/types/constant/common.constant.d.ts +12 -0
  62. package/types/date/index.d.ts +60 -0
  63. package/types/file/index.d.ts +96 -0
  64. package/types/http/http.d.ts +17 -0
  65. package/types/http/httpEnums.d.ts +53 -0
  66. package/types/index.d.ts +10 -0
  67. package/types/number/index.d.ts +62 -0
  68. package/types/object/index.d.ts +25 -0
  69. package/types/print/index.d.ts +11 -0
  70. package/types/string/index.d.ts +53 -0
  71. package/types/validate/index.d.ts +45 -0
  72. package/types/wecom/wecom.d.ts +3 -0
@@ -0,0 +1,108 @@
1
+ import { toThousands, convertCurrency, formatFloat, ceil, floor } from '../../src';
2
+
3
+ describe('toThousands', () => {
4
+ test(`toThousands('') 返回 '-'`, () => {
5
+ expect(toThousands('')).toBe('-');
6
+ })
7
+
8
+ test(`toThousands('', '|') 返回 '|'`, () => {
9
+ expect(toThousands('', '|')).toBe('|');
10
+ })
11
+
12
+ test(`toThousands(123) 返回 '123'`, () => {
13
+ expect(toThousands(123)).toBe('123');
14
+ })
15
+
16
+ test(`toThousands(12323) 返回 '12,323'`, () => {
17
+ expect(toThousands(12323)).toBe('12,323');
18
+ })
19
+
20
+ test(`toThousands('12323.12') 返回 '12,323.12'`, () => {
21
+ expect(toThousands('12323.12')).toBe('12,323.12');
22
+ })
23
+ });
24
+
25
+ describe('convertCurrency', () => {
26
+ test(`convertCurrency() 返回 ''`, () => {
27
+ expect(convertCurrency()).toBe('');
28
+ })
29
+
30
+ test(`convertCurrency('') 返回 ''`, () => {
31
+ expect(convertCurrency('-')).toBe('零元整');
32
+ })
33
+
34
+ test(`convertCurrency(1999999999999999) 返回 ''`, () => {
35
+ const value = '1999999999999999';
36
+ expect(convertCurrency(value)).toBe(value);
37
+ })
38
+
39
+ test(`convertCurrency(0.012) 返回 '壹分贰毫'`, () => {
40
+ expect(convertCurrency('0.012')).toBe('壹分贰毫');
41
+ })
42
+
43
+ test(`convertCurrency(0) 返回 '零元整'`, () => {
44
+ expect(convertCurrency('0')).toBe('零元整');
45
+ })
46
+
47
+ test(`convertCurrency(12.12) 返回 '壹拾贰元壹角贰分'`, () => {
48
+ expect(convertCurrency('12.12')).toBe('壹拾贰元壹角贰分');
49
+ })
50
+
51
+ test(`convertCurrency(1234567809) 返回 '壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰零玖元整'`, () => {
52
+ expect(convertCurrency('1234567809')).toBe('壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰零玖元整');
53
+ })
54
+ });
55
+
56
+ describe('formatFloat', () => {
57
+ test(`formatFloat('NaN') 返回 ''`, () => {
58
+ expect(formatFloat('NaN')).toBe('');
59
+ })
60
+
61
+ test(`formatFloat('1.2345') 返回 '1.23'`, () => {
62
+ expect(formatFloat('1.2345')).toBe('1.23');
63
+ })
64
+
65
+ test(`formatFloat('1.2345') 返回 '1.235'`, () => {
66
+ expect(formatFloat('1.2345', 3)).toBe('1.235');
67
+ })
68
+
69
+ test(`formatFloat('1', 3) 返回 '1.000'`, () => {
70
+ expect(formatFloat('1', 3)).toBe('1.000');
71
+ })
72
+ });
73
+
74
+ describe('ceil', () => {
75
+ test(`ceil('') 返回 ''`, () => {
76
+ expect(ceil('')).toBe('');
77
+ })
78
+
79
+ test(`ceil('1.23') 返回 2`, () => {
80
+ expect(ceil('1.23')).toBe(2);
81
+ })
82
+
83
+ test(`ceil('1.234', 2) 返回 1.24`, () => {
84
+ expect(ceil('1.234', 2)).toBe(1.24);
85
+ })
86
+
87
+ test(`ceil('1.230', 2) 返回 1.23`, () => {
88
+ expect(ceil('1.230', 2)).toBe(1.23);
89
+ })
90
+ });
91
+
92
+ describe('floor', () => {
93
+ test(`floor('') 返回 ''`, () => {
94
+ expect(floor('')).toBe('');
95
+ })
96
+
97
+ test(`floor('1.23') 返回 1`, () => {
98
+ expect(floor('1.23')).toBe(1);
99
+ })
100
+
101
+ test(`floor('1.234', 2) 返回 1.23`, () => {
102
+ expect(floor('1.234', 2)).toBe(1.23);
103
+ })
104
+
105
+ test(`floor('1.230', 2) 返回 1.23`, () => {
106
+ expect(floor('1.230', 2)).toBe(1.23);
107
+ })
108
+ });
@@ -0,0 +1,20 @@
1
+ import { deepEqual } from '../../src';
2
+
3
+
4
+ describe('deepEqual', () => {
5
+ test(`deepEqual(null, null) 返回 true`, () => {
6
+ expect(deepEqual(null, null)).toBe(true);
7
+ })
8
+
9
+ test(`deepEqual({}, null) 返回 false`, () => {
10
+ expect(deepEqual({}, null)).toBe(false);
11
+ })
12
+
13
+ test(`deepEqual({a: 10}, {a: 10}) 返回 true`, () => {
14
+ expect(deepEqual({a: 10}, {a: 10})).toBe(true);
15
+ })
16
+
17
+ test(`deepEqual({a: 10}, {a: 10, b: 20}) 返回 false`, () => {
18
+ expect(deepEqual({a: 10}, {a: 10, b: 20})).toBe(false);
19
+ })
20
+ });
@@ -0,0 +1,82 @@
1
+ import { formatEmptyValue, formatPhone, formatPhoneHide, formatBank, generateEnglishLetters } from '../../src';
2
+
3
+ describe('formatEmptyValue', () => {
4
+ test(`formatEmptyValue('') 返回 `, () => {
5
+ expect(formatEmptyValue('')).toBe('-');
6
+ })
7
+
8
+ test(`formatEmptyValue('123') 返回 123`, () => {
9
+ expect(formatEmptyValue('123')).toBe('123');
10
+ })
11
+
12
+ test(`formatEmptyValue(null) 返回 '-'`, () => {
13
+ expect(formatEmptyValue(null)).toBe('-');
14
+ })
15
+
16
+ test(`formatEmptyValue(null, ' ') 返回 ' '`, () => {
17
+ expect(formatEmptyValue(null, ' ')).toBe(' ');
18
+ })
19
+ });
20
+
21
+ describe('formatPhone', () => {
22
+ test(`formatPhone('') 返回 `, () => {
23
+ expect(formatPhone('')).toBe('-');
24
+ })
25
+
26
+ test(`formatPhone('', '-', ' ') 返回 ' '`, () => {
27
+ expect(formatPhone('', '-', ' ')).toBe(' ');
28
+ })
29
+
30
+ test('formatPhone(123) 返回 123', () => {
31
+ expect(formatPhone('123')).toBe('123');
32
+ })
33
+
34
+ test(`formatPhone(18211572781) 返回 '182 1157 2781'`, () => {
35
+ expect(formatPhone(18211572781)).toBe('182 1157 2781');
36
+ })
37
+
38
+ test(`formatPhone('18211572781', '-') 放回 '182-1157-2781'`, () => {
39
+ expect(formatPhone('18211572781', '-')).toBe('182-1157-2781');
40
+ })
41
+ });
42
+
43
+ describe('formatPhoneHide', () => {
44
+ test(`formatPhoneHide('') 返回 ''`, () => {
45
+ expect(formatPhoneHide('')).toBe('');
46
+ })
47
+
48
+ test('formatPhoneHide(123) 返回 123', () => {
49
+ expect(formatPhoneHide('123')).toBe('123');
50
+ })
51
+
52
+ test(`formatPhoneHide(18211572781) 返回 '182****2781'`, () => {
53
+ expect(formatPhoneHide(18211572781)).toBe('182****2781');
54
+ })
55
+
56
+ test(`formatPhoneHide('18211572781', '-') 放回 '182****2781'`, () => {
57
+ expect(formatPhoneHide('18211572781', '-')).toBe('182****2781');
58
+ })
59
+ });
60
+
61
+ describe('formatBank', () => {
62
+ test(`formatBank('') 返回 ''`, () => {
63
+ expect(formatBank('')).toBe('');
64
+ })
65
+
66
+ test(`formatBank('', '-') 返回 '-'`, () => {
67
+ expect(formatBank('', '-')).toBe('-');
68
+ })
69
+
70
+ test(`formatBank(6282356862823568123) 返回 '6282 3568 6282 3568 123'`, () => {
71
+ expect(formatBank('6282356862823568123')).toBe('6282 3568 6282 3568 123');
72
+ })
73
+ });
74
+
75
+
76
+ describe('generateEnglishLetters', () => {
77
+ test(`generateEnglishLetters() 返回 ['A', ..., 'Z']`, () => {
78
+ expect(generateEnglishLetters()).toContain('A');
79
+ expect(generateEnglishLetters()).toContain('Z');
80
+ expect(generateEnglishLetters()).toHaveLength(26);
81
+ })
82
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "es6",
5
+ "lib": ["es6", "dom", "es2015.collection"],
6
+ "removeComments": false,
7
+ "preserveConstEnums": true,
8
+ "moduleResolution": "node",
9
+ "experimentalDecorators": true,
10
+ "noImplicitAny": false,
11
+ "allowSyntheticDefaultImports": true,
12
+ "declaration": true,
13
+ "declarationDir": "./types",
14
+ "noUnusedLocals": true,
15
+ "noUnusedParameters": true,
16
+ "strictNullChecks": true,
17
+ "sourceMap": true,
18
+ "baseUrl": ".",
19
+ "rootDir": "./src/",
20
+ "jsx": "preserve",
21
+ "allowJs": true,
22
+ "resolveJsonModule": true,
23
+ "typeRoots": [
24
+ "node_modules/@types",
25
+ "global.d.ts"
26
+ ],
27
+ "paths": {
28
+ "@/*": ["./src/*"]
29
+ },
30
+ },
31
+ "include": [
32
+ "src"
33
+ ],
34
+ "exclude": [
35
+ "node_modules",
36
+ "dist"
37
+ ],
38
+ "compileOnSave": true
39
+ }
package/typedoc.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "excludeNotExported": true,
3
+ "mode": "modules",
4
+ "out": "docs",
5
+ "inputFiles": ["./src"],
6
+ "exclude": [
7
+ "src/index.ts"
8
+ ]
9
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 通用函数
3
+ * @packageDocumentation
4
+ * @module Common
5
+ * @preferred
6
+ */
7
+ import { IFromType } from "@/constant/common.constant";
8
+ /**
9
+ * 判断val 是否是空值
10
+ #### 使用说明
11
+ ```
12
+ isEmpty('') 返回 true
13
+ isEmpty(null) 返回 true
14
+ isEmpty(undefined) 返回 true
15
+ isEmpty(12323) 返回 false
16
+ ```
17
+ */
18
+ export declare function isEmpty(val: any): boolean;
19
+ export declare const clearLoginData: () => void;
20
+ export declare const getQueryString: (url: string, queryKey: string) => string;
21
+ export declare const getQueryVariable: (variable: any) => string | false;
22
+ export declare const getWecomToken: () => string | null;
23
+ export declare const getDeviceType: () => IFromType;
24
+ export declare const getFromType: (res: IFromType) => string;
25
+ export declare function randomString(e: any): string;
26
+ export declare const getCookie: (cookieName: any) => string;
27
+ export declare const buildUUID: () => string;
28
+ export declare const getTicket: () => string | null;
29
+ export declare const setTicket: (jsapiTicket: any) => void;
30
+ export declare const removeTicket: () => void;
31
+ export declare const formateTimestamp: (timestamp: number | null, type?: string) => string;
32
+ export declare const convertBase64UrlToBlob: (urlData: any) => Blob;
33
+ export declare const getEnvironment: () => "com-wx-mobile" | "com-wx-pc" | "wx-mobile" | "wx-pc" | "other";
34
+ export declare const getIsComWx: () => boolean;
35
+ export declare const getIsDevelopment: () => boolean;
36
+ export declare const filterRepeat: (arr: any[], fieldName: string) => any[];
37
+ export declare const base64ToBlob: (base64: any) => Blob;
38
+ export declare const base64ToFile: (base64: any, fileName: any) => File;
39
+ export declare const isImage: (type: string) => boolean;
40
+ export declare const getFileData: (optionName: string) => {
41
+ name: string;
42
+ url: string;
43
+ };
44
+ export declare const validateTwoDecimal: (v: number | string) => boolean;
45
+ export declare const uuid: (len: any, radix: any) => string;
46
+ export declare const getToken: (cacheType: string, key?: string) => string;
47
+ export declare const removeToken: (cacheType: string, key?: string) => void;
@@ -0,0 +1,12 @@
1
+ export interface IFromType {
2
+ isWxWork: boolean;
3
+ isWeixin: boolean;
4
+ isMobileScreen: boolean;
5
+ isMobileAny: boolean;
6
+ }
7
+ export declare const fromTypeMap: {
8
+ isWxWork: string;
9
+ isWeixin: string;
10
+ isMobile: string;
11
+ isMobileAny: string;
12
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * 解决ios不支持 new Date('2020-02-02')问题
3
+ #### 使用说明
4
+ ```
5
+ compatibleDate('2020-03-04') 返回 2020/03/04
6
+ compatibleDate(Date.now()) 返回 Date.now()
7
+ compatibleDate(new Date()) 返回 new Date()
8
+ ```
9
+ */
10
+ export declare function compatibleDate(date: string | number | Date): string | number | Date;
11
+ /**
12
+ * 调用原生 new Date 返回 Date实例 解决ios不支持 yyyy-MM-dd HH:mm:ss 格式new Date
13
+ #### 使用说明
14
+ ```
15
+ newDate() 返回 new Date()
16
+ newDate('2020-03-04') 返回 new Date('2020-03-04')
17
+ ```
18
+ */
19
+ export declare function newDate(date?: string | number | Date): Date;
20
+ /**
21
+ * 格式化时间
22
+ #### 使用说明
23
+ ```
24
+ formatTime() 返回 yyyy-MM-dd HH:mm:ss 格式的当前时间
25
+ formatTime('2018-02-02 00:00:00') 返回 2018-02-02 00:00:00
26
+ formatTime('2018-02-02', 'yyyy/MM/dd') 返回 2018/02/02
27
+ formatTime('2018-02-02 23:50:50', 'yyyy/MM/dd HH:mm:ss') 返回 2018/02/02 23:50:50
28
+ formatTime('2018-02-02 23:50:50', 'MM/dd HH:mm:ss') 返回 02/02 23:50:50
29
+ formatTime(new Date('2018-02-02 23:50:50') + 200, 'yyyy/MM/dd HH:mm:ss S') 返回 2018/02/02 23:50:50 200
30
+ ```
31
+ */
32
+ export declare function formatTime(date?: string | number | Date, fmt?: string): string;
33
+ /**
34
+ * 格式化相对时间
35
+ #### 使用说明
36
+ ```
37
+ fromNow('') 返回 -
38
+ fromNow(Date.now() - 2000) 返回 刚刚
39
+ fromNow(now - 3420 * 1000) 返回 58分钟前面
40
+ fromNow(now - 3600 * 1000 * 3) 返回 3小时前
41
+ fromNow(now - 3600 * 1000 * 24 * 1.5) 返回 1天前
42
+ fromNow(now - day5) 返回 当前时间的5天前日期 格式 yyyy年MM月dd日 HH时mm分ss秒
43
+ fromNow(Date.now() + 2000) 返回 Date.now() + 2000
44
+ fromNow('', '', 'defaultValue') 等于 defaultValue
45
+ ```
46
+ */
47
+ export declare function fromNow(time: Date | string | number, fmt?: string, defaultValue?: string): string | number | Date;
48
+ /**
49
+ * 增加日期天数
50
+ #### 使用说明
51
+ ```
52
+ addDays('') 返回 -
53
+ addDays('2018-02-02') 返回 2018-02-02
54
+ addDays('2018-02-02', 2) 返回 2018-02-04
55
+ addDays('2018-02-02', 2, 'yyyy/MM/dd') 返回 2018/02/04
56
+ addDays(new Date('2020-03-04'), 2, 'yyyy/MM/dd') 返回 2020/03/06
57
+ addDays(Date.now(), 2, 'yyyy/MM/dd') 返回 今天 + 2天
58
+ ```
59
+ */
60
+ export declare function addDays(date: Date | string | number, days?: string | number, fmt?: string): string;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * 文件处理相关
3
+ * @packageDocumentation
4
+ * @module File
5
+ * @preferred
6
+ */
7
+ export declare type FileSizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB';
8
+ export interface FileSizeObject {
9
+ size: number;
10
+ unit: FileSizeUnit;
11
+ }
12
+ /**
13
+ * 计算文件大小
14
+ #### 使用说明
15
+ ```
16
+ calcFileSize(100) 返回 { size: 100, unit: 'B' }
17
+ calcFileSize(1024) 返回 { size: 1, unit: 'KB' }
18
+ calcFileSize(1024, 'KB') 返回 { size: 1, unit: 'MB' }
19
+ calcFileSize(1126.4, 'mb') 返回 { size: 1.1, unit: 'GB' }
20
+ calcFileSize(Math.pow(1024, 2), 'kb') 返回 { size: 1, unit: 'GB' }
21
+ ```
22
+ * @param size 单位 k
23
+ * @returns number
24
+ */
25
+ export declare function calcFileSize(size: number, unit?: FileSizeUnit): FileSizeObject;
26
+ /**
27
+ * 文件大小转换
28
+ #### 使用说明
29
+ ```
30
+ fileSizeFormat('') 返回 -
31
+ fileSizeFormat('1024') 返回 1KB
32
+ fileSizeFormat('1024', 'KB') 返回 1MB
33
+ fileSizeFormat('2645', 'B') 返回 ceil(2645 / 1024, 2)MB
34
+ ```
35
+ * @param {string} str 字符串 单位k
36
+ */
37
+ export declare function fileSizeFormat(str: string | number, unit?: FileSizeUnit, defaultValue?: string): string;
38
+ /**
39
+ * base64转换为file
40
+ * dataurl base64图片
41
+ * */
42
+ export declare function dataURLtoBlob(dataurl: string): Blob;
43
+ export declare function blobToDataURL(blob: Blob): any;
44
+ export interface CompressImgScaleCallback {
45
+ (w: number, h: number): number;
46
+ }
47
+ export interface CompressImgQualityCallback {
48
+ (fileSize: number, scale: number, w: number, h: number): number;
49
+ }
50
+ /**
51
+ * 压缩图片方法
52
+ * @param file 图片
53
+ * @param scaleCallback 宽高 压缩规则
54
+ * @param qualityCallback 质量 压缩规则
55
+ */
56
+ export declare function compressImg(file: File, scaleCallback?: CompressImgScaleCallback, qualityCallback?: CompressImgQualityCallback): Promise<Blob>;
57
+ export declare type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
58
+ export interface ExportByBlobParams {
59
+ /**
60
+ * 请求方式
61
+ */
62
+ method?: Method;
63
+ /**
64
+ * 接口地址
65
+ */
66
+ url: string;
67
+ /**
68
+ * post接口参数
69
+ */
70
+ data?: any;
71
+ /**
72
+ * get接口参数
73
+ */
74
+ params?: any;
75
+ /**
76
+ * 导出的文件名称
77
+ */
78
+ filename?: string;
79
+ }
80
+ export interface GenExportByBlobParams {
81
+ /**
82
+ * axios 请求函数
83
+ */
84
+ axiosRequest: any;
85
+ /**
86
+ * 不使用 withCredentials 域名
87
+ */
88
+ notWithCredentials?: string[];
89
+ }
90
+ /**
91
+ * 生成导出函数
92
+ */
93
+ export declare function genExportByBlob({ axiosRequest, notWithCredentials, }: {
94
+ axiosRequest: any;
95
+ notWithCredentials?: never[] | undefined;
96
+ }): (config: ExportByBlobParams) => Promise<unknown>;
@@ -0,0 +1,17 @@
1
+ import { AxiosInstance } from "axios";
2
+ interface IHttp {
3
+ cacheType: 'localStorage' | 'sessionStorage' | 'both';
4
+ currentMode: string;
5
+ errorCb?: (error: any) => void;
6
+ getTokenCb?: () => void;
7
+ tokenKey?: 'token';
8
+ }
9
+ /**
10
+ * @param cacheType localStorage | sessionStorage | both
11
+ * @param currentMode local | dev | test | prod 等自定义mode
12
+ * @param errorCb 错误回调
13
+ * @param getTokenCb 获取token的回调
14
+ * @param tokenKey
15
+ * */
16
+ export declare const http: ({ cacheType, currentMode, errorCb, getTokenCb, tokenKey }: IHttp) => AxiosInstance;
17
+ export {};
@@ -0,0 +1,53 @@
1
+ export declare const httpEnum: {
2
+ HTTP_STATUS: {
3
+ TEMP_RESPOND: {
4
+ Continue: number;
5
+ SwitchingProtocal: number;
6
+ };
7
+ SUCCESS: {
8
+ Ok: number;
9
+ Created: number;
10
+ Accepted: number;
11
+ NoAuthoritativeInformation: number;
12
+ NoContent: number;
13
+ ResetContent: number;
14
+ ParticalContent: number;
15
+ };
16
+ REDIRECT: {
17
+ MultipleChoice: number;
18
+ MovedPermanently: number;
19
+ Found: number;
20
+ SeeOther: number;
21
+ NotModified: number;
22
+ TemporaryRedirect: number;
23
+ PermanentRedirect: number;
24
+ };
25
+ REQUEST_ERROR: {
26
+ BadRequest: number;
27
+ UnAuthorized: number;
28
+ Forbidden: number;
29
+ NotFound: number;
30
+ MethodNotAllowed: number;
31
+ NotAccepted: number;
32
+ ProxyAuthorizationRequired: number;
33
+ RequestTimeout: number;
34
+ UpgradeRequired: number;
35
+ TokenUnAuthorized: number;
36
+ };
37
+ SERVER_ERROR: {
38
+ InternalServerError: number;
39
+ BadGateway: number;
40
+ ServiceUnavailable: number;
41
+ GateTimeout: number;
42
+ HttpVersionNotSupported: number;
43
+ };
44
+ };
45
+ CODES: {
46
+ Success: string;
47
+ UnAuthorized: string;
48
+ UnAuthorizedPhone: string;
49
+ UnAuthorizedWecom: string;
50
+ UnAuthorizedHavePhone: string;
51
+ };
52
+ ERR_CODE_WHITE_LIST: never[];
53
+ };
@@ -0,0 +1,10 @@
1
+ export * from './common';
2
+ export * from './date';
3
+ export * from './file';
4
+ export * from './object';
5
+ export * from './print';
6
+ export * from './validate';
7
+ export * from './number';
8
+ export * from './string';
9
+ export * from './http/httpEnums';
10
+ export * from './http/http';
@@ -0,0 +1,62 @@
1
+ /**
2
+ * number处理相关
3
+ * @packageDocumentation
4
+ * @module Number
5
+ * @preferred
6
+ */
7
+ /**
8
+ * 千分位格式化
9
+ #### 使用说明
10
+ ```
11
+ toThousands(1) => 1
12
+ toThousands(12345) => 12,345
13
+ toThousands('12323.12') 返回 '12,323.12'
14
+ ```
15
+ */
16
+ export declare function toThousands(num: number | string, defaultValue?: string): string;
17
+ /**
18
+ * 阿拉伯数组转中文数字
19
+ #### 使用说明
20
+ ```
21
+ convertCurrency(0) 返回 '壹拾贰元壹角贰分'
22
+ convertCurrency(1234567809) 返回 '壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰零玖元整'
23
+ ```
24
+ * @param {number} money 金额
25
+ */
26
+ export declare function convertCurrency(money?: string): string;
27
+ /**
28
+ * 格式化小数位
29
+ #### 使用说明
30
+ ```
31
+ formatFloat('1.2345') 返回 '1.23'
32
+ formatFloat('1.2345', 3) 返回 '1.235'
33
+ formatFloat('1', 3) 返回 '1.000'
34
+ ```
35
+ * @param {*} val 小数
36
+ * @param {number} [pos=2] 保留的小数位
37
+ */
38
+ export declare function formatFloat(val: string | number, pos?: number): string;
39
+ /**
40
+ * 向上取整
41
+ #### 使用说明
42
+ ```
43
+ ceil('1.23') 返回 2
44
+ ceil('1.234', 2) 返回 1.24
45
+ ceil('1.230', 2) 返回 1.23
46
+ ```
47
+ * @param {*} val
48
+ * @param {number} [pos=2] 保留的小数位
49
+ */
50
+ export declare function ceil(val: string | number, pos?: number): string | number;
51
+ /**
52
+ * 向下取整
53
+ #### 使用说明
54
+ ```
55
+ floor('1.23') 返回 1
56
+ floor('1.234', 2) 返回 1.23
57
+ floor('1.230', 2) 返回 1.23
58
+ ```
59
+ * @param {*} val
60
+ * @param {number} [pos=2] 保留的小数位
61
+ */
62
+ export declare function floor(val: string | number, pos?: number): string | number;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * object处理相关
3
+ * @packageDocumentation
4
+ * @module Object
5
+ * @preferred
6
+ */
7
+ /**
8
+ * 比较两者的值是否相等
9
+ #### 使用说明
10
+ ```
11
+ deepEqual({a: 10}, {a: 10}) 返回 true
12
+ deepEqual({a: 10}, {a: 10, b: 20}) 返回 false
13
+ ```
14
+ * @param {*} x 用来比较的值
15
+ * @param {*} y 另一个用来比较的值
16
+ */
17
+ export declare function deepEqual(x: any, y: any): any;
18
+ /**
19
+ * 查找树结构节点路径
20
+ * @param {*} nodeValue 节点值
21
+ * @param {string} nodeKey 节点键
22
+ * @param {Array} treeArray 树数据
23
+ * @param {string} children 子集键
24
+ */
25
+ export declare function findNodePath(nodeValue: any, nodeKey: any, treeArray: any, childrenKey: any): any[] | undefined;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * print处理相关
3
+ * @packageDocumentation
4
+ * @module Print
5
+ * @preferred
6
+ */
7
+ /**
8
+ * 打印指定 HTML
9
+ * @param {*} html
10
+ */
11
+ export default function printHtml(html: any): void;