@base-web-kits/base-tools-ts 0.8.16 → 0.8.18
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/base-tools-ts.umd.global.js +2 -55
- package/dist/base-tools-ts.umd.global.js +2 -55
- package/dist/index.cjs +0 -37
- package/dist/index.js +0 -36
- package/package.json +1 -1
- package/dist/array/index.d.ts +0 -9
- package/dist/array/index.d.ts.map +0 -1
- package/dist/async/index.d.ts +0 -14
- package/dist/async/index.d.ts.map +0 -1
- package/dist/bean/EventBus.d.ts +0 -36
- package/dist/bean/EventBus.d.ts.map +0 -1
- package/dist/bean/index.d.ts +0 -2
- package/dist/bean/index.d.ts.map +0 -1
- package/dist/day/index.d.ts +0 -100
- package/dist/day/index.d.ts.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/lodash/index.d.ts +0 -8
- package/dist/lodash/index.d.ts.map +0 -1
- package/dist/number/big.d.ts +0 -137
- package/dist/number/big.d.ts.map +0 -1
- package/dist/number/format.d.ts +0 -88
- package/dist/number/format.d.ts.map +0 -1
- package/dist/number/index.d.ts +0 -4
- package/dist/number/index.d.ts.map +0 -1
- package/dist/number/random.d.ts +0 -33
- package/dist/number/random.d.ts.map +0 -1
- package/dist/object/index.d.ts +0 -11
- package/dist/object/index.d.ts.map +0 -1
- package/dist/string/format.d.ts +0 -33
- package/dist/string/format.d.ts.map +0 -1
- package/dist/string/index.d.ts +0 -4
- package/dist/string/index.d.ts.map +0 -1
- package/dist/string/other.d.ts +0 -15
- package/dist/string/other.d.ts.map +0 -1
- package/dist/string/random.d.ts +0 -27
- package/dist/string/random.d.ts.map +0 -1
- package/dist/typing/index.d.ts +0 -134
- package/dist/typing/index.d.ts.map +0 -1
- package/dist/url/file/index.d.ts +0 -22
- package/dist/url/file/index.d.ts.map +0 -1
- package/dist/url/index.d.ts +0 -5
- package/dist/url/index.d.ts.map +0 -1
- package/dist/url/oss/index.d.ts +0 -77
- package/dist/url/oss/index.d.ts.map +0 -1
- package/dist/url/param/index.d.ts +0 -49
- package/dist/url/param/index.d.ts.map +0 -1
- package/dist/url/qn/index.d.ts +0 -58
- package/dist/url/qn/index.d.ts.map +0 -1
- package/dist/validator/index.d.ts +0 -296
- package/dist/validator/index.d.ts.map +0 -1
|
@@ -710,7 +710,6 @@ var baseToolsTS = (() => {
|
|
|
710
710
|
var ts_exports = {};
|
|
711
711
|
__export(ts_exports, {
|
|
712
712
|
BigNumber: () => bignumber_default,
|
|
713
|
-
EventBus: () => EventBus,
|
|
714
713
|
add: () => add_default,
|
|
715
714
|
after: () => after_default,
|
|
716
715
|
appendUrlParam: () => appendUrlParam,
|
|
@@ -1135,58 +1134,6 @@ var baseToolsTS = (() => {
|
|
|
1135
1134
|
}
|
|
1136
1135
|
}
|
|
1137
1136
|
|
|
1138
|
-
// node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
1139
|
-
function mitt_default(n) {
|
|
1140
|
-
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
1141
|
-
var i = n.get(t);
|
|
1142
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
1143
|
-
}, off: function(t, e) {
|
|
1144
|
-
var i = n.get(t);
|
|
1145
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
1146
|
-
}, emit: function(t, e) {
|
|
1147
|
-
var i = n.get(t);
|
|
1148
|
-
i && i.slice().map(function(n2) {
|
|
1149
|
-
n2(e);
|
|
1150
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
1151
|
-
n2(t, e);
|
|
1152
|
-
});
|
|
1153
|
-
} };
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
// src/ts/bean/EventBus.ts
|
|
1157
|
-
var EventBus = class {
|
|
1158
|
-
_emitter = mitt_default();
|
|
1159
|
-
/** 订阅 */
|
|
1160
|
-
on(type, fn) {
|
|
1161
|
-
this._emitter.on(type, fn);
|
|
1162
|
-
return this;
|
|
1163
|
-
}
|
|
1164
|
-
/** 订阅一次 */
|
|
1165
|
-
once(type, fn) {
|
|
1166
|
-
const wrap2 = (event) => {
|
|
1167
|
-
this._emitter.off(type, wrap2);
|
|
1168
|
-
fn(event);
|
|
1169
|
-
};
|
|
1170
|
-
this._emitter.on(type, wrap2);
|
|
1171
|
-
return this;
|
|
1172
|
-
}
|
|
1173
|
-
/** 发布 */
|
|
1174
|
-
emit(type, event) {
|
|
1175
|
-
this._emitter.emit(type, event);
|
|
1176
|
-
return this;
|
|
1177
|
-
}
|
|
1178
|
-
/** 移除 */
|
|
1179
|
-
off(type, fn) {
|
|
1180
|
-
this._emitter.off(type, fn);
|
|
1181
|
-
return this;
|
|
1182
|
-
}
|
|
1183
|
-
/** 清空 */
|
|
1184
|
-
clear() {
|
|
1185
|
-
this._emitter.all.clear();
|
|
1186
|
-
return this;
|
|
1187
|
-
}
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
1137
|
// src/ts/day/index.ts
|
|
1191
1138
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
1192
1139
|
var import_customParseFormat = __toESM(require_customParseFormat(), 1);
|
|
@@ -4420,8 +4367,8 @@ var baseToolsTS = (() => {
|
|
|
4420
4367
|
var ListCache_default = ListCache;
|
|
4421
4368
|
|
|
4422
4369
|
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js
|
|
4423
|
-
var
|
|
4424
|
-
var Map_default =
|
|
4370
|
+
var Map = getNative_default(root_default, "Map");
|
|
4371
|
+
var Map_default = Map;
|
|
4425
4372
|
|
|
4426
4373
|
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js
|
|
4427
4374
|
function mapCacheClear() {
|
|
@@ -710,7 +710,6 @@ var baseToolsTS = (() => {
|
|
|
710
710
|
var ts_exports = {};
|
|
711
711
|
__export(ts_exports, {
|
|
712
712
|
BigNumber: () => bignumber_default,
|
|
713
|
-
EventBus: () => EventBus,
|
|
714
713
|
add: () => add_default,
|
|
715
714
|
after: () => after_default,
|
|
716
715
|
appendUrlParam: () => appendUrlParam,
|
|
@@ -1135,58 +1134,6 @@ var baseToolsTS = (() => {
|
|
|
1135
1134
|
}
|
|
1136
1135
|
}
|
|
1137
1136
|
|
|
1138
|
-
// node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
|
|
1139
|
-
function mitt_default(n) {
|
|
1140
|
-
return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
|
|
1141
|
-
var i = n.get(t);
|
|
1142
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
1143
|
-
}, off: function(t, e) {
|
|
1144
|
-
var i = n.get(t);
|
|
1145
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
1146
|
-
}, emit: function(t, e) {
|
|
1147
|
-
var i = n.get(t);
|
|
1148
|
-
i && i.slice().map(function(n2) {
|
|
1149
|
-
n2(e);
|
|
1150
|
-
}), (i = n.get("*")) && i.slice().map(function(n2) {
|
|
1151
|
-
n2(t, e);
|
|
1152
|
-
});
|
|
1153
|
-
} };
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
// src/ts/bean/EventBus.ts
|
|
1157
|
-
var EventBus = class {
|
|
1158
|
-
_emitter = mitt_default();
|
|
1159
|
-
/** 订阅 */
|
|
1160
|
-
on(type, fn) {
|
|
1161
|
-
this._emitter.on(type, fn);
|
|
1162
|
-
return this;
|
|
1163
|
-
}
|
|
1164
|
-
/** 订阅一次 */
|
|
1165
|
-
once(type, fn) {
|
|
1166
|
-
const wrap2 = (event) => {
|
|
1167
|
-
this._emitter.off(type, wrap2);
|
|
1168
|
-
fn(event);
|
|
1169
|
-
};
|
|
1170
|
-
this._emitter.on(type, wrap2);
|
|
1171
|
-
return this;
|
|
1172
|
-
}
|
|
1173
|
-
/** 发布 */
|
|
1174
|
-
emit(type, event) {
|
|
1175
|
-
this._emitter.emit(type, event);
|
|
1176
|
-
return this;
|
|
1177
|
-
}
|
|
1178
|
-
/** 移除 */
|
|
1179
|
-
off(type, fn) {
|
|
1180
|
-
this._emitter.off(type, fn);
|
|
1181
|
-
return this;
|
|
1182
|
-
}
|
|
1183
|
-
/** 清空 */
|
|
1184
|
-
clear() {
|
|
1185
|
-
this._emitter.all.clear();
|
|
1186
|
-
return this;
|
|
1187
|
-
}
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
1137
|
// src/ts/day/index.ts
|
|
1191
1138
|
var import_dayjs = __toESM(require_dayjs_min(), 1);
|
|
1192
1139
|
var import_customParseFormat = __toESM(require_customParseFormat(), 1);
|
|
@@ -4420,8 +4367,8 @@ var baseToolsTS = (() => {
|
|
|
4420
4367
|
var ListCache_default = ListCache;
|
|
4421
4368
|
|
|
4422
4369
|
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js
|
|
4423
|
-
var
|
|
4424
|
-
var Map_default =
|
|
4370
|
+
var Map = getNative_default(root_default, "Map");
|
|
4371
|
+
var Map_default = Map;
|
|
4425
4372
|
|
|
4426
4373
|
// node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js
|
|
4427
4374
|
function mapCacheClear() {
|
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BigNumber: () => import_bignumber.default,
|
|
34
|
-
EventBus: () => EventBus,
|
|
35
34
|
add: () => add_default,
|
|
36
35
|
after: () => after_default,
|
|
37
36
|
appendUrlParam: () => appendUrlParam,
|
|
@@ -457,41 +456,6 @@ async function toAsync(p) {
|
|
|
457
456
|
}
|
|
458
457
|
}
|
|
459
458
|
|
|
460
|
-
// src/ts/bean/EventBus.ts
|
|
461
|
-
var import_mitt = __toESM(require("mitt"), 1);
|
|
462
|
-
var EventBus = class {
|
|
463
|
-
_emitter = (0, import_mitt.default)();
|
|
464
|
-
/** 订阅 */
|
|
465
|
-
on(type, fn) {
|
|
466
|
-
this._emitter.on(type, fn);
|
|
467
|
-
return this;
|
|
468
|
-
}
|
|
469
|
-
/** 订阅一次 */
|
|
470
|
-
once(type, fn) {
|
|
471
|
-
const wrap2 = (event) => {
|
|
472
|
-
this._emitter.off(type, wrap2);
|
|
473
|
-
fn(event);
|
|
474
|
-
};
|
|
475
|
-
this._emitter.on(type, wrap2);
|
|
476
|
-
return this;
|
|
477
|
-
}
|
|
478
|
-
/** 发布 */
|
|
479
|
-
emit(type, event) {
|
|
480
|
-
this._emitter.emit(type, event);
|
|
481
|
-
return this;
|
|
482
|
-
}
|
|
483
|
-
/** 移除 */
|
|
484
|
-
off(type, fn) {
|
|
485
|
-
this._emitter.off(type, fn);
|
|
486
|
-
return this;
|
|
487
|
-
}
|
|
488
|
-
/** 清空 */
|
|
489
|
-
clear() {
|
|
490
|
-
this._emitter.all.clear();
|
|
491
|
-
return this;
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
|
|
495
459
|
// src/ts/day/index.ts
|
|
496
460
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
497
461
|
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"), 1);
|
|
@@ -8567,7 +8531,6 @@ function isLongitude(s) {
|
|
|
8567
8531
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8568
8532
|
0 && (module.exports = {
|
|
8569
8533
|
BigNumber,
|
|
8570
|
-
EventBus,
|
|
8571
8534
|
add,
|
|
8572
8535
|
after,
|
|
8573
8536
|
appendUrlParam,
|
package/dist/index.js
CHANGED
|
@@ -16,41 +16,6 @@ async function toAsync(p) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// src/ts/bean/EventBus.ts
|
|
20
|
-
import mitt from "mitt";
|
|
21
|
-
var EventBus = class {
|
|
22
|
-
_emitter = mitt();
|
|
23
|
-
/** 订阅 */
|
|
24
|
-
on(type, fn) {
|
|
25
|
-
this._emitter.on(type, fn);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/** 订阅一次 */
|
|
29
|
-
once(type, fn) {
|
|
30
|
-
const wrap2 = (event) => {
|
|
31
|
-
this._emitter.off(type, wrap2);
|
|
32
|
-
fn(event);
|
|
33
|
-
};
|
|
34
|
-
this._emitter.on(type, wrap2);
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
/** 发布 */
|
|
38
|
-
emit(type, event) {
|
|
39
|
-
this._emitter.emit(type, event);
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
/** 移除 */
|
|
43
|
-
off(type, fn) {
|
|
44
|
-
this._emitter.off(type, fn);
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
/** 清空 */
|
|
48
|
-
clear() {
|
|
49
|
-
this._emitter.all.clear();
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
19
|
// src/ts/day/index.ts
|
|
55
20
|
import dayjs from "dayjs";
|
|
56
21
|
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
@@ -8125,7 +8090,6 @@ function isLongitude(s) {
|
|
|
8125
8090
|
}
|
|
8126
8091
|
export {
|
|
8127
8092
|
BigNumber,
|
|
8128
|
-
EventBus,
|
|
8129
8093
|
add_default as add,
|
|
8130
8094
|
after_default as after,
|
|
8131
8095
|
appendUrlParam,
|
package/package.json
CHANGED
package/dist/array/index.d.ts
DELETED
|
@@ -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"}
|
package/dist/async/index.d.ts
DELETED
|
@@ -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"}
|
package/dist/bean/EventBus.d.ts
DELETED
|
@@ -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"}
|
package/dist/bean/index.d.ts
DELETED
package/dist/bean/index.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/day/index.d.ts
DELETED
|
@@ -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
|
package/dist/day/index.d.ts.map
DELETED
|
@@ -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
|
package/dist/index.d.ts.map
DELETED
|
@@ -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"}
|
package/dist/lodash/index.d.ts
DELETED
|
@@ -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"}
|
package/dist/number/big.d.ts
DELETED
|
@@ -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
|
package/dist/number/big.d.ts.map
DELETED
|
@@ -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"}
|