@codady/utils 0.0.9 → 0.0.10

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/utils.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- * @since Last modified: 2025-12-19 15:23:38
3
+ * @since Last modified: 2025-12-22 20:26:42
4
4
  * @name Utils for web front-end.
5
- * @version 0.0.9
5
+ * @version 0.0.10
6
6
  * @author AXUI development team <3217728223@qq.com>
7
7
  * @description This is a set of general-purpose JavaScript utility functions developed by the AXUI team. All functions are pure and do not involve CSS or other third-party libraries. They are suitable for any web front-end environment.
8
8
  * @see {@link https://www.axui.cn|Official website}
@@ -45,37 +45,100 @@
45
45
  //document.createElementNS('http://www.w3.org/1998/Math/MathML', 'math'); -> MathMLElement
46
46
  };
47
47
 
48
- const deepClone = (data) => {
49
- const dataType = getDataType(data);
50
- if (dataType === 'Object') {
51
- const newObj = {};
52
- const symbols = Object.getOwnPropertySymbols(data);
48
+ //支持原始值的复制,包括Number、String、Boolean、Null
49
+ //支持Date和Regex对象值复制(值转换)
50
+ //支持{},[],Set和Map的遍历
51
+ const deepClone = (data, options = {}) => {
52
+ const dataType = getDataType(data),
53
+ // Default options
54
+ opts = Object.assign({
55
+ cloneSet: true,
56
+ cloneMap: true,
57
+ cloneObject: true,
58
+ cloneArray: true,
59
+ //可重新构建
60
+ cloneDate: true,
61
+ cloneRegex: true,
62
+ //节点默认不复制
63
+ //cloneElement: false,
64
+ //cloneFragment: false,
65
+ }, options);
66
+ // Check interceptor - if it returns a value (not null/undefined), use it directly
67
+ if (opts.interceptor && typeof opts.interceptor === 'function') {
68
+ let result = opts.interceptor(data, dataType);
69
+ if ((result ?? false)) {
70
+ // Call onAfterClone if set
71
+ opts.onAfterClone?.({
72
+ output: result,
73
+ input: data,
74
+ type: dataType,
75
+ cloned: result !== data,
76
+ });
77
+ return result;
78
+ }
79
+ // If interceptor returns null/undefined, continue with normal cloning process
80
+ }
81
+ // Callback before cloning
82
+ opts.onBeforeClone?.(data, dataType);
83
+ let newData, cloned = true;
84
+ if (dataType === 'Object' && opts.cloneObject) {
85
+ const newObj = {}, symbols = Object.getOwnPropertySymbols(data);
53
86
  // Clone regular properties
54
87
  for (const key in data) {
55
- newObj[key] = deepClone(data[key]);
88
+ newObj[key] = deepClone(data[key], opts);
56
89
  }
57
90
  // Clone Symbol properties
58
91
  if (symbols.length > 0) {
59
92
  for (const symbol of symbols) {
60
- newObj[symbol] = deepClone(data[symbol]);
93
+ newObj[symbol] = deepClone(data[symbol], opts);
61
94
  }
62
95
  }
63
- return newObj;
96
+ newData = newObj;
64
97
  }
65
- else if (dataType === 'Array') {
66
- return data.map(item => deepClone(item));
98
+ else if (dataType === 'Array' && opts.cloneArray) {
99
+ newData = data.map(item => deepClone(item, opts));
67
100
  }
68
- else if (dataType === 'Date') {
69
- return new Date(data.getTime());
101
+ else if (dataType === 'Map' && opts.cloneMap) {
102
+ const newMap = new Map();
103
+ for (const [key, value] of data) {
104
+ // Both Map keys and values need deep cloning
105
+ newMap.set(deepClone(key, opts), deepClone(value, opts));
106
+ }
107
+ newData = newMap;
108
+ }
109
+ else if (dataType === 'Set' && opts.cloneSet) {
110
+ const newSet = new Set();
111
+ for (const value of data) {
112
+ // Set values need deep cloning
113
+ newSet.add(deepClone(value, opts));
114
+ }
115
+ newData = newSet;
70
116
  }
71
- else if (dataType === 'RegExp') {
117
+ else if (dataType === 'Date' && opts.cloneDate) {
118
+ newData = new Date(data.getTime());
119
+ }
120
+ else if (dataType === 'RegExp' && opts.cloneRegex) {
72
121
  const regex = data;
73
- return new RegExp(regex.source, regex.flags);
122
+ newData = new RegExp(regex.source, regex.flags);
123
+ // } else if ((dataType.includes('HTML') && opts.cloneElement) ||
124
+ // (dataType === 'DocumentFragment' && opts.cloneFragment)
125
+ //) {
126
+ //Text,Comment,HTML*Element,DocumentFragment,Attr
127
+ // newData = (data as any).cloneNode(true) as T;
74
128
  }
75
129
  else {
76
- // Number, String, Boolean, Symbol,Text,Comment,Set,Map, HTML*Element, Function,Error,Promise,ArrayBuffer,Blob,File, return directly
77
- return data;
130
+ // Number, String, Boolean, Symbol, Function,Error,Promise,ArrayBuffer,Blob,File, return directly
131
+ newData = data;
132
+ cloned = false;
78
133
  }
134
+ // Callback after cloning
135
+ opts.onAfterClone?.({
136
+ output: newData,
137
+ input: data,
138
+ type: dataType,
139
+ cloned,
140
+ });
141
+ return newData;
79
142
  };
80
143
 
81
144
  const deepCloneToJSON = (data) => {
@@ -106,7 +169,7 @@
106
169
  }
107
170
  };
108
171
 
109
- const mutableMethods = [
172
+ const arrayMutableMethods = [
110
173
  'push', 'pop', 'shift', 'unshift', 'splice',
111
174
  'sort', 'reverse', 'copyWithin', 'fill'
112
175
  ];
@@ -118,7 +181,7 @@
118
181
  }
119
182
  //使用默认
120
183
  if (!allowList || allowList?.length) {
121
- allowList = mutableMethods;
184
+ allowList = arrayMutableMethods;
122
185
  }
123
186
  const methods = {};
124
187
  for (let method of allowList) {
@@ -134,10 +197,10 @@
134
197
  context.addedItems = [...args];
135
198
  break;
136
199
  case 'pop':
137
- context.poppedValue = target[len - 1];
200
+ context.poppedItem = target[len - 1];
138
201
  break;
139
202
  case 'shift':
140
- context.shiftedValue = target[0];
203
+ context.shiftedItem = target[0];
141
204
  break;
142
205
  case 'splice':
143
206
  const [s, d] = args,
@@ -207,20 +270,160 @@
207
270
  return dataType;
208
271
  };
209
272
 
210
- const getUniqueId = (prefix, extra = true) => {
273
+ const getUniqueId = (options = {}) => {
274
+ const prefix = options.prefix, suffix = options.suffix, base10 = options.base10, base36 = options.base36;
211
275
  // Current timestamp in milliseconds (since Unix epoch)
212
276
  // This provides the primary uniqueness guarantee
213
277
  const timestamp = Date.now(),
214
278
  // Generate a base-36 random string (0-9, a-z)
215
279
  // Math.random() returns a number in [0, 1), converting to base-36 gives a compact representation
216
280
  // substring(2, 11) extracts 9 characters starting from index 2
217
- random = Math.random().toString(36).substring(2, 11),
281
+ //0.259854635->0.9crs03e8v2
282
+ base36Random = base36 ? '-' + Math.random().toString(36).substring(2, 11) : '',
218
283
  // Additional 4-digit random number for extra randomness
219
284
  // This helps avoid collisions in high-frequency generation scenarios
220
- extraRandom = extra ? '_' + Math.floor(Math.random() * 10000).toString().padStart(4, '0') : '', prefixString = prefix ? prefix + '_' : '';
285
+ base10Random = base10 ? '-' + Math.floor(Math.random() * 10000).toString().padStart(4, '0') : '', prefixString = prefix ? prefix + '-' : '', suffixString = suffix ? '-' + suffix : '';
221
286
  // Construct the final ID string
222
287
  // Format: [prefix_]timestamp_randomBase36_extraRandom
223
- return `${prefixString}${timestamp}_${random}${extraRandom}`;
288
+ return `${prefixString}${timestamp}${base36Random}${base10Random}${suffixString}`;
289
+ };
290
+
291
+ const setMutableMethods = ['add', 'delete', 'clear'];
292
+
293
+ const mapMutableMethods = ['set', 'delete', 'clear'];
294
+
295
+ const wrapSetMethods = ({ target, onBeforeMutate = () => { }, onAfterMutate = () => { }, allowList = setMutableMethods, props = {}, }) => {
296
+ // Validation: Ensure target is a Set
297
+ if (!(target instanceof Set)) {
298
+ throw new TypeError("The 'target' parameter must be a Set.");
299
+ }
300
+ // Create method wrappers
301
+ const methods = {};
302
+ // Helper to create wrapped method
303
+ const createWrappedMethod = (method) => {
304
+ return function (...args) {
305
+ const context = {};
306
+ // Capture pre-mutation context based on method
307
+ switch (method) {
308
+ case 'add': {
309
+ const [value] = args;
310
+ context.addedItem = value;
311
+ //context.existed=true,说明值重复
312
+ context.existed = target.has(value);
313
+ break;
314
+ }
315
+ case 'delete': {
316
+ const [value] = args;
317
+ context.existed = target.has(value);
318
+ context.deletedItem = context.existed ? value : undefined;
319
+ break;
320
+ }
321
+ case 'clear': {
322
+ context.clearedItems = Array.from(target);
323
+ //用来做验证
324
+ context.previousSize = target.size;
325
+ break;
326
+ }
327
+ }
328
+ // Execute before mutation callback
329
+ onBeforeMutate(context);
330
+ // Execute the native Set method
331
+ const result = target[method].apply(target, args);
332
+ // Construct patch object
333
+ const patch = {
334
+ method,
335
+ result,
336
+ args,
337
+ context,
338
+ target,
339
+ ...props
340
+ };
341
+ // Execute after mutation callback
342
+ onAfterMutate(patch);
343
+ return result;
344
+ };
345
+ };
346
+ // Wrap allowed methods
347
+ for (const method of allowList) {
348
+ if (setMutableMethods.includes(method)) {
349
+ methods[method] = createWrappedMethod(method);
350
+ }
351
+ }
352
+ // Add target reference
353
+ Object.defineProperty(methods, 'target', {
354
+ get: () => target,
355
+ enumerable: false,
356
+ configurable: false
357
+ });
358
+ return methods;
359
+ };
360
+
361
+ const wrapMapMethods = ({ target, onBeforeMutate = () => { }, onAfterMutate = () => { }, allowList = mapMutableMethods, props = {}, }) => {
362
+ // Validation: Ensure target is a Map
363
+ if (!(target instanceof Map)) {
364
+ throw new TypeError("The 'target' parameter must be a Map.");
365
+ }
366
+ // Create method wrappers
367
+ const methods = {};
368
+ // Helper to create wrapped method
369
+ const createWrappedMethod = (method) => {
370
+ return function (...args) {
371
+ const context = {};
372
+ // Capture pre-mutation context based on method
373
+ switch (method) {
374
+ case 'set': {
375
+ const [key, newValue] = args;
376
+ context.key = key;
377
+ context.newValue = newValue;
378
+ context.existed = target.has(key);
379
+ context.oldValue = context.existed ? target.get(key) : undefined;
380
+ break;
381
+ }
382
+ case 'delete': {
383
+ const [key] = args;
384
+ context.key = key;
385
+ context.existed = target.has(key);
386
+ context.value = context.existed ? target.get(key) : undefined;
387
+ break;
388
+ }
389
+ case 'clear': {
390
+ context.clearedItems = Array.from(target.entries());
391
+ //用来做验证
392
+ context.previousSize = target.size;
393
+ break;
394
+ }
395
+ }
396
+ // Execute before mutation callback
397
+ onBeforeMutate(context);
398
+ // Execute the native Map method
399
+ const result = target[method].apply(target, args);
400
+ // Construct patch object
401
+ const patch = {
402
+ method,
403
+ result,
404
+ args,
405
+ context,
406
+ target,
407
+ ...props
408
+ };
409
+ // Execute after mutation callback
410
+ onAfterMutate(patch);
411
+ return result;
412
+ };
413
+ };
414
+ // Wrap allowed methods
415
+ for (const method of allowList) {
416
+ if (mapMutableMethods.includes(method)) {
417
+ methods[method] = createWrappedMethod(method);
418
+ }
419
+ }
420
+ // Add target reference
421
+ Object.defineProperty(methods, 'target', {
422
+ get: () => target,
423
+ enumerable: false,
424
+ configurable: false
425
+ });
426
+ return methods;
224
427
  };
225
428
 
226
429
  const utils = {
@@ -232,7 +435,11 @@
232
435
  deepClone,
233
436
  deepCloneToJSON,
234
437
  wrapArrayMethods,
235
- mutableMethods,
438
+ arrayMutableMethods,
439
+ setMutableMethods,
440
+ mapMutableMethods,
441
+ wrapSetMethods,
442
+ wrapMapMethods,
236
443
  getUniqueId
237
444
  };
238
445
 
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @since Last modified: 2025-12-19 15:23:38
2
+ * @since Last modified: 2025-12-22 20:26:42
3
3
  * @name Utils for web front-end.
4
- * @version 0.0.9
4
+ * @version 0.0.10
5
5
  * @author AXUI development team <3217728223@qq.com>
6
6
  * @description This is a set of general-purpose JavaScript utility functions developed by the AXUI team. All functions are pure and do not involve CSS or other third-party libraries. They are suitable for any web front-end environment.
7
7
  * @see {@link https://www.axui.cn|Official website}
@@ -12,4 +12,4 @@
12
12
  * @copyright This software supports the MIT License, allowing free learning and commercial use, but please retain the terms 'ax,' 'axui,' 'AX,' and 'AXUI' within the software.
13
13
  * @license MIT license
14
14
  */
15
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).utils=t()}(this,function(){"use strict";const getDataType=e=>{let t,r=Object.prototype.toString.call(e).slice(8,-1);return t="Function"===r&&/^\s*class\s+/.test(e.toString())?"Class":"Object"===r&&Object.getPrototypeOf(e)!==Object.prototype?"Instance":r,t},deepClone=e=>{const t=getDataType(e);if("Object"===t){const t={},r=Object.getOwnPropertySymbols(e);for(const r in e)t[r]=deepClone(e[r]);if(r.length>0)for(const o of r)t[o]=deepClone(e[o]);return t}if("Array"===t)return e.map(e=>deepClone(e));if("Date"===t)return new Date(e.getTime());if("RegExp"===t){const t=e;return new RegExp(t.source,t.flags)}return e},deepCloneToJSON=e=>{const t=getDataType(e);if("Object"===t){const t={};for(const r in e)t[r]=deepCloneToJSON(e[r]);for(const e in t)void 0===t[e]&&Reflect.deleteProperty(t,e);return t}if("Array"===t){return e.map((e,t)=>deepCloneToJSON(e)).filter(e=>void 0!==e)}return["Number","String","Boolean","Null"].includes(t)?e:void 0},e=["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill"];return{getDataType:getDataType,requireTypes:(e,t,r)=>{let o=Array.isArray(t)?t:[t],n=getDataType(e),s=n.toLowerCase(),a=o.map(e=>e.toLowerCase()),i=s.includes("html")?"element":s;if(r)try{if(!a.includes(i))throw new TypeError(`Expected data type(s): [${a.join(", ")}], but got: ${i}`)}catch(e){r(e,n)}else if(!a.includes(i))throw new TypeError(`Expected data type(s): [${a.join(", ")}], but got: ${i}`);return n},deepClone:deepClone,deepCloneToJSON:deepCloneToJSON,wrapArrayMethods:({target:t,onBeforeMutate:r=()=>{},onAfterMutate:o=()=>{},allowList:n,props:s={}})=>{if(!Array.isArray(t))throw new TypeError("The 'target' parameter must be an array.");n&&!n?.length||(n=e);const a={};for(let e of n)a[e]=function(...n){const a={},i=t.length;switch(e){case"push":case"unshift":a.addedItems=[...n];break;case"pop":a.poppedValue=t[i-1];break;case"shift":a.shiftedValue=t[0];break;case"splice":const[e,r]=n,o=e<0?Math.max(i+e,0):Math.min(e,i),s=void 0===r?i-o:r;a.deletedItems=t.slice(o,o+s);break;case"sort":case"reverse":a.oldSnapshot=[...t];break;case"fill":case"copyWithin":const c=n[1]||0,l=void 0===n[2]?i:n[2];a.oldItems=t.slice(c,l),a.start=c,a.end=l}r?.(a);const c=Array.prototype[e].apply(t,n),l={value:c,key:e,args:n,context:a,target:t,...s};return o?.(l),c};return a},mutableMethods:e,getUniqueId:(e,t=!0)=>`${e?e+"_":""}${Date.now()}_${Math.random().toString(36).substring(2,11)}${t?"_"+Math.floor(1e4*Math.random()).toString().padStart(4,"0"):""}`}});
15
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).utils=t()}(this,function(){"use strict";const getDataType=e=>{let t,r=Object.prototype.toString.call(e).slice(8,-1);return t="Function"===r&&/^\s*class\s+/.test(e.toString())?"Class":"Object"===r&&Object.getPrototypeOf(e)!==Object.prototype?"Instance":r,t},deepClone=(e,t={})=>{const r=getDataType(e),o=Object.assign({cloneSet:!0,cloneMap:!0,cloneObject:!0,cloneArray:!0,cloneDate:!0,cloneRegex:!0},t);if(o.interceptor&&"function"==typeof o.interceptor){let t=o.interceptor(e,r);if(t)return o.onAfterClone?.({output:t,input:e,type:r,cloned:t!==e}),t}o.onBeforeClone?.(e,r);let n,s=!0;if("Object"===r&&o.cloneObject){const t={},r=Object.getOwnPropertySymbols(e);for(const r in e)t[r]=deepClone(e[r],o);if(r.length>0)for(const n of r)t[n]=deepClone(e[n],o);n=t}else if("Array"===r&&o.cloneArray)n=e.map(e=>deepClone(e,o));else if("Map"===r&&o.cloneMap){const t=new Map;for(const[r,n]of e)t.set(deepClone(r,o),deepClone(n,o));n=t}else if("Set"===r&&o.cloneSet){const t=new Set;for(const r of e)t.add(deepClone(r,o));n=t}else if("Date"===r&&o.cloneDate)n=new Date(e.getTime());else if("RegExp"===r&&o.cloneRegex){const t=e;n=new RegExp(t.source,t.flags)}else n=e,s=!1;return o.onAfterClone?.({output:n,input:e,type:r,cloned:s}),n},deepCloneToJSON=e=>{const t=getDataType(e);if("Object"===t){const t={};for(const r in e)t[r]=deepCloneToJSON(e[r]);for(const e in t)void 0===t[e]&&Reflect.deleteProperty(t,e);return t}if("Array"===t){return e.map((e,t)=>deepCloneToJSON(e)).filter(e=>void 0!==e)}return["Number","String","Boolean","Null"].includes(t)?e:void 0},e=["push","pop","shift","unshift","splice","sort","reverse","copyWithin","fill"],t=["add","delete","clear"],r=["set","delete","clear"];return{getDataType:getDataType,requireTypes:(e,t,r)=>{let o=Array.isArray(t)?t:[t],n=getDataType(e),s=n.toLowerCase(),a=o.map(e=>e.toLowerCase()),c=s.includes("html")?"element":s;if(r)try{if(!a.includes(c))throw new TypeError(`Expected data type(s): [${a.join(", ")}], but got: ${c}`)}catch(e){r(e,n)}else if(!a.includes(c))throw new TypeError(`Expected data type(s): [${a.join(", ")}], but got: ${c}`);return n},deepClone:deepClone,deepCloneToJSON:deepCloneToJSON,wrapArrayMethods:({target:t,onBeforeMutate:r=()=>{},onAfterMutate:o=()=>{},allowList:n,props:s={}})=>{if(!Array.isArray(t))throw new TypeError("The 'target' parameter must be an array.");n&&!n?.length||(n=e);const a={};for(let e of n)a[e]=function(...n){const a={},c=t.length;switch(e){case"push":case"unshift":a.addedItems=[...n];break;case"pop":a.poppedItem=t[c-1];break;case"shift":a.shiftedItem=t[0];break;case"splice":const[e,r]=n,o=e<0?Math.max(c+e,0):Math.min(e,c),s=void 0===r?c-o:r;a.deletedItems=t.slice(o,o+s);break;case"sort":case"reverse":a.oldSnapshot=[...t];break;case"fill":case"copyWithin":const i=n[1]||0,l=void 0===n[2]?c:n[2];a.oldItems=t.slice(i,l),a.start=i,a.end=l}r?.(a);const i=Array.prototype[e].apply(t,n),l={value:i,key:e,args:n,context:a,target:t,...s};return o?.(l),i};return a},arrayMutableMethods:e,setMutableMethods:t,mapMutableMethods:r,wrapSetMethods:({target:e,onBeforeMutate:r=()=>{},onAfterMutate:o=()=>{},allowList:n=t,props:s={}})=>{if(!(e instanceof Set))throw new TypeError("The 'target' parameter must be a Set.");const a={},createWrappedMethod=t=>function(...n){const a={};switch(t){case"add":{const[t]=n;a.addedItem=t,a.existed=e.has(t);break}case"delete":{const[t]=n;a.existed=e.has(t),a.deletedItem=a.existed?t:void 0;break}case"clear":a.clearedItems=Array.from(e),a.previousSize=e.size}r(a);const c=e[t].apply(e,n),i={method:t,result:c,args:n,context:a,target:e,...s};return o(i),c};for(const e of n)t.includes(e)&&(a[e]=createWrappedMethod(e));return Object.defineProperty(a,"target",{get:()=>e,enumerable:!1,configurable:!1}),a},wrapMapMethods:({target:e,onBeforeMutate:t=()=>{},onAfterMutate:o=()=>{},allowList:n=r,props:s={}})=>{if(!(e instanceof Map))throw new TypeError("The 'target' parameter must be a Map.");const a={},createWrappedMethod=r=>function(...n){const a={};switch(r){case"set":{const[t,r]=n;a.key=t,a.newValue=r,a.existed=e.has(t),a.oldValue=a.existed?e.get(t):void 0;break}case"delete":{const[t]=n;a.key=t,a.existed=e.has(t),a.value=a.existed?e.get(t):void 0;break}case"clear":a.clearedItems=Array.from(e.entries()),a.previousSize=e.size}t(a);const c=e[r].apply(e,n),i={method:r,result:c,args:n,context:a,target:e,...s};return o(i),c};for(const e of n)r.includes(e)&&(a[e]=createWrappedMethod(e));return Object.defineProperty(a,"target",{get:()=>e,enumerable:!1,configurable:!1}),a},getUniqueId:(e={})=>{const t=e.prefix,r=e.suffix,o=e.base10,n=e.base36;return`${t?t+"-":""}${Date.now()}${n?"-"+Math.random().toString(36).substring(2,11):""}${o?"-"+Math.floor(1e4*Math.random()).toString().padStart(4,"0"):""}${r?"-"+r:""}`}}});
package/dist.zip CHANGED
Binary file
package/modules.js CHANGED
@@ -1,14 +1,18 @@
1
1
  /**
2
- * Last modified: 2025/12/19 15:23:21
2
+ * Last modified: 2025/12/22 17:21:44
3
3
  */
4
4
  'use strict';
5
5
  import deepClone from './src/deepClone';
6
6
  import deepCloneToJSON from './src/deepCloneToJSON';
7
7
  import getDataType from './src/getDataType';
8
8
  import wrapArrayMethods from './src/wrapArrayMethods';
9
- import mutableMethods from './src/mutableMethods';
10
9
  import requireTypes from './src/requireTypes';
11
10
  import getUniqueId from './src/getUniqueId';
11
+ import arrayMutableMethods from './src/arrayMutableMethods';
12
+ import setMutableMethods from './src/setMutableMethods';
13
+ import mapMutableMethods from './src/mapMutableMethods';
14
+ import wrapSetMethods from './src/wrapSetMethods';
15
+ import wrapMapMethods from './src/wrapMapMethods';
12
16
  const utils = {
13
17
  //executeStr,
14
18
  getDataType,
@@ -18,7 +22,11 @@ const utils = {
18
22
  deepClone,
19
23
  deepCloneToJSON,
20
24
  wrapArrayMethods,
21
- mutableMethods,
25
+ arrayMutableMethods,
26
+ setMutableMethods,
27
+ mapMutableMethods,
28
+ wrapSetMethods,
29
+ wrapMapMethods,
22
30
  getUniqueId
23
31
  };
24
32
  export default utils;
package/modules.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Last modified: 2025/12/19 15:23:21
2
+ * Last modified: 2025/12/22 17:21:44
3
3
  */
4
4
  'use strict'
5
5
  import deepClone from './src/deepClone';
@@ -7,11 +7,15 @@ import deepCloneToJSON from './src/deepCloneToJSON';
7
7
  import executeStr from './src/executeStr';
8
8
  import getDataType from './src/getDataType';
9
9
  import wrapArrayMethods from './src/wrapArrayMethods';
10
- import mutableMethods from './src/mutableMethods';
11
10
  import parseStr from './src/parseStr';
12
11
  import renderTpl from './src/renderTpl';
13
12
  import requireTypes from './src/requireTypes';
14
13
  import getUniqueId from './src/getUniqueId';
14
+ import arrayMutableMethods from './src/arrayMutableMethods';
15
+ import setMutableMethods from './src/setMutableMethods';
16
+ import mapMutableMethods from './src/mapMutableMethods';
17
+ import wrapSetMethods from './src/wrapSetMethods';
18
+ import wrapMapMethods from './src/wrapMapMethods';
15
19
 
16
20
 
17
21
 
@@ -24,7 +28,11 @@ const utils = {
24
28
  deepClone,
25
29
  deepCloneToJSON,
26
30
  wrapArrayMethods,
27
- mutableMethods,
31
+ arrayMutableMethods,
32
+ setMutableMethods,
33
+ mapMutableMethods,
34
+ wrapSetMethods,
35
+ wrapMapMethods,
28
36
  getUniqueId
29
37
  };
30
38
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codady/utils",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "author": "AXUI Development Team",
5
5
  "license": "MIT",
6
6
  "description": "This is a set of general-purpose JavaScript utility functions developed by the AXUI team. All functions are pure and do not involve CSS or other third-party libraries. They are suitable for any web front-end environment.",
@@ -0,0 +1,5 @@
1
+ const arrayMutableMethods = [
2
+ 'push', 'pop', 'shift', 'unshift', 'splice',
3
+ 'sort', 'reverse', 'copyWithin', 'fill'
4
+ ];
5
+ export default arrayMutableMethods;
@@ -0,0 +1,5 @@
1
+ const arrayMutableMethods = [
2
+ 'push', 'pop', 'shift', 'unshift', 'splice',
3
+ 'sort', 'reverse', 'copyWithin', 'fill'
4
+ ];
5
+ export default arrayMutableMethods;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @since Last modified: 2025/12/19 10:06:07
2
+ * @since Last modified: 2025/12/22 17:20:46
3
3
  * A list of supported array mutation methods.
4
4
  * These methods are commonly used to modify the contents of an array.
5
5
  * These methods can be tracked and handled in various use cases, such as undo/redo functionality,
@@ -7,9 +7,9 @@
7
7
  *
8
8
  */
9
9
  export type ArrayMutationNames = ('push' | 'pop' | 'shift' | 'unshift' | 'splice' | 'sort' | 'reverse' | 'copyWithin' | 'fill')[];
10
- const mutableMethods: ArrayMutationNames = [
10
+ const arrayMutableMethods: ArrayMutationNames = [
11
11
  'push', 'pop', 'shift', 'unshift', 'splice',
12
12
  'sort', 'reverse', 'copyWithin', 'fill'
13
13
  ];
14
14
 
15
- export default mutableMethods;
15
+ export default arrayMutableMethods;