@base-web-kits/base-tools-ts 0.8.18 → 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.
@@ -710,6 +710,7 @@ var baseToolsTS = (() => {
710
710
  var ts_exports = {};
711
711
  __export(ts_exports, {
712
712
  BigNumber: () => bignumber_default,
713
+ EventBus: () => EventBus,
713
714
  add: () => add_default,
714
715
  after: () => after_default,
715
716
  appendUrlParam: () => appendUrlParam,
@@ -1134,6 +1135,58 @@ var baseToolsTS = (() => {
1134
1135
  }
1135
1136
  }
1136
1137
 
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
+
1137
1190
  // src/ts/day/index.ts
1138
1191
  var import_dayjs = __toESM(require_dayjs_min(), 1);
1139
1192
  var import_customParseFormat = __toESM(require_customParseFormat(), 1);
@@ -4367,8 +4420,8 @@ var baseToolsTS = (() => {
4367
4420
  var ListCache_default = ListCache;
4368
4421
 
4369
4422
  // node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js
4370
- var Map = getNative_default(root_default, "Map");
4371
- var Map_default = Map;
4423
+ var Map2 = getNative_default(root_default, "Map");
4424
+ var Map_default = Map2;
4372
4425
 
4373
4426
  // node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js
4374
4427
  function mapCacheClear() {
@@ -710,6 +710,7 @@ var baseToolsTS = (() => {
710
710
  var ts_exports = {};
711
711
  __export(ts_exports, {
712
712
  BigNumber: () => bignumber_default,
713
+ EventBus: () => EventBus,
713
714
  add: () => add_default,
714
715
  after: () => after_default,
715
716
  appendUrlParam: () => appendUrlParam,
@@ -1134,6 +1135,58 @@ var baseToolsTS = (() => {
1134
1135
  }
1135
1136
  }
1136
1137
 
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
+
1137
1190
  // src/ts/day/index.ts
1138
1191
  var import_dayjs = __toESM(require_dayjs_min(), 1);
1139
1192
  var import_customParseFormat = __toESM(require_customParseFormat(), 1);
@@ -4367,8 +4420,8 @@ var baseToolsTS = (() => {
4367
4420
  var ListCache_default = ListCache;
4368
4421
 
4369
4422
  // node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js
4370
- var Map = getNative_default(root_default, "Map");
4371
- var Map_default = Map;
4423
+ var Map2 = getNative_default(root_default, "Map");
4424
+ var Map_default = Map2;
4372
4425
 
4373
4426
  // node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js
4374
4427
  function mapCacheClear() {
package/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ 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,
34
35
  add: () => add_default,
35
36
  after: () => after_default,
36
37
  appendUrlParam: () => appendUrlParam,
@@ -456,6 +457,41 @@ async function toAsync(p) {
456
457
  }
457
458
  }
458
459
 
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
+
459
495
  // src/ts/day/index.ts
460
496
  var import_dayjs = __toESM(require("dayjs"), 1);
461
497
  var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"), 1);
@@ -8531,6 +8567,7 @@ function isLongitude(s) {
8531
8567
  // Annotate the CommonJS export names for ESM import in node:
8532
8568
  0 && (module.exports = {
8533
8569
  BigNumber,
8570
+ EventBus,
8534
8571
  add,
8535
8572
  after,
8536
8573
  appendUrlParam,
package/dist/index.js CHANGED
@@ -16,6 +16,41 @@ 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
+
19
54
  // src/ts/day/index.ts
20
55
  import dayjs from "dayjs";
21
56
  import customParseFormat from "dayjs/plugin/customParseFormat";
@@ -8090,6 +8125,7 @@ function isLongitude(s) {
8090
8125
  }
8091
8126
  export {
8092
8127
  BigNumber,
8128
+ EventBus,
8093
8129
  add_default as add,
8094
8130
  after_default as after,
8095
8131
  appendUrlParam,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-web-kits/base-tools-ts",
3
- "version": "0.8.18",
3
+ "version": "0.9.1",
4
4
  "sideEffects": false,
5
5
  "description": "Independent TS utilities package built from src/ts.",
6
6
  "keywords": [