@jhqn/utils-core 0.0.3-beta.6 → 0.0.3-beta.7

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.cjs CHANGED
@@ -438,6 +438,23 @@ const attachFmt = (data) => {
438
438
  return attachList.map(recoverFile);
439
439
  };
440
440
 
441
+ const isNumberArray = (arr) => arr.every((item) => typeof item === "number");
442
+ const isStringArray = (arr) => arr.every((item) => typeof item === "string");
443
+ const naturalSort = (arr) => {
444
+ if (isNumberArray(arr))
445
+ return [...arr].sort((a, b) => a - b);
446
+ if (isStringArray(arr)) {
447
+ return [...arr].sort((a, b) => a.localeCompare(b, "zh-CN")).sort((a, b) => a.length - b.length);
448
+ }
449
+ const newArr = [...arr].sort();
450
+ const validArr = newArr.filter((a) => isDef(a));
451
+ const invalidArr = newArr.filter((a) => !isDef(a));
452
+ return naturalSort(validArr).concat(invalidArr);
453
+ };
454
+ const naturalSortBy = (arr, key) => {
455
+ return [...arr].sort((a, b) => naturalSort([a[key], b[key]])[0] === a[key] ? -1 : 1);
456
+ };
457
+
441
458
  const inBrowser = typeof window !== "undefined";
