@haluo/util 2.0.29 → 2.0.31

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 +92 -84
  31. package/dist/modules/open-app/index.js +260 -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 -629
  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 -27
  44. package/dist/types/modules/date/index.d.ts +52 -52
  45. package/dist/types/modules/dom/index.d.ts +28 -28
  46. package/dist/types/modules/filter/index.d.ts +24 -24
  47. package/dist/types/modules/format/index.d.ts +15 -15
  48. package/dist/types/modules/match/index.d.ts +12 -12
  49. package/dist/types/modules/monitor/index.d.ts +3 -3
  50. package/dist/types/modules/monitor/lib/jsError.d.ts +1 -1
  51. package/dist/types/modules/monitor/lib/timing.d.ts +1 -1
  52. package/dist/types/modules/monitor/lib/xhr.d.ts +1 -1
  53. package/dist/types/modules/monitor/utils/onload.d.ts +1 -1
  54. package/dist/types/modules/monitor/utils/tracker.d.ts +7 -7
  55. package/dist/types/modules/number/index.d.ts +41 -41
  56. package/dist/types/modules/sentry/index.d.ts +15 -15
  57. package/dist/types/modules/tools/index.d.ts +166 -166
  58. package/dist/types/types/index.d.ts +3 -3
  59. package/package.json +88 -88
