@base-web-kits/base-tools-ts 0.8.16 → 0.9.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 (47) hide show
  1. package/package.json +1 -1
  2. package/dist/array/index.d.ts +0 -9
  3. package/dist/array/index.d.ts.map +0 -1
  4. package/dist/async/index.d.ts +0 -14
  5. package/dist/async/index.d.ts.map +0 -1
  6. package/dist/bean/EventBus.d.ts +0 -36
  7. package/dist/bean/EventBus.d.ts.map +0 -1
  8. package/dist/bean/index.d.ts +0 -2
  9. package/dist/bean/index.d.ts.map +0 -1
  10. package/dist/day/index.d.ts +0 -100
  11. package/dist/day/index.d.ts.map +0 -1
  12. package/dist/index.d.ts +0 -15
  13. package/dist/index.d.ts.map +0 -1
  14. package/dist/lodash/index.d.ts +0 -8
  15. package/dist/lodash/index.d.ts.map +0 -1
  16. package/dist/number/big.d.ts +0 -137
  17. package/dist/number/big.d.ts.map +0 -1
  18. package/dist/number/format.d.ts +0 -88
  19. package/dist/number/format.d.ts.map +0 -1
  20. package/dist/number/index.d.ts +0 -4
  21. package/dist/number/index.d.ts.map +0 -1
  22. package/dist/number/random.d.ts +0 -33
  23. package/dist/number/random.d.ts.map +0 -1
  24. package/dist/object/index.d.ts +0 -11
  25. package/dist/object/index.d.ts.map +0 -1
  26. package/dist/string/format.d.ts +0 -33
  27. package/dist/string/format.d.ts.map +0 -1
  28. package/dist/string/index.d.ts +0 -4
  29. package/dist/string/index.d.ts.map +0 -1
  30. package/dist/string/other.d.ts +0 -15
  31. package/dist/string/other.d.ts.map +0 -1
  32. package/dist/string/random.d.ts +0 -27
  33. package/dist/string/random.d.ts.map +0 -1
  34. package/dist/typing/index.d.ts +0 -134
  35. package/dist/typing/index.d.ts.map +0 -1
  36. package/dist/url/file/index.d.ts +0 -22
  37. package/dist/url/file/index.d.ts.map +0 -1
  38. package/dist/url/index.d.ts +0 -5
  39. package/dist/url/index.d.ts.map +0 -1
  40. package/dist/url/oss/index.d.ts +0 -77
  41. package/dist/url/oss/index.d.ts.map +0 -1
  42. package/dist/url/param/index.d.ts +0 -49
  43. package/dist/url/param/index.d.ts.map +0 -1
  44. package/dist/url/qn/index.d.ts +0 -58
  45. package/dist/url/qn/index.d.ts.map +0 -1
  46. package/dist/validator/index.d.ts +0 -296
  47. package/dist/validator/index.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-web-kits/base-tools-ts",
3
- "version": "0.8.16",
3
+ "version": "0.9.1",
4
4
  "sideEffects": false,
5
5
  "description": "Independent TS utilities package built from src/ts.",