442
459
  const waitTime = (time = 100) => {
443
460
  return new Promise((resolve) => {
@@ -565,6 +582,8 @@ exports.kebab2Camel = kebab2Camel;
565
582
  exports.kebab2Pascal = kebab2Pascal;
566
583
  exports.kebab2Snake = kebab2Snake;
567
584
  exports.kebab2Title = kebab2Title;
585
+ exports.naturalSort = naturalSort;
586
+ exports.naturalSortBy = naturalSortBy;
568
587
  exports.nonASCII = nonASCII;
569
588
  exports.parseToJSON = parseToJSON;
570
589
  exports.pascal2Camel = pascal2Camel;
package/dist/index.d.cts CHANGED
@@ -220,39 +220,55 @@ declare const jLogOnce: (...args: any[]) => void;
220
220
  /**
221
221
  * 数字或字符串
222
222
  */
223
- declare type Numeric = number | string;
223
+ type Numeric = number | string;
224
224
  /**
225
225
  * 可 Null
226
226
  */
227
- declare type Nullable<T> = T | null;
227
+ type Nullable<T> = T | null;
228
228
  /**
229
229
  * 可 Undefined
230
230
  */
231
- declare type Undefinable<T> = T | undefined;
231
+ type Undefinable<T> = T | undefined;
232
232
  /**
233
233
  * 可 Null 或 Undefined
234
234
  */
235
- declare type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
235
+ type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
236
236
  /**
237
237
  * alias for NullOrUndefinable
238
238
  */
239
- declare type UnDef<T> = NullOrUndefinable<T>;
239
+ type UnDef<T> = NullOrUndefinable<T>;
240
240
  /**
241
241
  * 请求结果
242
242
  */
243
- declare type Res<T = any> = Service.Response<T>;
243
+ type Res<T = any> = Service.Response<T>;
244
244
  /**
245
245
  * 分页请求结果数据
246
246
  */
247
- declare type PageResData<T = any> = Service.PageResponseData<T>;
247
+ type PageResData<T = any> = Service.PageResponseData<T>;
248
248
  /**
249
249
  * 分页请求结果
250
250
  */
251
- declare type PageRes<T = any> = Service.PageResponse<T>;
251
+ type PageRes<T = any> = Service.PageResponse<T>;
252
+ /**
253
+ * 分页请求参数
254
+ */
255
+ type PageReq<T extends Record<string, any> = NonNullable<unknown>> = Service.PageRequestParams<T>;
252
256
  /**
253
257
  * 可能是数组
254
258
  */
255
- declare type MaybeArray<T = any> = T | Array<T>;
259
+ type MaybeArray<T = any> = T | Array<T>;
260
+ /**
261
+ * 枚举键值对
262
+ */
263
+ type VK<T = string> = Record<string | number, T>;
264
+ /**
265
+ * 字典
266
+ */
267
+ type Dict<T = string> = Record<string, T>;
268
+ /**
269
+ * 使某键可选
270
+ */
271
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
256
272
 
257
273
  /**
258
274
  * 隐藏中间部分
@@ -540,6 +556,20 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
540
556
  percentage?: number | undefined;
541
557
  }[];
542
558
 
559
+ /**
560
+ * 自然排序
561
+ * @param {UnDef<string>[] | UnDef<number>[]} arr - 数字或字符串数组
562
+ * @returns {UnDef<string>[] | UnDef<number>[]} - 排序后的数组
563
+ */
564
+ declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
565
+ /**
566
+ * 根据 key 自然排序
567
+ * @param arr - 数组
568
+ * @param {string} key - 键名
569
+ * @returns {any[]} - 排序后的数组
570
+ */
571
+ declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
572
+
543
573
  /**
544
574
  * 检测变量类型
545
575
  * @param {any} val 检测的目标
@@ -753,4 +783,4 @@ declare const nonASCII: (text: string) => boolean;
753
783
  */
754
784
  declare const isValidFileType: (file: File, type: string) => boolean;
755
785
 
756
- export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
786
+ export { type Dict, type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageReq, type PageRes, type PageResData, type PartialBy, type Res, type UnDef, type Undefinable, type VK, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
package/dist/index.d.mts CHANGED
@@ -220,39 +220,55 @@ declare const jLogOnce: (...args: any[]) => void;
220
220
  /**
221
221
  * 数字或字符串
222
222
  */
223
- declare type Numeric = number | string;
223
+ type Numeric = number | string;
224
224
  /**
225
225
  * 可 Null
226
226
  */
227
- declare type Nullable<T> = T | null;
227
+ type Nullable<T> = T | null;
228
228
  /**
229
229
  * 可 Undefined
230
230
  */
231
- declare type Undefinable<T> = T | undefined;
231
+ type Undefinable<T> = T | undefined;
232
232
  /**
233
233
  * 可 Null 或 Undefined
234
234
  */
235
- declare type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
235
+ type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
236
236
  /**
237
237
  * alias for NullOrUndefinable
238
238
  */
239
- declare type UnDef<T> = NullOrUndefinable<T>;
239
+ type UnDef<T> = NullOrUndefinable<T>;
240
240
  /**
241
241
  * 请求结果
242
242
  */
243
- declare type Res<T = any> = Service.Response<T>;
243
+ type Res<T = any> = Service.Response<T>;
244
244
  /**
245
245
  * 分页请求结果数据
246
246
  */
247
- declare type PageResData<T = any> = Service.PageResponseData<T>;
247
+ type PageResData<T = any> = Service.PageResponseData<T>;
248
248
  /**
249
249
  * 分页请求结果
250
250
  */
251
- declare type PageRes<T = any> = Service.PageResponse<T>;
251
+ type PageRes<T = any> = Service.PageResponse<T>;
252
+ /**
253
+ * 分页请求参数
254
+ */
255
+ type PageReq<T extends Record<string, any> = NonNullable<unknown>> = Service.PageRequestParams<T>;
252
256
  /**
253
257
  * 可能是数组
254
258
  */
255
- declare type MaybeArray<T = any> = T | Array<T>;
259
+ type MaybeArray<T = any> = T | Array<T>;
260
+ /**
261
+ * 枚举键值对
262
+ */
263
+ type VK<T = string> = Record<string | number, T>;
264
+ /**
265
+ * 字典
266
+ */
267
+ type Dict<T = string> = Record<string, T>;
268
+ /**
269
+ * 使某键可选
270
+ */
271
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
256
272
 
257
273
  /**
258
274
  * 隐藏中间部分
@@ -540,6 +556,20 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
540
556
  percentage?: number | undefined;
541
557
  }[];
542
558
 
559
+ /**
560
+ * 自然排序
561
+ * @param {UnDef<string>[] | UnDef<number>[]} arr - 数字或字符串数组
562
+ * @returns {UnDef<string>[] | UnDef<number>[]} - 排序后的数组
563
+ */
564
+ declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
565
+ /**
566
+ * 根据 key 自然排序
567
+ * @param arr - 数组
568
+ * @param {string} key - 键名
569
+ * @returns {any[]} - 排序后的数组
570
+ */
571
+ declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
572
+
543
573
  /**
544
574
  * 检测变量类型
545
575
  * @param {any} val 检测的目标
@@ -753,4 +783,4 @@ declare const nonASCII: (text: string) => boolean;
753
783
  */
754
784
  declare const isValidFileType: (file: File, type: string) => boolean;
755
785
 
756
- export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
786
+ export { type Dict, type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageReq, type PageRes, type PageResData, type PartialBy, type Res, type UnDef, type Undefinable, type VK, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
package/dist/index.d.ts CHANGED
@@ -220,39 +220,55 @@ declare const jLogOnce: (...args: any[]) => void;
220
220
  /**
221
221
  * 数字或字符串
222
222
  */
223
- declare type Numeric = number | string;
223
+ type Numeric = number | string;
224
224
  /**
225
225
  * 可 Null
226
226
  */
227
- declare type Nullable<T> = T | null;
227
+ type Nullable<T> = T | null;
228
228
  /**
229
229
  * 可 Undefined
230
230
  */
231
- declare type Undefinable<T> = T | undefined;
231
+ type Undefinable<T> = T | undefined;
232
232
  /**
233
233
  * 可 Null 或 Undefined
234
234
  */
235
- declare type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
235
+ type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
236
236
  /**
237
237
  * alias for NullOrUndefinable
238
238
  */
239
- declare type UnDef<T> = NullOrUndefinable<T>;
239
+ type UnDef<T> = NullOrUndefinable<T>;
240
240
  /**
241
241
  * 请求结果
242
242
  */
243
- declare type Res<T = any> = Service.Response<T>;
243
+ type Res<T = any> = Service.Response<T>;
244
244
  /**
245
245
  * 分页请求结果数据
246
246
  */
247
- declare type PageResData<T = any> = Service.PageResponseData<T>;
247
+ type PageResData<T = any> = Service.PageResponseData<T>;
248
248
  /**
249
249
  * 分页请求结果
250
250
  */
251
- declare type PageRes<T = any> = Service.PageResponse<T>;
251
+ type PageRes<T = any> = Service.PageResponse<T>;
252
+ /**
253
+ * 分页请求参数
254
+ */
255
+ type PageReq<T extends Record<string, any> = NonNullable<unknown>> = Service.PageRequestParams<T>;
252
256
  /**
253
257
  * 可能是数组
254
258
  */
255
- declare type MaybeArray<T = any> = T | Array<T>;
259
+ type MaybeArray<T = any> = T | Array<T>;
260
+ /**
261
+ * 枚举键值对
262
+ */
263
+ type VK<T = string> = Record<string | number, T>;
264
+ /**
265
+ * 字典
266
+ */
267
+ type Dict<T = string> = Record<string, T>;
268
+ /**
269
+ * 使某键可选
270
+ */
271
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
256
272
 
257
273
  /**
258
274
  * 隐藏中间部分
@@ -540,6 +556,20 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
540
556
  percentage?: number | undefined;
541
557
  }[];
542
558
 
559
+ /**
560
+ * 自然排序
561
+ * @param {UnDef<string>[] | UnDef<number>[]} arr - 数字或字符串数组
562
+ * @returns {UnDef<string>[] | UnDef<number>[]} - 排序后的数组
563
+ */
564
+ declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
565
+ /**
566
+ * 根据 key 自然排序
567
+ * @param arr - 数组
568
+ * @param {string} key - 键名
569
+ * @returns {any[]} - 排序后的数组
570
+ */
571
+ declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
572
+
543
573
  /**
544
574
  * 检测变量类型
545
575
  * @param {any} val 检测的目标
@@ -753,4 +783,4 @@ declare const nonASCII: (text: string) => boolean;
753
783
  */
754
784
  declare const isValidFileType: (file: File, type: string) => boolean;
755
785
 
756
- export { type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageRes, type PageResData, type Res, type UnDef, type Undefinable, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
786
+ export { type Dict, type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageReq, type PageRes, type PageResData, type PartialBy, type Res, type UnDef, type Undefinable, type VK, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
package/dist/index.mjs CHANGED
@@ -427,6 +427,23 @@ const attachFmt = (data) => {
427
427
  return attachList.map(recoverFile);
428
428
  };
429
429
 
430
+ const isNumberArray = (arr) => arr.every((item) => typeof item === "number");
431
+ const isStringArray = (arr) => arr.every((item) => typeof item === "string");
432
+ const naturalSort = (arr) => {
433
+ if (isNumberArray(arr))
434
+ return [...arr].sort((a, b) => a - b);
435
+ if (isStringArray(arr)) {
436
+ return [...arr].sort((a, b) => a.localeCompare(b, "zh-CN")).sort((a, b) => a.length - b.length);
437
+ }
438
+ const newArr = [...arr].sort();
439
+ const validArr = newArr.filter((a) => isDef(a));
440
+ const invalidArr = newArr.filter((a) => !isDef(a));
441
+ return naturalSort(validArr).concat(invalidArr);
442
+ };
443
+ const naturalSortBy = (arr, key) => {
444
+ return [...arr].sort((a, b) => naturalSort([a[key], b[key]])[0] === a[key] ? -1 : 1);
445
+ };
446
+
430
447
  const inBrowser = typeof window !== "undefined";
431
448
  const waitTime = (time = 100) => {
432
449
  return new Promise((resolve) => {
@@ -470,4 +487,4 @@ const getCodeOfHour = () => getCodeOfTime(`${dateFmt( new Date(), "YYYY-MM-DD HH
470
487
  const getCodeOfDate = () => getCodeOfTime(dateFmt(/* @__PURE__ */ new Date(), "date"));
471
488
  const getCodeOfMonth = () => getCodeOfTime(dateFmt(dayjs().endOf("month"), "date"));
472
489
 
473
- export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
490
+ export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jhqn/utils-core",
3
3
  "type": "module",
4
- "version": "0.0.3-beta.6",
4
+ "version": "0.0.3-beta.7",
5
5
  "author": "jade-gjz <jiangang.zhang@jaderd.com>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/jaderd-jh/utils/tree/main/packages/core#readme",