@astrolimit/fc-utils 25.12.18 → 26.1.15

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 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: boolean): any;
68
- declare function parseJson(json: string, mode: boolean): any;
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: Map<T | "*", Array<IHandler>>): {
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) {
@@ -318,22 +318,22 @@ function parseJson(json, mode) {
318
318
 
319
319
  //#endregion
320
320
  //#region src/unique.ts
321
- var NumIdSingleton = class NumIdSingleton {
322
- static _value = 36;
323
- get value() {
324
- NumIdSingleton._value = NumIdSingleton._value + 1;
325
- if (NumIdSingleton._value > 1200) NumIdSingleton._value = 36;
326
- return NumIdSingleton._value.toString(36);
321
+ const counterProxy = {
322
+ _value: 370,
323
+ get len() {
324
+ return `${this._value}`.length;
325
+ },
326
+ get id() {
327
+ this._value = this._value + 1;
328
+ if (this.len > 10) this._value = 370;
329
+ return this._value;
327
330
  }
328
331
  };
329
- const numId = new NumIdSingleton();
330
- let id = 0;
331
332
  function uniqueId() {
332
- const num = 370 + ++id;
333
- return "F" + Math.random().toString(36).substr(3, 3) + Number(`${Date.now()}`).toString(36) + num.toString(36) + "c";
333
+ return "F" + Math.random().toString(36).slice(3, 6) + Date.now().toString(36) + counterProxy.id.toString(36) + "c";
334
334
  }
335
335
  function shortKey() {
336
- return Number(`${dayjs().diff(dayjs("2025-01-01"), "millisecond")}`).toString(36) + numId.value;
336
+ return dayjs().diff(dayjs("2025-01-01"), "millisecond").toString(36) + uniqueId().slice(3, 6);
337
337
  }
338
338
 
339
339
  //#endregion
@@ -363,29 +363,29 @@ function deepSet(data, idx, val) {
363
363
  //#endregion
364
364
  //#region src/mitt.ts
365
365
  function Mitt(all) {
366
- all = all || /* @__PURE__ */ new Map();
366
+ const finalAll = all || /* @__PURE__ */ new Map();
367
367
  const mitt = {
368
368
  $on(type, handler) {
369
- const handlers = all.get(type);
370
- if (!(handlers && handlers.push(handler))) all.set(type, [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 = all.get(type);
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
- (all.get(type) || []).slice().map((handler) => {
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
- (all.get("*") || []).slice().map((handler) => {
388
+ (finalAll.get("*") || []).slice().map((handler) => {
389
389
  handler(type, args);
390
390
  });
391
391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrolimit/fc-utils",
3
- "version": "25.12.018",
3
+ "version": "26.01.015",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "license": "SFR",