6
6
  "keywords": [
@@ -1,9 +0,0 @@
1
- /**
2
- * 拖拽排序 (不改变原数组)
3
- * @param list 原始数组
4
- * @param fromIndex 要移动的元素的原始索引
5
- * @param toIndex 要移动到的目标索引
6
- * @returns 移动元素后的新数组
7
- */
8
- export declare function arrayMove<T>(list: T[], fromIndex: number, toIndex: number): T[];
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/array/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAKzE"}
@@ -1,14 +0,0 @@
1
- /**
2
- * 将 Promise 包装为 [data, error] 形式, 减少 try-catch 代码量
3
- * @param p 要包装的 Promise
4
- * @returns 一个 Promise,其结果为 [data, error] 形式
5
- * @example
6
- * const [data, err] = await toAsync(fetch('https://api.example.com/data'));
7
- * if (err) {
8
- * console.error(err);
9
- * return;
10
- * }
11
- * console.log(data);
12
- */
13
- export declare function toAsync<T>(p: Promise<T>): Promise<[T | null, unknown]>;
14
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/async/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAO5E"}
@@ -1,36 +0,0 @@
1
- import { type EventType } from 'mitt';
2
- type Events = Record<EventType, unknown>;
3
- /**
4
- * 总线式发布订阅
5
- * @example
6
- * const emitter = new EventBus<any>(); // 支持链式调用
7
- * emitter.on('xx', fn); // 订阅事件 xx
8
- * emitter.once('xx', fn); // 订阅事件 xx 一次
9
- * emitter.emit('xx', any); // 发布事件 xx,参数任意
10
- * emitter.off('xx'); // 移除事件 xx 下全部监听
11
- * emitter.off('xx', fn); // 移除事件 xx 下指定监听
12
- * emitter.clear(); // 移除所有事件
13
- *
14
- * @example 类型约束
15
- * type T = { a: number; b: string };
16
- * const emitter = new EventBus<{ xx: T }>();
17
- * const fn = (arg: T) => {}
18
- * emitter.on('xx', fn);
19
- * emitter.off('xx', fn);
20
- * emitter.emit('xx', { a: 123, b: '123' });
21
- */
22
- export default class EventBus<T extends Events = Events> {
23
- private readonly _emitter;
24
- /** 订阅 */
25
- on<K extends keyof T>(type: K, fn: (event: T[K]) => void): this;
26
- /** 订阅一次 */
27
- once<K extends keyof T>(type: K, fn: (event: T[K]) => void): this;
28
- /** 发布 */
29
- emit<K extends keyof T>(type: K, event: T[K]): this;
30
- /** 移除 */
31
- off<K extends keyof T>(type: K, fn?: (event: T[K]) => void): this;
32
- /** 清空 */
33
- clear(): this;
34
- }
35
- export {};
36
- //# sourceMappingURL=EventBus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventBus.d.ts","sourceRoot":"","sources":["../../../src/ts/bean/EventBus.ts"],"names":[],"mappings":"AAAA,OAAa,EAAgB,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1D,KAAK,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACrD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAElD,SAAS;IACT,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAK/D,WAAW;IACX,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IASjE,SAAS;IACT,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAK5C,SAAS;IACT,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,IAAI;IAKjE,SAAS;IACT,KAAK,IAAI,IAAI;CAId"}
@@ -1,2 +0,0 @@
1
- export { default as EventBus } from './EventBus';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/bean/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -1,100 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import 'dayjs/locale/zh-cn';
3
- type BaseTime = number | string | Date | dayjs.Dayjs | null | undefined;
4
- /**
5
- * 创建 dayjs 实例
6
- * 文档: https://day.js.org/zh-CN/
7
- * @param t 各种规范或不规范的时间
8
- * @returns dayjs 实例
9
- * @example
10
- * const d = toDayjs('2021-01-01'); // dayjs 实例
11
- * d.format('YYYY-MM-DD HH:mm:ss'); // "2025-12-10 11:33:16"
12
- * d.valueOf(); // 毫秒时间戳,如 1765337596913
13
- * d.unix(); // 秒时间戳,如 1765337596
14
- * d.millisecond(); // 毫秒 913
15
- * d.second(); // 秒 16
16
- * d.minute(); // 分 33
17
- * d.hour(); // 时 11
18
- * d.date(); // 日 10
19
- * d.day(); // 星期几 5(周日=0)
20
- * d.month() + 1; // 月 12
21
- * d.year(); // 年 2025
22
- * d.startOf('day').valueOf(); // 当日零点
23
- * d.startOf('month').format('YYYY-MM-DD HH:mm:ss'); // 月初 "2025-12-01 00:00:00"
24
- * d.endOf('month').format('YYYY-MM-DD HH:mm:ss'); // 月末 "2025-12-31 23:59:59"
25
- * d.fromNow(); // “刚刚”、“x分钟前/后”、“x小时前/后”、“x天前/后”、“x月前/后”、“x年前/后”
26
- * d.isSame(t, 'day'); // 是否与t在同一天
27
- * d.diff(); // 与当前时间相差的毫秒数
28
- * d.diff(t); // 与t相差的毫秒数
29
- * d.diff(t, 'second'); // 与t相差的秒数
30
- * d.diff(t, 'minute'); // 与t相差的分钟数
31
- * d.diff(t, 'hour'); // 与t相差的小时数
32
- * d.diff(t, 'day'); // 与t相差的天数
33
- * d.diff(t, 'week'); // 与t相差的周数
34
- * d.diff(t, 'month'); // 与t相差的月数
35
- * d.diff(t, 'quarter'); // 与t相差的季度数
36
- * d.diff(t, 'year'); // 与t相差的年数
37
- */
38
- export declare function toDayjs(t: BaseTime, fmt?: dayjs.OptionType): dayjs.Dayjs;
39
- /**
40
- * 获取“前几天”的日期范围
41
- * @param offset 正整数天数
42
- * @param fmt 日期格式,默认 `YYYY-MM-DD`
43
- * @returns `[start, end]` 日期字符串数组
44
- * @example
45
- * 若今天为 2025-11-19:
46
- * getDateRangeBefore(1) // ['2025-11-18', '2025-11-19']
47
- * getDateRangeBefore(1, 'YYYY-MM-DD HH:mm:ss') // ['2025-11-18 00:00:00', '2025-11-19 23:59:59']
48
- */
49
- export declare function getDateRangeBefore(offset: number, fmt?: string): string[];
50
- /**
51
- * 获取“后几天”的日期范围
52
- * - 起点:今天;终点:`offset` 天后
53
- * - 若 `fmt` 含时间令牌(如 `HH:mm:ss`),则返回整日范围:起点为当日零点,终点为当日末尾
54
- * @param offset 正整数天数
55
- * @param fmt 日期格式,默认 `YYYY-MM-DD`
56
- * @returns `[start, end]` 日期字符串数组
57
- * @example
58
- * 若今天为 2025-11-19:
59
- * getDateRangeAfter(1) // ['2025-11-19', '2025-11-20']
60
- * getDateRangeAfter(1, 'YYYY-MM-DD HH:mm:ss') // ['2025-11-19 00:00:00', '2025-11-20 23:59:59']
61
- */
62
- export declare function getDateRangeAfter(offset: number, fmt?: string): string[];
63
- /**
64
- * 获取倒计时的时间分解(零填充字符串)
65
- * @param diff 毫秒差值(正数表示剩余时间,负数/0表示已到期)
66
- * @returns 包含天、时、分、秒、毫秒的零填充对象
67
- * @example
68
- * const diff = toDayjs(t).diff(); // 毫秒差值
69
- * const parts = getCountdownParts(diff); // { d: '01', h: '02', m: '03', s: '04', ms: '567' }
70
- */
71
- export declare function getCountdownParts(diff: number): {
72
- d: string;
73
- h: string;
74
- m: string;
75
- s: string;
76
- ms: string;
77
- };
78
- /**
79
- * 通过出生日期计算年龄
80
- * @param birthdate 生日日期,支持多种格式(会被自动解析)
81
- * @returns 年龄对象,包含 `age`(年龄数值)和 `type`(年龄单位,'year' 表示年,'month' 表示月)
82
- * @example
83
- * // 假设当前日期为 2025-11-19
84
- * getAgeByBirthdate('2025-05-10'); // { age: 6, type: 'month' }
85
- * getAgeByBirthdate('2020-11-19'); // { age: 5, type: 'year' }
86
- * getAgeByBirthdate('2020-12-01'); // { age: 4, type: 'year' }(生日还没到, 所以年龄是4岁)
87
- */
88
- export declare function getAgeByBirthdate(birthdate: string): {
89
- age: number;
90
- type: string;
91
- };
92
- /**
93
- * 对外抛出 dayjs 以便全局配置
94
- * @example
95
- * 切换语言
96
- * dayjs.locale('en'); // 切换为英文
97
- * dayjs.locale('zh-cn'); // 切换为中文 (默认)
98
- */
99
- export { dayjs };
100
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/day/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAU5B,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,UAAU,eAmB1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAe,YASpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAe,YASnE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM;;;;;;EAgB7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM;;;EAqBlD;AAED;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * 内部统一导出, 外部快捷引入: import {xx} from 'base-tools/ts'
3
- */
4
- export * from './array';
5
- export * from './async';
6
- export * from './bean';
7
- export * from './day';
8
- export * from './lodash';
9
- export * from './number';
10
- export * from './object';
11
- export * from './string';
12
- export * from './typing';
13
- export * from './url';
14
- export * from './validator';
15
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * re-export 全量 lodash-es
3
- * 文档: https://www.lodashjs.com/
4
- * 目的: 从工具库统一loadsh版本,避免项目多个版本冲突
5
- * 注意: 需在tsup.config.ts加入noExternal: ['lodash-es'],确保打包时不被忽略
6
- */
7
- export * from 'lodash-es';
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/lodash/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,WAAW,CAAC"}
@@ -1,137 +0,0 @@
1
- import BigNumber from 'bignumber.js';
2
- /**
3
- * 数值入参类型。
4
- * 支持原生 `number`、`string`(包含小数、科学计数法等)以及 `BigNumber`。
5
- */
6
- export type NumLike = string | number | BigNumber;
7
- /**
8
- * 将任意 `NumLike` 统一转换为 `BigNumber` 实例。
9
- * @param x 任意支持的数值入参。
10
- * @returns `BigNumber` 实例。
11
- * @example
12
- * big('0.1'); // => BigNumber
13
- * big(0.2); // => BigNumber
14
- */
15
- export declare function big(x: NumLike): BigNumber;
16
- /**
17
- * 高精度加法(支持多个参数连加)。
18
- * @example
19
- * bigAdd(0.1, 0.2); // => 0.3
20
- * bigAdd('0.1', '0.2'); // => 0.3
21
- * bigAdd(1, 2, 3, 4); // => 10 // 多参数连加: 1+2+3+4
22
- */
23
- export declare function bigAdd(a: NumLike, ...rest: NumLike[]): number;
24
- /**
25
- * 高精度减法(支持多个参数连减)。
26
- * @example
27
- * bigSub(1, 0.9); // => 0.1
28
- * bigSub('1.1', '0.2'); // => 0.9
29
- * bigSub(10, 1, 2, 3); // => 4 // 多参数连减: 10-1-2-3
30
- */
31
- export declare function bigSub(a: NumLike, ...rest: NumLike[]): number;
32
- /**
33
- * 高精度乘法(支持多个参数连乘)。
34
- * @example
35
- * bigMul(0.1, 0.2); // => 0.02
36
- * bigMul('1.5', '3'); // => 4.5
37
- * bigMul(2, 3, 4); // => 24 // 多参数连乘: 2*3*4
38
- */
39
- export declare function bigMul(a: NumLike, ...rest: NumLike[]): number;
40
- /**
41
- * 高精度除法(支持多个参数连除)。
42
- * @example
43
- * bigDiv(1, 3); // => 0.333333...
44
- * bigDiv('10', '4'); // => 2.5
45
- * bigDiv(100, 5, 2); // => 10 // 多参数连除: 100/5/2
46
- */
47
- export declare function bigDiv(a: NumLike, ...rest: NumLike[]): number;
48
- /**
49
- * 指数运算
50
- * @param x 底数。
51
- * @param y 指数。
52
- * @returns 计算结果。
53
- * @example
54
- * bigPow(2, 3); // => 8
55
- * bigPow('2.5', 2); // => 6.25
56
- */
57
- export declare function bigPow(x: NumLike, y: NumLike): number;
58
- /**
59
- * 四舍五入到指定位数
60
- * @param x 需要舍入的数值。
61
- * @param dp 保留的小数位数,默认 `0`(取整)。
62
- * @param rm 舍入模式,默认 `ROUND_HALF_UP`(四舍五入)。
63
- * @returns 舍入后的数值。
64
- * @example
65
- * bigRound(1.6); // => 2
66
- * bigRound('1.234', 2); // => 1.23
67
- * bigRound('1.235', 2); // => 1.24
68
- * bigRound('1.299', 2, BigNumber.ROUND_DOWN); // => 1.29
69
- */
70
- export declare function bigRound(x: NumLike, dp?: number, rm?: BigNumber.RoundingMode): number;
71
- /**
72
- * 将数值按指定位数格式化为字符串(保留小数位)。
73
- * @param x 需要格式化的数值。
74
- * @param dp 保留的小数位数,默认 `2`。
75
- * @param rm 舍入模式,默认 `ROUND_HALF_UP`(四舍五入)。
76
- * @returns 格式化后的字符串。
77
- * @example
78
- * toFixed('1'); // => '1.00'
79
- * +toFixed('1'); // => 1
80
- * toFixed(1.2345); // => '1.23'
81
- * toFixed(1.2345, 3); // => '1.235'
82
- * toFixed('1.2345', 0, BigNumber.ROUND_UP); // => '2'
83
- */
84
- export declare function toFixed(x: NumLike, dp?: number, rm?: BigNumber.RoundingMode): string;
85
- /**
86
- * 比较两个数值大小。
87
- * @example
88
- * bigCompare('2', '10'); // => -1
89
- * bigCompare(3, 3); // => 0
90
- * bigCompare('10', 2); // => 1
91
- */
92
- export declare function bigCompare(a: NumLike, b: NumLike): -1 | 0 | 1 | null;
93
- /**
94
- * 判断两个数值是否相等。
95
- * @example
96
- * bigEqual('1.0', 1); // => true
97
- * bigEqual(2, 1); // => false
98
- */
99
- export declare function bigEqual(a: NumLike, b: NumLike): boolean;
100
- /**
101
- * 判断 a 是否大于 b。
102
- * @example
103
- * bigGt(2, 1); // => true
104
- * bigGt(1, 2); // => false
105
- */
106
- export declare function bigGt(a: NumLike, b: NumLike): boolean;
107
- /**
108
- * 判断 a 是否大于等于 b。
109
- * @example
110
- * bigGte(2, 2); // => true
111
- * bigGte(1, 2); // => false
112
- */
113
- export declare function bigGte(a: NumLike, b: NumLike): boolean;
114
- /**
115
- * 判断 a 是否小于 b。
116
- * @example
117
- * bigLt(1, 2); // => true
118
- * bigLt(2, 1); // => false
119
- */
120
- export declare function bigLt(a: NumLike, b: NumLike): boolean;
121
- /**
122
- * 判断 a 是否小于等于 b。
123
- * @example
124
- * bigLte(2, 2); // => true
125
- * bigLte(1, 2); // => true
126
- * bigLte(2, 1); // => false
127
- */
128
- export declare function bigLte(a: NumLike, b: NumLike): boolean;
129
- /**
130
- * 导出 BigNumber 类
131
- * @example
132
- * BigNumber.ROUND_HALF_UP; // 使用类型
133
- * BigNumber.set(config); // 设置全局配置
134
- * const bn = new BigNumber('123456.789'); // 创建实例
135
- */
136
- export { BigNumber };
137
- //# sourceMappingURL=big.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"big.d.ts","sourceRoot":"","sources":["../../../src/ts/number/big.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,SAAS,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAIpD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAIpD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAIpD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,UAIpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,UAE5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,SAAI,EAAE,EAAE,GAAE,SAAS,CAAC,YAAsC,UAEhG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CACrB,CAAC,EAAE,OAAO,EACV,EAAE,SAAI,EACN,EAAE,GAAE,SAAS,CAAC,YAAsC,GACnD,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,88 +0,0 @@
1
- import { BigNumber } from './big';
2
- /**
3
- * 开头补零
4
- * @param n 数字
5
- * @param len 总长度,默认 2
6
- * @returns 零填充后的字符串
7
- * @example
8
- * zeroPad(1) // '01'
9
- * zeroPad(12) // '12'
10
- * zeroPad(12, 4) // '0012'
11
- */
12
- export declare function zeroPad(n: number | string, len?: number): string;
13
- /**
14
- * 给数字添加指定单位 (支持数字字符串,其他非法字符返回原值)
15
- * @param unit 单位
16
- * @param num 数字
17
- * @example
18
- * withUnit(0, 'px') // "0px"
19
- * withUnit(1, 'px') // "1px"
20
- * withUnit('1', 'rpx') // "1rpx"
21
- * withUnit('1', '%') // "1%"
22
- * withUnit('auto', 'px') // "auto"
23
- * withUnit(null | undefined | '') // ""
24
- */
25
- export declare function withUnit(num?: number | string, unit?: string): string;
26
- /**
27
- * 给数字添加px单位 (支持数字字符串,其他非法字符返回原值)
28
- * @example
29
- * withUnitPx(10) // "10px"
30
- * withUnitPx('10') // "10px"
31
- * withUnitPx('10px') // "10px"
32
- * withUnitPx("auto") // "auto"
33
- * withUnitPx("30%") // "30%"
34
- * withUnitPx(null | undefined | '') // ""
35
- * withUnitPx(0) // "0px"
36
- */
37
- export declare function withUnitPx(num?: string | number): string;
38
- /**
39
- * 给数字添加距离单位:当数值大于等于 1000m 时转换为 km,否则显示 m(最多两位小数、无无意义补零)
40
- * @example
41
- * withDistance(5); // => '5m'
42
- * withDistance(999.456); // => '999.46m'
43
- * withDistance(1000); // => '1km'
44
- * withDistance('1500'); // => '1.5km'
45
- * withDistance('1728'); // => '1.73km'
46
- */
47
- export declare function withDistance(m: number | string): string;
48
- /**
49
- * 数字转千分位字符串(保留小数与符号)。
50
- * @example
51
- * toThousandth(1234567); // => '1,234,567'
52
- * toThousandth('1234567.89'); // => '1,234,567.89'
53
- * toThousandth('-987654'); // => '-987,654'
54
- */
55
- export declare function toThousandth(str: number | string): string;
56
- /**
57
- * 阿拉伯数字转中文整数(忽略小数;支持负数)。
58
- * @param num 输入的数字或数字字符串(小数部分将被丢弃)
59
- * @returns 中文数字字符串;非法输入返回空字符串
60
- * @example
61
- * toChineseNum(123456); // "十二万三千四百五十六"
62
- * toChineseNum(-10008); // "负一万零八"
63
- * `第${toChineseNum(123)}条` // "第一百二十三条"
64
- */
65
- export declare function toChineseNum(num: number | string): string;
66
- /**
67
- * 金额转中文大写(支持角/分/厘,精度控制)。
68
- * @param amount 金额(支持 number | string),非法或非有限数返回空串
69
- * @param opts 配置项
70
- * @param opts.precision 保留小数位(0~3),对应:0无小数、1角、2角分、3角分厘;默认 2
71
- * @param opts.rm 舍入模式,默认 `BigNumber.ROUND_HALF_UP`(四舍五入)
72
- * @param opts.yuanChar 元单位字符(`'元' | '圆'`),默认 `'元'`
73
- * @returns 中文大写金额字符串;示例:`壹佰贰拾叁元肆角伍分`
74
- * @example
75
- * toChineseCurrency(0) // '零元整'
76
- * toChineseCurrency(10) // '拾元整'
77
- * toChineseCurrency(101) // '壹佰零壹元整'
78
- * toChineseCurrency(1001000) // '壹佰万零壹仟元整'
79
- * toChineseCurrency(1001.01) // '壹仟零壹元壹分'
80
- * toChineseCurrency('1234.5679', { precision: 3 }) // '壹仟贰佰叁拾肆元伍角陆分捌厘'
81
- * toChineseCurrency(-1.2) // '负壹元贰角'
82
- */
83
- export declare function toChineseCurrency(amount: number | string, opts?: {
84
- precision?: 0 | 1 | 2 | 3;
85
- rm?: BigNumber.RoundingMode;
86
- yuanChar?: '元' | '圆';
87
- }): string;
88
- //# sourceMappingURL=format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/ts/number/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAI,UAElD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,SAAK,UAUxD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,UAE/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAIvD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAqBzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,UA4ChD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,IAAI,GAAE;IACJ,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,EAAE,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC;IAC5B,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;CACjB,GACL,MAAM,CAyER"}
@@ -1,4 +0,0 @@
1
- export * from './big';
2
- export * from './format';
3
- export * from './random';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * 随机生成 `a` 到 `b` 的整数(闭区间,包含两端)。
3
- * - 自动交换边界,按从小到大处理。
4
- * - 下界向上取整、上界向下取整后再取值。
5
- * @param a 边界值。
6
- * @param b 边界值。
7
- * @returns 闭区间内的随机整数。
8
- * @example
9
- * randomInt(0, 10); // => 0..10 之间的随机整数(含 0 与 10)
10
- * randomInt(10, 0); // => 0..10 之间的随机整数(含 0 与 10)
11
- * randomInt(5.2, 10.8); // => 6..10 之间取整随机数(含 6 与 10)
12
- */
13
- export declare function randomInt(a: number, b: number): number;
14
- /**
15
- * 随机生成 `a` 到 `b` 的浮点数(半开区间,包含下界不包含上界)。
16
- * - 自动交换边界,按从小到大处理。
17
- * @param a 边界值。
18
- * @param b 边界值。
19
- * @returns 半开区间内的随机浮点数。
20
- * @example
21
- * randomFloat(0, 10); // => [0, 10) 内的随机浮点数
22
- * randomFloat(10, 0); // => [0, 10) 内的随机浮点数
23
- * randomFloat(5.2, 10.8); // => [5.2, 10.8) 内的随机浮点数
24
- */
25
- export declare function randomFloat(a: number, b: number): number;
26
- /**
27
- * 随机生成一个布尔值。
28
- * @returns 随机布尔值。
29
- * @example
30
- * randomBoolean(); // => 随机返回 true 或 false
31
- */
32
- export declare function randomBoolean(): boolean;
33
- //# sourceMappingURL=random.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/ts/number/random.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAWxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * 获取对象键名数组(类型安全)。
3
- * 注:内置 `Object.keys` 与 `lodash-es` 的 `keys` 在 TS 中通常返回 `string[]`,无法精确到 `keyof T`。
4
- * @param obj 目标对象
5
- * @returns 类型精确的 `Array<keyof T>`
6
- * @example
7
- * const o = { a: 1, b: 'x' };
8
- * const keys = getObjectKeys(o); // type: ('a' | 'b')[], value: ['a','b']
9
- */
10
- export declare function getObjectKeys<T extends object>(obj: T): Array<keyof T>;
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/object/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAEtE"}
@@ -1,33 +0,0 @@
1
- /**
2
- * 文本脱敏
3
- * @param s 原始文本
4
- * @param keepLeft 保留左侧字符数(默认 1)
5
- * @param keepRight 保留右侧字符数(默认 0)
6
- * @param maskChar 脱敏字符(默认 `*`)
7
- * @returns 脱敏文本
8
- * @example
9
- * toMaskText('王小明', 1, 0) // => '王*'
10
- * toMaskText('王小明', 1, 1) // => '王*明'
11
- * toMaskText('13800138000', 3, 4) // => '138****8000'
12
- */
13
- export declare function toMaskText(s: string, keepLeft?: number, keepRight?: number, maskChar?: string): string;
14
- /**
15
- * 手机号中间打星:保留前三位与后四位,中间打 `*`。
16
- * @param phone 手机号字符串
17
- * @returns 遮蔽后的手机号
18
- * @example
19
- * toMaskPhone('13800138000') // => '138****8000'
20
- */
21
- export declare function toMaskPhone(phone: string): string;
22
- /**
23
- * 姓名打星:
24
- * - 长度 ≤ 2:保留首字,其余打 `*`
25
- * - 长度 ≥ 3:保留首尾,各打星中间
26
- * @param name 姓名字符串
27
- * @returns 遮蔽后的姓名
28
- * @example
29
- * toMaskName('张三') // => '张*'
30
- * toMaskName('王小明') // => '王*明'
31
- */
32
- export declare function toMaskName(name: string): string;
33
- //# sourceMappingURL=format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/ts/string/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,SAAS,SAAI,EAAE,QAAQ,SAAM,UAYhF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,UAExC;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,UAItC"}
@@ -1,4 +0,0 @@
1
- export * from './format';
2
- export * from './random';
3
- export * from './other';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ts/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * 计算字符串在 UTF-8 编码下的字节长度。
3
- * 使用场景:
4
- * 1) 按字节限制表单输入(避免超过后端/数据库字段上限)
5
- * 2) 评估网络传输、缓存(Redis/消息队列)开销
6
- * 3) 根据字节数截断或提示用户(而非按字符数)
7
- * @param str 输入的字符串
8
- * @returns 字符串的字节长度
9
- * @example
10
- * getStringByteLength('abc') // 3
11
- * getStringByteLength('中文') // 6
12
- * getStringByteLength('😊') // 4
13
- */
14
- export declare function getStringByteLength(str: string): number;
15
- //# sourceMappingURL=other.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"other.d.ts","sourceRoot":"","sources":["../../../src/ts/string/other.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmBvD"}
@@ -1,27 +0,0 @@
1
- /**
2
- * 生成UUID
3
- * @returns UUID字符串
4
- * @example
5
- * const uuid = createUUID() // '7982fcfe-5721-4632-bede-6000885be57d'
6
- */
7
- export declare function createUUID(): string;
8
- /**
9
- * 生成随机字符串id
10
- * - 常用于生成元素标签的id (默认加上'id_'前缀, 避免小程序中数字开头的id导致查询节点信息失败)
11
- * @param prefix 前缀, 默认 'id_'
12
- * @returns 随机字符串
13
- * @example
14
- * const id = createRandId(); // 'id_0rjuuuqv60xi'
15
- * const id = createRandId('canvas_'); // 'canvas_v82a7ctm09q'
16
- */
17
- export declare function createRandId(prefix?: string): string;
18
- /**
19
- * 时间+固定位数的随机数字字符串
20
- * @param digits 随机部分的位数,默认 6
21
- * @returns 时间+随机数字字符串
22
- * @example
23
- * const traceId = createTimeRandId(); // '1763002648039123456'
24
- * const traceId = createTimeRandId(8); // '176300264803912345678'
25
- */
26
- export declare function createTimeRandId(digits?: number): string;
27
- //# sourceMappingURL=random.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/ts/string/random.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,WAMzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAQ,UAE1C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,MAAU,UAMlD"}