@haluo/util 2.0.28 → 2.0.29

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 (59) hide show
  1. package/README.md +350 -350
  2. package/dist/index.d.ts +39 -39
  3. package/dist/index.js +43 -43
  4. package/dist/modules/cookie/index.d.ts +27 -27
  5. package/dist/modules/cookie/index.js +49 -49
  6. package/dist/modules/date/index.d.ts +52 -52
  7. package/dist/modules/date/index.js +185 -185
  8. package/dist/modules/dom/index.d.ts +28 -28
  9. package/dist/modules/dom/index.js +55 -55
  10. package/dist/modules/filter/index.d.ts +24 -24
  11. package/dist/modules/filter/index.js +38 -38
  12. package/dist/modules/format/index.d.ts +15 -15
  13. package/dist/modules/format/index.js +16 -16
  14. package/dist/modules/match/index.d.ts +12 -12
  15. package/dist/modules/match/index.js +27 -27
  16. package/dist/modules/monitor/index.d.ts +3 -3
  17. package/dist/modules/monitor/index.js +10 -10
  18. package/dist/modules/monitor/lib/jsError.d.ts +1 -1
  19. package/dist/modules/monitor/lib/jsError.js +57 -57
  20. package/dist/modules/monitor/lib/timing.d.ts +1 -1
  21. package/dist/modules/monitor/lib/timing.js +65 -65
  22. package/dist/modules/monitor/lib/xhr.d.ts +1 -1
  23. package/dist/modules/monitor/lib/xhr.js +41 -41
  24. package/dist/modules/monitor/utils/onload.d.ts +1 -1
  25. package/dist/modules/monitor/utils/onload.js +8 -8
  26. package/dist/modules/monitor/utils/tracker.d.ts +7 -7
  27. package/dist/modules/monitor/utils/tracker.js +49 -49
  28. package/dist/modules/number/index.d.ts +47 -47
  29. package/dist/modules/number/index.js +114 -114
  30. package/dist/modules/open-app/index.d.ts +84 -84
  31. package/dist/modules/open-app/index.js +244 -244
  32. package/dist/modules/sentry/index.d.ts +15 -15
  33. package/dist/modules/sentry/index.js +73 -73
  34. package/dist/modules/tools/index.d.ts +166 -166
  35. package/dist/modules/tools/index.js +382 -382
  36. package/dist/modules/upload/aliOss.d.ts +291 -291
  37. package/dist/modules/upload/aliOss.js +629 -626
  38. package/dist/modules/upload/index.d.ts +38 -38
  39. package/dist/modules/upload/index.js +44 -44
  40. package/dist/tsconfig.tsbuildinfo +1 -1
  41. package/dist/types/index.d.ts +3 -3
  42. package/dist/types/index.js +1 -1
  43. package/dist/types/modules/cookie/index.d.ts +27 -0
  44. package/dist/types/modules/date/index.d.ts +52 -0
  45. package/dist/types/modules/dom/index.d.ts +28 -0
  46. package/dist/types/modules/filter/index.d.ts +24 -0
  47. package/dist/types/modules/format/index.d.ts +15 -0
  48. package/dist/types/modules/match/index.d.ts +12 -0
  49. package/dist/types/modules/monitor/index.d.ts +3 -0
  50. package/dist/types/modules/monitor/lib/jsError.d.ts +1 -0
  51. package/dist/types/modules/monitor/lib/timing.d.ts +1 -0
  52. package/dist/types/modules/monitor/lib/xhr.d.ts +1 -0
  53. package/dist/types/modules/monitor/utils/onload.d.ts +1 -0
  54. package/dist/types/modules/monitor/utils/tracker.d.ts +7 -0
  55. package/dist/types/modules/number/index.d.ts +41 -0
  56. package/dist/types/modules/sentry/index.d.ts +15 -0
  57. package/dist/types/modules/tools/index.d.ts +166 -0
  58. package/dist/types/types/index.d.ts +3 -0
  59. package/package.json +88 -88
