@astrolimit/fc-utils 25.12.18 → 26.1.3
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/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,13 +59,13 @@ declare function deepCopy<T>(value: T): T;
|
|
|
59
59
|
declare function deepExtendArgs<T extends Record<string, any> | any[]>(origin: T, ...lst: any[]): T;
|
|
60
60
|
//#endregion
|
|
61
61
|
//#region src/extend.d.ts
|
|
62
|
-
declare function extend(): any;
|
|
62
|
+
declare function extend(...args: Record<string | number | symbol, any>[]): any;
|
|
63
63
|
declare function copy<T>(obj: T): T;
|
|
64
64
|
//#endregion
|
|
65
65
|
//#region src/json.d.ts
|
|
66
66
|
declare function toJson(obj: Record<string | number, any>, space: number): string;
|
|
67
|
-
declare function parseFn(fn: string, mode
|
|
68
|
-
declare function parseJson(json: string, mode
|
|
67
|
+
declare function parseFn(fn: string, mode?: boolean): any;
|
|
68
|
+
declare function parseJson(json: string, mode?: boolean): any;
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/modify.d.ts
|
|
71
71
|
declare function $set<T extends Record<string, any>, K extends keyof T>(target: T, field: K, value: T[K]): void;
|
|
@@ -140,7 +140,7 @@ interface IHandler {
|
|
|
140
140
|
(...args: any[]): void;
|
|
141
141
|
_once?: boolean;
|
|
142
142
|
}
|
|
143
|
-
declare function Mitt<T extends string>(all
|
|
143
|
+
declare function Mitt<T extends string>(all?: Map<T | "*", Array<IHandler>>): {
|
|
144
144
|
readonly $on: (type: T, handler: IHandler) => void;
|
|
145
145
|
readonly $once: (type: T, handler: IHandler) => void;
|
|
146
146
|
readonly $off: (type: T, handler: IHandler) => void;
|
|
@@ -154,4 +154,4 @@ declare function lower(str: string): string;
|
|
|
154
154
|
//#region src/mergeprops.d.ts
|
|
155
155
|
declare const mergeProps: (objects: Array<Record<string, any>>, initial?: Record<string, any>, opt?: Record<string, any>) => Record<string, any>;
|
|
156
156
|
//#endregion
|
|
157
|
-
export { $del, $set, Mitt, copy, debounce, deepCopy, deepExtend, deepExtendArgs, deepSet, extend, getSlot, hasProperty, is, lower, mergeProps, parseFn, parseJson, shortKey, toArray, toCase, toDate, toJson, toLine, toPromise, toString, uniqueId };
|
|
157
|
+
export { $del, $set, type IHandler, Mitt, copy, debounce, deepCopy, deepExtend, deepExtendArgs, deepSet, extend, getSlot, hasProperty, is, lower, mergeProps, parseFn, parseJson, shortKey, toArray, toCase, toDate, toJson, toLine, toPromise, toString, uniqueId };
|
package/dist/index.js
CHANGED
|
@@ -217,7 +217,7 @@ const _extends = Object.assign || function(a) {
|
|
|
217
217
|
for (let b, c = 1; c < arguments.length; c++) for (let d in b = arguments[c], b) Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
|
|
218
218
|
return a;
|
|
219
219
|
};
|
|
220
|
-
function extend() {
|
|
220
|
+
function extend(...args) {
|
|
221
221
|
return _extends.apply(this, arguments);
|
|
222
222
|
}
|
|
223
223
|
function copy(obj) {
|
|
@@ -363,29 +363,29 @@ function deepSet(data, idx, val) {
|
|
|
363
363
|
//#endregion
|
|
364
364
|
//#region src/mitt.ts
|
|
365
365
|
function Mitt(all) {
|
|
366
|
-
|
|
366
|
+
const finalAll = all || /* @__PURE__ */ new Map();
|
|
367
367
|
const mitt = {
|
|
368
368
|
$on(type, handler) {
|
|
369
|
-
const handlers =
|
|
370
|
-
if (!(handlers && handlers.push(handler)))
|
|
369
|
+
const handlers = finalAll.get(type);
|
|
370
|
+
if (!(handlers && handlers.push(handler))) finalAll.set(type, [handler]);
|
|
371
371
|
},
|
|
372
372
|
$once(type, handler) {
|
|
373
373
|
handler._once = true;
|
|
374
374
|
mitt.$on(type, handler);
|
|
375
375
|
},
|
|
376
376
|
$off(type, handler) {
|
|
377
|
-
const handlers =
|
|
377
|
+
const handlers = finalAll.get(type);
|
|
378
378
|
if (handlers) handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
|
379
379
|
},
|
|
380
380
|
$emit(type, ...args) {
|
|
381
|
-
(
|
|
381
|
+
(finalAll.get(type) || []).slice().map((handler) => {
|
|
382
382
|
if (handler._once) {
|
|
383
383
|
mitt.$off(type, handler);
|
|
384
384
|
delete handler._once;
|
|
385
385
|
}
|
|
386
386
|
handler(...args);
|
|
387
387
|
});
|
|
388
|
-
(
|
|
388
|
+
(finalAll.get("*") || []).slice().map((handler) => {
|
|
389
389
|
handler(type, args);
|
|
390
390
|
});
|
|
391
391
|
}
|