package/dist/index.d.ts CHANGED
@@ -1,39 +1,39 @@
1
- import cookie from './modules/cookie';
2
- import date from './modules/date';
3
- import dom from './modules/dom';
4
- import filter from './modules/filter';
5
- import format from './modules/format';
6
- import match from './modules/match';
7
- import number from './modules/number';
8
- import openApp from './modules/open-app';
9
- import tools from './modules/tools';
10
- import upload from './modules/upload';
11
- import monitor from './modules/monitor';
12
- export * from './modules/monitor';
13
- interface Modules {
14
- cookie: typeof cookie;
15
- date: typeof date;
16
- dom: typeof dom;
17
- filter: typeof filter;
18
- format: typeof format;
19
- match: typeof match;
20
- number: typeof number;
21
- openApp: typeof openApp;
22
- tools: typeof tools;
23
- upload: typeof upload;
24
- monitor: typeof monitor;
25
- }
26
- declare class Utils {
27
- constructor();
28
- /**
29
- * 挂载各组件
30
- * 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
31
- * @param {Object} Vue 需要挂载的目标对象
32
- */
33
- install(app: any): void;
34
- }
35
- interface Utils extends Modules {
36
- }
37
- declare const _default: Utils;
38
- export default _default;
39
- export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
1
+ import cookie from './modules/cookie';
2
+ import date from './modules/date';
3
+ import dom from './modules/dom';
4
+ import filter from './modules/filter';
5
+ import format from './modules/format';
6
+ import match from './modules/match';
7
+ import number from './modules/number';
8
+ import openApp from './modules/open-app';
9
+ import tools from './modules/tools';
10
+ import upload from './modules/upload';
11
+ import monitor from './modules/monitor';
12
+ export * from './modules/monitor';
13
+ interface Modules {
14
+ cookie: typeof cookie;
15
+ date: typeof date;
16
+ dom: typeof dom;
17
+ filter: typeof filter;
18
+ format: typeof format;
19
+ match: typeof match;
20
+ number: typeof number;
21
+ openApp: typeof openApp;
22
+ tools: typeof tools;
23
+ upload: typeof upload;
24
+ monitor: typeof monitor;
25
+ }
26
+ declare class Utils {
27
+ constructor();
28
+ /**
29
+ * 挂载各组件
30
+ * 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
31
+ * @param {Object} Vue 需要挂载的目标对象
32
+ */
33
+ install(app: any): void;
34
+ }
35
+ interface Utils extends Modules {
36
+ }
37
+ declare const _default: Utils;
38
+ export default _default;
39
+ export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
- import cookie from './modules/cookie';
2
- import date from './modules/date';
3
- import dom from './modules/dom';
4
- import filter from './modules/filter';
5
- import format from './modules/format';
6
- import match from './modules/match';
7
- import number from './modules/number';
8
- import openApp from './modules/open-app';
9
- import tools from './modules/tools';
10
- import upload from './modules/upload';
11
- import monitor from './modules/monitor';
12
- export * from './modules/monitor';
13
- const modules = {
14
- cookie,
15
- date,
16
- dom,
17
- filter,
18
- format,
19
- match,
20
- number,
21
- openApp,
22
- tools,
23
- upload,
24
- monitor
25
- };
26
- class Utils {
27
- constructor() {
28
- Object.assign(this, modules);
29
- }
30
- /**
31
- * 挂载各组件
32
- * 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
33
- * @param {Object} Vue 需要挂载的目标对象
34
- */
35
- install(app) {
36
- Object.keys(modules).forEach((key) => {
37
- const globalProperties = app.config.globalProperties;
38
- globalProperties['$' + key] = modules[key];
39
- });
40
- }
41
- }
42
- export default new Utils();
43
- export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
1
+ import cookie from './modules/cookie';
2
+ import date from './modules/date';
3
+ import dom from './modules/dom';
4
+ import filter from './modules/filter';
5
+ import format from './modules/format';
6
+ import match from './modules/match';
7
+ import number from './modules/number';
8
+ import openApp from './modules/open-app';
9
+ import tools from './modules/tools';
10
+ import upload from './modules/upload';
11
+ import monitor from './modules/monitor';
12
+ export * from './modules/monitor';
13
+ const modules = {
14
+ cookie,
15
+ date,
16
+ dom,
17
+ filter,
18
+ format,
19
+ match,
20
+ number,
21
+ openApp,
22
+ tools,
23
+ upload,
24
+ monitor
25
+ };
26
+ class Utils {
27
+ constructor() {
28
+ Object.assign(this, modules);
29
+ }
30
+ /**
31
+ * 挂载各组件
32
+ * 示例:this.$cookie、this.$date、this.$match、this.$number、this.$tools
33
+ * @param {Object} Vue 需要挂载的目标对象
34
+ */
35
+ install(app) {
36
+ Object.keys(modules).forEach((key) => {
37
+ const globalProperties = app.config.globalProperties;
38
+ globalProperties['$' + key] = modules[key];
39
+ });
40
+ }
41
+ }
42
+ export default new Utils();
43
+ export { cookie, date, dom, filter, format, match, number, openApp, tools, upload, monitor };
@@ -1,27 +1,27 @@
1
- interface ICookie {
2
- name: string;
3
- value: string;
4
- exdays: number;
5
- path?: string;
6
- domain?: string;
7
- }
8
- declare class CookieClass {
9
- /**
10
- * 获取cookie
11
- * @param {String} name
12
- * @return {String}
13
- */
14
- getCookie(name: string): string;
15
- /**
16
- * 设置cookie
17
- * @param {Object} ICookie
18
- */
19
- setCookie({ name, value, exdays, path, domain, }: ICookie): void;
20
- /**
21
- * 清除Cookie
22
- * @param {String} name
23
- */
24
- clearCookie({ name, path, domain, }: ICookie): void;
25
- }
26
- declare const _default: CookieClass;
27
- export default _default;
1
+ interface ICookie {
2
+ name: string;
3
+ value: string;
4
+ exdays: number;
5
+ path?: string;
6
+ domain?: string;
7
+ }
8
+ declare class CookieClass {
9
+ /**
10
+ * 获取cookie
11
+ * @param {String} name
12
+ * @return {String}
13
+ */
14
+ getCookie(name: string): string;
15
+ /**
16
+ * 设置cookie
17
+ * @param {Object} ICookie
18
+ */
19
+ setCookie({ name, value, exdays, path, domain, }: ICookie): void;
20
+ /**
21
+ * 清除Cookie
22
+ * @param {String} name
23
+ */
24
+ clearCookie({ name, path, domain, }: ICookie): void;
25
+ }
26
+ declare const _default: CookieClass;
27
+ export default _default;
@@ -1,49 +1,49 @@
1
- /**
2
- * @file Cookie
3
- * @Author: wanghui
4
- * @createBy: @2021.01.21
5
- */
6
- 'use strict';
7
- class CookieClass {
8
- /**
9
- * 获取cookie
10
- * @param {String} name
11
- * @return {String}
12
- */
13
- getCookie(name) {
14
- const _name = name + '=';
15
- const ca = document.cookie.split(';');
16
- for (let i = 0; i < ca.length; i++) {
17
- let c = ca[i];
18
- while (c.charAt(0) === ' ')
19
- c = c.substring(1);
20
- if (c.includes(_name))
21
- return c.substring(_name.length, c.length);
22
- }
23
- return '';
24
- }
25
- /**
26
- * 设置cookie
27
- * @param {Object} ICookie
28
- */
29
- setCookie({ name = '', value = '', exdays = -1, path = '/', domain = '.jddmoto.com', }) {
30
- var d = new Date();
31
- d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
32
- var expires = `expires=${d.toUTCString()}`;
33
- document.cookie = `${name}=${value};${expires};path=${path};domain=${domain};`;
34
- }
35
- /**
36
- * 清除Cookie
37
- * @param {String} name
38
- */
39
- clearCookie({ name = '', path = '/', domain = '.jddmoto.com', }) {
40
- this.setCookie({
41
- name,
42
- value: '',
43
- exdays: -1,
44
- path,
45
- domain
46
- });
47
- }
48
- }
49
- export default new CookieClass();
1
+ /**
2
+ * @file Cookie
3
+ * @Author: wanghui
4
+ * @createBy: @2021.01.21
5
+ */
6
+ 'use strict';
7
+ class CookieClass {
8
+ /**
9
+ * 获取cookie
10
+ * @param {String} name
11
+ * @return {String}
12
+ */
13
+ getCookie(name) {
14
+ const _name = name + '=';
15
+ const ca = document.cookie.split(';');
16
+ for (let i = 0; i < ca.length; i++) {
17
+ let c = ca[i];
18
+ while (c.charAt(0) === ' ')
19
+ c = c.substring(1);
20
+ if (c.includes(_name))
21
+ return c.substring(_name.length, c.length);
22
+ }
23
+ return '';
24
+ }
25
+ /**
26
+ * 设置cookie
27
+ * @param {Object} ICookie
28
+ */
29
+ setCookie({ name = '', value = '', exdays = -1, path = '/', domain = '.jddmoto.com', }) {
30
+ var d = new Date();
31
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
32
+ var expires = `expires=${d.toUTCString()}`;
33
+ document.cookie = `${name}=${value};${expires};path=${path};domain=${domain};`;
34
+ }
35
+ /**
36
+ * 清除Cookie
37
+ * @param {String} name
38
+ */
39
+ clearCookie({ name = '', path = '/', domain = '.jddmoto.com', }) {
40
+ this.setCookie({
41
+ name,
42
+ value: '',
43
+ exdays: -1,
44
+ path,
45
+ domain
46
+ });
47
+ }
48
+ }
49
+ export default new CookieClass();
@@ -1,52 +1,52 @@
1
- declare class DateClass {
2
- /**
3
- * 格式化时间
4
- * @param {Date|Number|String} date 需要格式化的时间 2017-11-11、2017/11/11、linux time
5
- * @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
6
- * date.format(new Date()) // 默认格式 'YYYY-MM-DD HH:mm:ss'
7
- * date.format(1586840260500) // 默认格式,传参为linux时间
8
- * date.format(new Date(), 'YYYY:MM:DD') // 自定义格式 'YYYY:MM:DD'
9
- * @return {String} fmt 'YYYY-MM-DD HH:mm:ss'
10
- */
11
- format(date: Date | number | string, fmt?: string): string;
12
- /**
13
- * 天数加减
14
- * @param {string | Date} date 传入的时间 2020-10-15 or Date
15
- * @param {String} days 天数
16
- * addDaysToDate('2020-10-15', 10) // '2020-10-25'
17
- * addDaysToDate('2020-10-15', -10) // '2020-10-05'
18
- * @return {String} fmt 'YYYY-MM-DD'
19
- */
20
- addDaysToDate(date: string | Date, days: number): string;
21
- /**
22
- * 获取倒计时剩余时间
23
- * @param {Date | Number} endTime 截止时间
24
- * @param {Date | Number} startTime 开始时间,默认取客户端当前时间
25
- * date.format(new Date()) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
26
- * date.format(1586840260500) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
27
- * @return {object | boolean} {dd: '天', hh: '时', mm: '分', ss: '秒'}
28
- */
29
- remainTime(endTime: Date | Number, startTime?: Date | Number): object | boolean;
30
- /**
31
- * 格式化现在的已过时间
32
- * @param {Number} startTime
33
- * @return {String} *年前 *个月前 *天前 *小时前 *分钟前 刚刚
34
- */
35
- formatPassTime(startTime: any): string;
36
- /**
37
- * 格式化时间 列表里的时间内容格式 待废弃,统一时间格式
38
- * @param {Number} time 1494141000*1000
39
- * @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
40
- */
41
- formatPassTimeForList(time: string): string | false;
42
- /**
43
- * 格式化时间 详情内容里的时间格式
44
- * @param {Number} time 1494141000*1000
45
- * @param {String} fmt 想要格式化的格式
46
- * @param {Boolean} noYear 是否显示年
47
- * @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
48
- */
49
- formatPassTimeForDetail(time: string, fmt: string | undefined, noYear: Boolean): string | false;
50
- }
51
- declare const _default: DateClass;
52
- export default _default;
1
+ declare class DateClass {
2
+ /**
3
+ * 格式化时间
4
+ * @param {Date|Number|String} date 需要格式化的时间 2017-11-11、2017/11/11、linux time
5
+ * @param {String} fmt 想要格式化的格式 'YYYY-MM-DD HH:mm:ss'、'YYYY-MM-DD'、'YYYY年MM月DD日 HH时mm分ss秒'、'YYYY年MM月DD日'
6
+ * date.format(new Date()) // 默认格式 'YYYY-MM-DD HH:mm:ss'
7
+ * date.format(1586840260500) // 默认格式,传参为linux时间
8
+ * date.format(new Date(), 'YYYY:MM:DD') // 自定义格式 'YYYY:MM:DD'
9
+ * @return {String} fmt 'YYYY-MM-DD HH:mm:ss'
10
+ */
11
+ format(date: Date | number | string, fmt?: string): string;
12
+ /**
13
+ * 天数加减
14
+ * @param {string | Date} date 传入的时间 2020-10-15 or Date
15
+ * @param {String} days 天数
16
+ * addDaysToDate('2020-10-15', 10) // '2020-10-25'
17
+ * addDaysToDate('2020-10-15', -10) // '2020-10-05'
18
+ * @return {String} fmt 'YYYY-MM-DD'
19
+ */
20
+ addDaysToDate(date: string | Date, days: number): string;
21
+ /**
22
+ * 获取倒计时剩余时间
23
+ * @param {Date | Number} endTime 截止时间
24
+ * @param {Date | Number} startTime 开始时间,默认取客户端当前时间
25
+ * date.format(new Date()) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
26
+ * date.format(1586840260500) // 返回 {dd: '天', hh: '时', mm: '分', ss: '秒'}
27
+ * @return {object | boolean} {dd: '天', hh: '时', mm: '分', ss: '秒'}
28
+ */
29
+ remainTime(endTime: Date | Number, startTime?: Date | Number): object | boolean;
30
+ /**
31
+ * 格式化现在的已过时间
32
+ * @param {Number} startTime
33
+ * @return {String} *年前 *个月前 *天前 *小时前 *分钟前 刚刚
34
+ */
35
+ formatPassTime(startTime: any): string;
36
+ /**
37
+ * 格式化时间 列表里的时间内容格式 待废弃,统一时间格式
38
+ * @param {Number} time 1494141000*1000
39
+ * @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
40
+ */
41
+ formatPassTimeForList(time: string): string | false;
42
+ /**
43
+ * 格式化时间 详情内容里的时间格式
44
+ * @param {Number} time 1494141000*1000
45
+ * @param {String} fmt 想要格式化的格式
46
+ * @param {Boolean} noYear 是否显示年
47
+ * @return {String} *年*月*日 *月*日 刚刚(1-60秒) 1-60分钟前 1-24小时前 1-3天前
48
+ */
49
+ formatPassTimeForDetail(time: string, fmt: string | undefined, noYear: Boolean): string | false;
50
+ }
51
+ declare const _default: DateClass;
52
+ export default _default;