@@ -1,73 +1,73 @@
1
- /**
2
- * 异常上报日志监控类
3
- * @Author: wanghui
4
- * 常用配置 option:https://docs.sentry.io/clients/javascript/config/
5
- * 1.自动捕获vue组件内异常
6
- * 2.自动捕获promise内的异常
7
- * 3.自动捕获没有被catch的运行异常
8
- */
9
- 'use strict';
10
- import Raven from 'raven-js';
11
- // import RavenVue from 'raven-js/plugins/vue';
12
- class Report {
13
- static instance;
14
- constructor(Vue, options = {}) {
15
- if (process.env.NODE_ENV !== 'development') {
16
- // todo
17
- }
18
- this.vue = Vue;
19
- this.options = options;
20
- }
21
- static getInstance(Vue, Option) {
22
- if (!(this.instance instanceof this)) {
23
- this.instance = new this(Vue, Option);
24
- this.instance.install();
25
- }
26
- return this.instance;
27
- }
28
- install() {
29
- if (process.env.NODE_ENV !== 'development') {
30
- // Raven.config(this.options.dsn, {
31
- // environment: process.env.NODE_ENV,
32
- // }).addPlugin(RavenVue, this.Vue).install();
33
- // raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
34
- // 记录用户信息
35
- Raven.setUserContext({ user: this.options.user || '' });
36
- // 设置全局tag标签
37
- Raven.setTagsContext({ environment: this.options.env || '' });
38
- }
39
- }
40
- /**
41
- * 主动上报
42
- * @param {String} data
43
- * @param {String} type 'info','warning','error'
44
- * @param {Object} options
45
- */
46
- log(data = null, type = 'error', options = {}) {
47
- // 添加面包屑
48
- Raven.captureBreadcrumb({
49
- message: data,
50
- category: 'manual message',
51
- });
52
- // 异常上报
53
- if (data instanceof Error) {
54
- Raven.captureException(data, {
55
- level: type,
56
- logger: 'manual exception',
57
- tags: { options },
58
- });
59
- }
60
- else {
61
- Raven.captureException('error', {
62
- level: type,
63
- logger: 'manual data',
64
- extra: {
65
- data,
66
- options: this.options,
67
- date: new Date(),
68
- },
69
- });
70
- }
71
- }
72
- }
73
- export default Report;
1
+ /**
2
+ * 异常上报日志监控类
3
+ * @Author: wanghui
4
+ * 常用配置 option:https://docs.sentry.io/clients/javascript/config/
5
+ * 1.自动捕获vue组件内异常
6
+ * 2.自动捕获promise内的异常
7
+ * 3.自动捕获没有被catch的运行异常
8
+ */
9
+ 'use strict';
10
+ import Raven from 'raven-js';
11
+ // import RavenVue from 'raven-js/plugins/vue';
12
+ class Report {
13
+ static instance;
14
+ constructor(Vue, options = {}) {
15
+ if (process.env.NODE_ENV !== 'development') {
16
+ // todo
17
+ }
18
+ this.vue = Vue;
19
+ this.options = options;
20
+ }
21
+ static getInstance(Vue, Option) {
22
+ if (!(this.instance instanceof this)) {
23
+ this.instance = new this(Vue, Option);
24
+ this.instance.install();
25
+ }
26
+ return this.instance;
27
+ }
28
+ install() {
29
+ if (process.env.NODE_ENV !== 'development') {
30
+ // Raven.config(this.options.dsn, {
31
+ // environment: process.env.NODE_ENV,
32
+ // }).addPlugin(RavenVue, this.Vue).install();
33
+ // raven内置了vue插件,会通过vue.config.errorHandler来捕获vue组件内错误并上报sentry服务
34
+ // 记录用户信息
35
+ Raven.setUserContext({ user: this.options.user || '' });
36
+ // 设置全局tag标签
37
+ Raven.setTagsContext({ environment: this.options.env || '' });
38
+ }
39
+ }
40
+ /**
41
+ * 主动上报
42
+ * @param {String} data
43
+ * @param {String} type 'info','warning','error'
44
+ * @param {Object} options
45
+ */
46
+ log(data = null, type = 'error', options = {}) {
47
+ // 添加面包屑
48
+ Raven.captureBreadcrumb({
49
+ message: data,
50
+ category: 'manual message',
51
+ });
52
+ // 异常上报
53
+ if (data instanceof Error) {
54
+ Raven.captureException(data, {
55
+ level: type,
56
+ logger: 'manual exception',
57
+ tags: { options },
58
+ });
59
+ }
60
+ else {
61
+ Raven.captureException('error', {
62
+ level: type,
63
+ logger: 'manual data',
64
+ extra: {
65
+ data,
66
+ options: this.options,
67
+ date: new Date(),
68
+ },
69
+ });
70
+ }
71
+ }
72
+ }
73
+ export default Report;
@@ -1,166 +1,166 @@
1
- import { IObjectKey } from '../../types/index';
2
- declare class ToolsClass {
3
- [key: string]: any;
4
- constructor();
5
- /**
6
- * 深拷贝 Object|Array
7
- * 深拷贝,支持 普通对象、数组,但是未解决Function、Date、RegExp,且1M以上数据性能不好
8
- * @param {String} data
9
- * @return {Object}
10
- */
11
- deepCopy(data: object): object;
12
- /**
13
- * 深拷贝 Object|Array
14
- * 支持 普通对象、数组和函数的深复制,但是未解决循环引用、Date、RegExp
15
- * @param {Object|Array} data
16
- * @return {Object}
17
- */
18
- deepCopy2<T>(obj: T): T;
19
- /**
20
- * 深拷贝 Object|Array
21
- * 注意:需要 yarn add lodash
22
- * @param {Object|Array} data
23
- * @return {Object}
24
- */
25
- deepCopy3(obj: any): any;
26
- /**
27
- * 防抖
28
- * demo:debounce(func, 300)(args)
29
- * @param {Function} func 执行函数
30
- * @param {Number} wait 节流时间,毫秒
31
- * @return {Function} delay
32
- */
33
- debounce(func: Function, wait: number): () => void;
34
- /**
35
- * 节流
36
- * demo:throttle(func, 300)(args)
37
- * @param {Object|Array} func 执行函数
38
- * @param {Number} wait 节流时间,毫秒
39
- * @return {Function} delay
40
- */
41
- throttle(func: Function, wait: number): () => void;
42
- /**
43
- * 获取路径中文件名称
44
- * @param {String} url
45
- * @return {String}
46
- */
47
- getUrlName(url: string): string;
48
- /**
49
- * 动态加载脚本
50
- * tip:按需加载时用(多次调用,js不会重复加载)
51
- * @param {String} url
52
- * @return {Promise}
53
- */
54
- loadJs(url: string): Error | Promise<unknown>;
55
- /**
56
- * 动态加载样式
57
- * @param {String} url
58
- * @return {Promise}
59
- */
60
- loadCss(url: string): Error | Promise<unknown>;
61
- /**
62
- * 蒙层显示后,html禁止滚动操作
63
- * @param {String} className
64
- * @return {Void}
65
- */
66
- stopScroll: (className: string) => Error | undefined;
67
- /**
68
- * 蒙层隐藏后,html开启滚动操作
69
- * @param {String} className
70
- * @return {Void}
71
- */
72
- startScroll: (className: string) => Error | undefined;
73
- /**
74
- * 字符串复制到剪贴板
75
- * 注意:需要 yarn add clipboard-copy
76
- * @param {String} str
77
- * @return {String}
78
- */
79
- clipboard(str: string): Error | Promise<void>;
80
- /**
81
- * 首字母大写
82
- * @param {String} str
83
- * @return {String}
84
- */
85
- firstUpperCase(str: string): string;
86
- /**
87
- * 截取数组或字符串,示例:slice('1234', 3)
88
- * @param {Array|String} target 数组或字符串
89
- * @param {Number} length 截取长度,从0开始
90
- * @return {any}
91
- */
92
- slice(target?: Array<any> | string, length?: number): string | any[];
93
- /**
94
- * 获取guid
95
- * @return {String}
96
- */
97
- guid(): string;
98
- /**
99
- * 获取文本字节数(含中文)
100
- * @param {String} str
101
- * @return {String}
102
- */
103
- getBytesOfText(str?: string): number;
104
- /**
105
- * object 对象转 array 数组
106
- * demo:
107
- * objectToArray({a:1,b:2}) 输出:["a=1", "b=2"]
108
- * @param {Object} obj
109
- * @returns {Array} arr
110
- */
111
- objectToArray: (obj: IObjectKey<string>) => Array<string>;
112
- /**
113
- * convertEnum
114
- * 枚举键值互换
115
- * @param {Object} obj
116
- * convertKeyValueEnum({a: 1, b: 2}) // {1: "a", 2: "b"}
117
- * @returns {Object} result
118
- */
119
- convertKeyValueEnum: (obj: IObjectKey<string>) => IObjectKey<string>;
120
- /**
121
- * 数组去重
122
- * @param {Array} arr
123
- * @returns {Array}
124
- */
125
- uniqueArr(arr: Array<any>): Array<any>;
126
- /**
127
- * 数组元素交换位置
128
- * index1和index2分别是两个数组的索引值,即是两个要交换元素位置的索引值,如1,5就是数组中下标为1和5的两个元素交换位置
129
- * @param {Array<string | number>} array 数组
130
- * @param {number} index1 添加项目的位置
131
- * @param {number} index2 删除项目的位置
132
- * swapArray([1, 2, 3, 4], 2, 3) // [1, 2, 4, 3]
133
- * @returns {Array<string | number>} array
134
- */
135
- swapArray(array: Array<string | number>, index1: number, index2: number): Array<string | number>;
136
- /**
137
- * 过滤表情符号
138
- * @param {String} str
139
- * @return {String}
140
- */
141
- filterEmoji(str: string): string;
142
- /**
143
- * 是否包含表情
144
- * @param {String} str
145
- * @return {boolean}
146
- */
147
- containsEmoji(str: string): boolean;
148
- /**
149
- * 是否包含表汉字
150
- * @param {String} str
151
- * @return {boolean}
152
- */
153
- containsHanZi(str: string): boolean;
154
- isEmpty(val: any): boolean;
155
- isDefined: (val: any) => boolean;
156
- /**
157
- * 字段脱敏处理
158
- * @param {String} field 未脱敏字段
159
- * @param {Int} before 开头未脱敏字符数
160
- * @param {Int} after 结尾未脱敏字符数
161
- * @return {String} 已脱敏字段
162
- */
163
- sensitiveField(field: string | number, before?: number, after?: number): string;
164
- }
165
- declare const _default: ToolsClass;
166
- export default _default;
1
+ import { IObjectKey } from '../../types/index';
2
+ declare class ToolsClass {
3
+ [key: string]: any;
4
+ constructor();
5
+ /**
6
+ * 深拷贝 Object|Array
7
+ * 深拷贝,支持 普通对象、数组,但是未解决Function、Date、RegExp,且1M以上数据性能不好
8
+ * @param {String} data
9
+ * @return {Object}
10
+ */
11
+ deepCopy(data: object): object;
12
+ /**
13
+ * 深拷贝 Object|Array
14
+ * 支持 普通对象、数组和函数的深复制,但是未解决循环引用、Date、RegExp
15
+ * @param {Object|Array} data
16
+ * @return {Object}
17
+ */
18
+ deepCopy2<T>(obj: T): T;
19
+ /**
20
+ * 深拷贝 Object|Array
21
+ * 注意:需要 yarn add lodash
22
+ * @param {Object|Array} data
23
+ * @return {Object}
24
+ */
25
+ deepCopy3(obj: any): any;
26
+ /**
27
+ * 防抖
28
+ * demo:debounce(func, 300)(args)
29
+ * @param {Function} func 执行函数
30
+ * @param {Number} wait 节流时间,毫秒
31
+ * @return {Function} delay
32
+ */
33
+ debounce(func: Function, wait: number): () => void;
34
+ /**
35
+ * 节流
36
+ * demo:throttle(func, 300)(args)
37
+ * @param {Object|Array} func 执行函数
38
+ * @param {Number} wait 节流时间,毫秒
39
+ * @return {Function} delay
40
+ */
41
+ throttle(func: Function, wait: number): () => void;
42
+ /**
43
+ * 获取路径中文件名称
44
+ * @param {String} url
45
+ * @return {String}
46
+ */
47
+ getUrlName(url: string): string;
48
+ /**
49
+ * 动态加载脚本
50
+ * tip:按需加载时用(多次调用,js不会重复加载)
51
+ * @param {String} url
52
+ * @return {Promise}
53
+ */
54
+ loadJs(url: string): Error | Promise<unknown>;
55
+ /**
56
+ * 动态加载样式
57
+ * @param {String} url
58
+ * @return {Promise}
59
+ */
60
+ loadCss(url: string): Error | Promise<unknown>;
61
+ /**
62
+ * 蒙层显示后,html禁止滚动操作
63
+ * @param {String} className
64
+ * @return {Void}
65
+ */
66
+ stopScroll: (className: string) => Error | undefined;
67
+ /**
68
+ * 蒙层隐藏后,html开启滚动操作
69
+ * @param {String} className
70
+ * @return {Void}
71
+ */
72
+ startScroll: (className: string) => Error | undefined;
73
+ /**
74
+ * 字符串复制到剪贴板
75
+ * 注意:需要 yarn add clipboard-copy
76
+ * @param {String} str
77
+ * @return {String}
78
+ */
79
+ clipboard(str: string): Error | Promise<void>;
80
+ /**
81
+ * 首字母大写
82
+ * @param {String} str
83
+ * @return {String}
84
+ */
85
+ firstUpperCase(str: string): string;
86
+ /**
87
+ * 截取数组或字符串,示例:slice('1234', 3)
88
+ * @param {Array|String} target 数组或字符串
89
+ * @param {Number} length 截取长度,从0开始
90
+ * @return {any}
91
+ */
92
+ slice(target?: Array<any> | string, length?: number): string | any[];
93
+ /**
94
+ * 获取guid
95
+ * @return {String}
96
+ */
97
+ guid(): string;
98
+ /**
99
+ * 获取文本字节数(含中文)
100
+ * @param {String} str
101
+ * @return {String}
102
+ */
103
+ getBytesOfText(str?: string): number;
104
+ /**
105
+ * object 对象转 array 数组
106
+ * demo:
107
+ * objectToArray({a:1,b:2}) 输出:["a=1", "b=2"]
108
+ * @param {Object} obj
109
+ * @returns {Array} arr
110
+ */
111
+ objectToArray: (obj: IObjectKey<string>) => Array<string>;
112
+ /**
113
+ * convertEnum
114
+ * 枚举键值互换
115
+ * @param {Object} obj
116
+ * convertKeyValueEnum({a: 1, b: 2}) // {1: "a", 2: "b"}
117
+ * @returns {Object} result
118
+ */
119
+ convertKeyValueEnum: (obj: IObjectKey<string>) => IObjectKey<string>;
120
+ /**
121
+ * 数组去重
122
+ * @param {Array} arr
123
+ * @returns {Array}
124
+ */
125
+ uniqueArr(arr: Array<any>): Array<any>;
126
+ /**
127
+ * 数组元素交换位置
128
+ * index1和index2分别是两个数组的索引值,即是两个要交换元素位置的索引值,如1,5就是数组中下标为1和5的两个元素交换位置
129
+ * @param {Array<string | number>} array 数组
130
+ * @param {number} index1 添加项目的位置
131
+ * @param {number} index2 删除项目的位置
132
+ * swapArray([1, 2, 3, 4], 2, 3) // [1, 2, 4, 3]
133
+ * @returns {Array<string | number>} array
134
+ */
135
+ swapArray(array: Array<string | number>, index1: number, index2: number): Array<string | number>;
136
+ /**
137
+ * 过滤表情符号
138
+ * @param {String} str
139
+ * @return {String}
140
+ */
141
+ filterEmoji(str: string): string;
142
+ /**
143
+ * 是否包含表情
144
+ * @param {String} str
145
+ * @return {boolean}
146
+ */
147
+ containsEmoji(str: string): boolean;
148
+ /**
149
+ * 是否包含表汉字
150
+ * @param {String} str
151
+ * @return {boolean}
152
+ */
153
+ containsHanZi(str: string): boolean;
154
+ isEmpty(val: any): boolean;
155
+ isDefined: (val: any) => boolean;
156
+ /**
157
+ * 字段脱敏处理
158
+ * @param {String} field 未脱敏字段
159
+ * @param {Int} before 开头未脱敏字符数
160
+ * @param {Int} after 结尾未脱敏字符数
161
+ * @return {String} 已脱敏字段
162
+ */
163
+ sensitiveField(field: string | number, before?: number, after?: number): string;
164
+ }
165
+ declare const _default: ToolsClass;
166
+ export default _default;