@ntnyq/utils 0.11.0 → 0.11.2

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +571 -509
  2. package/dist/index.js +61 -76
  3. package/package.json +27 -26
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ function noop() {}
7
7
  * Alias of {@link noop}.
8
8
  */
9
9
  const NOOP = noop;
10
-
11
10
  //#endregion
12
11
  //#region src/fn/once.ts
13
12
  /**
@@ -35,7 +34,6 @@ function once(func) {
35
34
  return true;
36
35
  };
37
36
  }
38
-
39
37
  //#endregion
40
38
  //#region src/env/isBrowser.ts
41
39
  /**
@@ -46,7 +44,6 @@ function once(func) {
46
44
  function isBrowser() {
47
45
  return typeof document !== "undefined" && typeof window !== "undefined" && typeof navigator !== "undefined" && window === self;
48
46
  }
49
-
50
47
  //#endregion
51
48
  //#region src/is/dom.ts
52
49
  /**
@@ -61,7 +58,6 @@ function isHTMLElement(value) {
61
58
  if (!isBrowser()) return false;
62
59
  return typeof value === "object" && value !== null && "nodeType" in value && value.nodeType === Node.ELEMENT_NODE && value instanceof HTMLElement;
63
60
  }
64
-
65
61
  //#endregion
66
62
  //#region src/is/core.ts
67
63
  function getObjectType(value) {
@@ -128,24 +124,24 @@ function isEmptyArray(value) {
128
124
  function isNonEmptyArray(value) {
129
125
  return isArray(value) && value.length > 0;
130
126
  }
131
- function isObject(value) {
132
- return (typeof value === "object" || isFunction(value)) && !isNull(value);
133
- }
134
- function isEmptyObject(value) {
135
- return isObject(value) && !isMap(value) && !isSet(value) && Object.keys(value).length === 0;
136
- }
137
127
  function isMap(value) {
138
128
  return getObjectType(value) === "Map";
139
129
  }
140
- function isEmptyMap(value) {
141
- return isMap(value) && value.size === 0;
142
- }
143
130
  function isSet(value) {
144
131
  return getObjectType(value) === "Set";
145
132
  }
146
133
  function isEmptySet(value) {
147
134
  return isSet(value) && value.size === 0;
148
135
  }
136
+ function isObject(value) {
137
+ return (typeof value === "object" || isFunction(value)) && !isNull(value);
138
+ }
139
+ function isEmptyObject(value) {
140
+ return isObject(value) && !isMap(value) && !isSet(value) && Object.keys(value).length === 0;
141
+ }
142
+ function isEmptyMap(value) {
143
+ return isMap(value) && value.size === 0;
144
+ }
149
145
  function isRegExp(value) {
150
146
  return getObjectType(value) === "RegExp";
151
147
  }
@@ -185,7 +181,6 @@ function isUrlString(value) {
185
181
  return false;
186
182
  }
187
183
  }
188
-
189
184
  //#endregion
190
185
  //#region src/is/isDeepEqual.ts
191
186
  /**
@@ -204,7 +199,6 @@ function isDeepEqual(value1, value2) {
204
199
  }
205
200
  return Object.is(value1, value2);
206
201
  }
207
-
208
202
  //#endregion
209
203
  //#region src/dom/scrollIntoView.ts
210
204
  /**
@@ -224,7 +218,6 @@ function scrollElementIntoView(element, options = {}) {
224
218
  const elementRect = element.getBoundingClientRect();
225
219
  if (parent.scrollWidth > parent.scrollHeight ? elementRect.left < parentRect.left || elementRect.right > parentRect.right : elementRect.top < parentRect.top || elementRect.bottom > parentRect.bottom) parent.scrollIntoView(scrollIntoViewOptions);
226
220
  }
227
-
228
221
  //#endregion
229
222
  //#region src/dom/openExternalURL.ts
230
223
  /**
@@ -237,7 +230,6 @@ function openExternalURL(url, options = {}) {
237
230
  const { target = "_blank" } = options;
238
231
  return window.open(url, target);
239
232
  }
240
-
241
233
  //#endregion
242
234
  //#region src/dom/isVisibleInViewport.ts
243
235
  /**
@@ -251,7 +243,6 @@ function isElementVisibleInViewport(element, targetWindow = window) {
251
243
  const { innerWidth, innerHeight } = targetWindow;
252
244
  return (top >= 0 && top <= innerHeight || bottom >= 0 && bottom <= innerHeight) && (left >= 0 && left <= innerWidth || right >= 0 && right <= innerWidth);
253
245
  }
254
-
255
246
  //#endregion
256
247
  //#region src/file/extension.ts
257
248
  /**
@@ -272,7 +263,6 @@ function getFileExtension(filePath) {
272
263
  if (!filePath) return;
273
264
  return filePath.match(/\.([^.]+)$/)?.[1];
274
265
  }
275
-
276
266
  //#endregion
277
267
  //#region src/html/escape.ts
278
268
  const htmlEscapeMap = {
@@ -308,7 +298,6 @@ const htmlUnescapeRegexp = /&(amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
308
298
  function unescapeHTML(str) {
309
299
  return str.replace(htmlUnescapeRegexp, (char) => htmlUnescapeMap[char]);
310
300
  }
311
-
312
301
  //#endregion
313
302
  //#region src/misc/raf.ts
314
303
  /**
@@ -341,7 +330,6 @@ function cAF(id) {
341
330
  const root = getRoot();
342
331
  return root.cancelAnimationFrame.call(root, id);
343
332
  }
344
-
345
333
  //#endregion
346
334
  //#region src/misc/clamp.ts
347
335
  /**
@@ -354,7 +342,6 @@ function cAF(id) {
354
342
  function clamp(value, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFINITY) {
355
343
  return Math.min(Math.max(value, min), max);
356
344
  }
357
-
358
345
  //#endregion
359
346
  //#region src/misc/waitFor.ts
360
347
  /**
@@ -373,7 +360,6 @@ function clamp(value, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFI
373
360
  async function waitFor(ms) {
374
361
  return new Promise((resolve) => setTimeout(resolve, ms));
375
362
  }
376
-
377
363
  //#endregion
378
364
  //#region src/misc/throttle.ts
379
365
  /**
@@ -391,7 +377,7 @@ function throttle(delay, callback, options = {}) {
391
377
  */
392
378
  let lastExec = 0;
393
379
  let cancelled = false;
394
- let timeoutId;
380
+ let timeoutId = void 0;
395
381
  function clearExistingTimeout() {
396
382
  if (timeoutId) clearTimeout(timeoutId);
397
383
  }
@@ -425,7 +411,6 @@ function debounce(delay, callback, options = {}) {
425
411
  isDebounce: true
426
412
  });
427
413
  }
428
-
429
414
  //#endregion
430
415
  //#region src/misc/warnOnce.ts
431
416
  /**
@@ -442,7 +427,6 @@ function warnOnce(message) {
442
427
  warned.add(message);
443
428
  console.warn(message);
444
429
  }
445
-
446
430
  //#endregion
447
431
  //#region src/misc/convertTime.ts
448
432
  /**
@@ -506,7 +490,6 @@ function convertFromMilliseconds(milliseconds, toUnit = "SECOND") {
506
490
  function convertTimeUnit(value, fromUnit, toUnit) {
507
491
  return convertFromMilliseconds(convertToMilliseconds(value, fromUnit), toUnit);
508
492
  }
509
-
510
493
  //#endregion
511
494
  //#region src/misc/convertStorage.ts
512
495
  /**
@@ -569,7 +552,6 @@ function convertFromBytes(bytes, toUnit = "MB") {
569
552
  function convertStorageUnit(value, fromUnit, toUnit) {
570
553
  return convertFromBytes(convertToBytes(value, fromUnit), toUnit);
571
554
  }
572
-
573
555
  //#endregion
574
556
  //#region src/array/at.ts
575
557
  /**
@@ -592,7 +574,6 @@ function at(array, index) {
592
574
  function last(array) {
593
575
  return at(array, -1);
594
576
  }
595
-
596
577
  //#endregion
597
578
  //#region src/array/chunk.ts
598
579
  /**
@@ -606,7 +587,6 @@ function chunk(array, size) {
606
587
  for (let i = 0; i < array.length; i += size) result.push(array.slice(i, i + size));
607
588
  return result;
608
589
  }
609
-
610
590
  //#endregion
611
591
  //#region src/array/remove.ts
612
592
  /**
@@ -624,7 +604,6 @@ function remove(array, value) {
624
604
  }
625
605
  return false;
626
606
  }
627
-
628
607
  //#endregion
629
608
  //#region src/array/unique.ts
630
609
  /**
@@ -647,7 +626,6 @@ function uniqueBy(array, equalFn) {
647
626
  return acc;
648
627
  }, []);
649
628
  }
650
-
651
629
  //#endregion
652
630
  //#region src/number/random.ts
653
631
  /**
@@ -665,7 +643,6 @@ function randomNumber(min, max = 0, options = {}) {
665
643
  if (min > max) [min, max] = [max, min];
666
644
  return Math.trunc(Math.random() * (max - min + (options.includeMax ? 1 : 0)) + min);
667
645
  }
668
-
669
646
  //#endregion
670
647
  //#region src/number/toInteger.ts
671
648
  /**
@@ -714,7 +691,23 @@ function toInteger(value, options = {}) {
714
691
  }
715
692
  return result;
716
693
  }
717
-
694
+ //#endregion
695
+ //#region src/number/toNumber.ts
696
+ /**
697
+ * Converts `value` to a number.
698
+ * @param value The value to process.
699
+ * @returns Returns the number.
700
+ */
701
+ function toNumber(value) {
702
+ if (!isString(value) && !isNumber(value)) throw new TypeError(`Expected a string or number, got ${typeof value}`);
703
+ if (isNaN(value)) throw new TypeError(`Expected a valid number, got NaN`);
704
+ if (isString(value)) {
705
+ const result = Number.parseFloat(value);
706
+ if (isNaN(result)) throw new TypeError(`Expected a valid number, got NaN`);
707
+ return result;
708
+ }
709
+ return value;
710
+ }
718
711
  //#endregion
719
712
  //#region src/array/shuffle.ts
720
713
  /**
@@ -730,7 +723,6 @@ function shuffle(array) {
730
723
  }
731
724
  return array;
732
725
  }
733
-
734
726
  //#endregion
735
727
  //#region src/array/toArray.ts
736
728
  /**
@@ -742,7 +734,6 @@ function toArray(array) {
742
734
  array = array ?? [];
743
735
  return Array.isArray(array) ? array : [array];
744
736
  }
745
-
746
737
  //#endregion
747
738
  //#region src/array/arrayable.ts
748
739
  /**
@@ -761,7 +752,6 @@ function flattenArrayable(array) {
761
752
  function mergeArrayable(...args) {
762
753
  return args.flatMap((i) => toArray(i));
763
754
  }
764
-
765
755
  //#endregion
766
756
  //#region src/array/intersect.ts
767
757
  /**
@@ -772,7 +762,6 @@ function mergeArrayable(...args) {
772
762
  function intersect(a, b) {
773
763
  return a.filter((item) => b.includes(item));
774
764
  }
775
-
776
765
  //#endregion
777
766
  //#region src/array/isArrayEqual.ts
778
767
  /**
@@ -785,14 +774,12 @@ function isArrayEqual(array1, array2) {
785
774
  if (array1.length !== array2.length) return false;
786
775
  return array1.every((item, idx) => item === array2[idx]);
787
776
  }
788
-
789
777
  //#endregion
790
778
  //#region src/string/pad.ts
791
779
  function createPadString(options) {
792
780
  const { length, char } = options;
793
781
  return (value) => (char.repeat(length) + value).slice(-length);
794
782
  }
795
-
796
783
  //#endregion
797
784
  //#region src/string/join.ts
798
785
  /**
@@ -804,27 +791,24 @@ function createPadString(options) {
804
791
  function join(array, options = {}) {
805
792
  const { separator = "" } = options;
806
793
  if (!Array.isArray(array) || !array.length) return "";
807
- return array.filter((v) => Boolean(v) || v === 0).join(separator);
794
+ return array.filter((i) => Boolean(i) || i === 0).join(separator);
808
795
  }
809
-
810
796
  //#endregion
811
797
  //#region src/string/slash.ts
812
798
  /**
813
799
  * Replace backslash to slash
814
800
  */
815
801
  function slash(input) {
816
- return input.replace(/\\/g, "/");
802
+ return input.replaceAll("\\", "/");
817
803
  }
818
-
819
804
  //#endregion
820
805
  //#region src/string/escape.ts
821
806
  /**
822
807
  * @copyright {@link https://github.com/sindresorhus/escape-string-regexp}
823
808
  */
824
809
  function escapeStringRegexp(value) {
825
- return value.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
810
+ return value.replaceAll(/[|\\{}()[\]^$+*?.]/g, "\\$&").replaceAll("-", "\\x2d");
826
811
  }
827
-
828
812
  //#endregion
829
813
  //#region src/string/random.ts
830
814
  /**
@@ -842,7 +826,6 @@ function randomString(length = 16, chars = "0123456789abcdefghijklmnopqrstuvwxyz
842
826
  }
843
827
  return result.join("");
844
828
  }
845
-
846
829
  //#endregion
847
830
  //#region src/string/slugify.ts
848
831
  const rControl = /[\u0000-\u001F]/g;
@@ -852,9 +835,8 @@ const rCombining = /[\u0300-\u036F]/g;
852
835
  * Default slugify function
853
836
  */
854
837
  function slugify(str) {
855
- return str.normalize("NFKD").replace(rCombining, "").replace(rControl, "").replace(rSpecial, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1").toLowerCase();
838
+ return str.normalize("NFKD").replace(rCombining, "").replace(rControl, "").replace(rSpecial, "-").replaceAll(/-{2,}/g, "-").replaceAll(/^-+|-+$/g, "").replace(/^(\d)/, "_$1").toLowerCase();
856
839
  }
857
-
858
840
  //#endregion
859
841
  //#region src/string/unindent.ts
860
842
  const _RE_FULL_WS = /^\s*$/;
@@ -887,7 +869,6 @@ function unindent(input) {
887
869
  while (emptylinesTail < lines.length && whitespaceLines[lines.length - emptylinesTail - 1]) emptylinesTail++;
888
870
  return lines.slice(emptylinesHead, lines.length - emptylinesTail).map((line) => line.slice(commonIndent)).join("\n");
889
871
  }
890
-
891
872
  //#endregion
892
873
  //#region src/string/getLength.ts
893
874
  let segmenter;
@@ -904,19 +885,16 @@ function getStringLength(value) {
904
885
  segmenter ??= new Intl.Segmenter();
905
886
  return [...segmenter.segment(value)].length;
906
887
  }
907
-
908
888
  //#endregion
909
889
  //#region src/string/ensurePrefix.ts
910
890
  function ensurePrefix(input, prefix) {
911
891
  return input.startsWith(prefix) ? input : `${prefix}${input}`;
912
892
  }
913
-
914
893
  //#endregion
915
894
  //#region src/string/ensureSuffix.ts
916
895
  function ensureSuffix(input, suffix) {
917
896
  return input.endsWith(suffix) ? input : `${input}${suffix}`;
918
897
  }
919
-
920
898
  //#endregion
921
899
  //#region src/string/getSimilarity.ts
922
900
  function getStringSimilarity(str1, str2, options = {}) {
@@ -942,7 +920,6 @@ function getStringSimilarity(str1, str2, options = {}) {
942
920
  }
943
921
  return match * 2 / (str1.length + str2.length - (sliceLength - 1) * 2);
944
922
  }
945
-
946
923
  //#endregion
947
924
  //#region src/color/color.ts
948
925
  const RE_VALID_HEX_COLOR = /^#(?:[0-9a-f]{6}|[0-9a-f]{3})$/i;
@@ -952,7 +929,7 @@ function validateHexColor(hex) {
952
929
  return RE_VALID_HEX_COLOR.test(hex);
953
930
  }
954
931
  function normalizeHexString(hex) {
955
- return hex.length === 6 ? hex : hex.replace(/./g, "$&$&");
932
+ return hex.length === 6 ? hex : hex.replaceAll(/./g, "$&$&");
956
933
  }
957
934
  var Color = class Color {
958
935
  red = 0;
@@ -1028,7 +1005,6 @@ var Color = class Color {
1028
1005
  return new Color(Math.max(this.red - amount, 0), Math.max(this.green - amount, 0), Math.max(this.blue - amount, 0), this.alpha);
1029
1006
  }
1030
1007
  };
1031
-
1032
1008
  //#endregion
1033
1009
  //#region src/color/random.ts
1034
1010
  /**
@@ -1056,7 +1032,6 @@ function randomRGBAColor() {
1056
1032
  function randomHexColor() {
1057
1033
  return `#${Math.random().toString(16).slice(2, 8)}`;
1058
1034
  }
1059
-
1060
1035
  //#endregion
1061
1036
  //#region src/proxy/enhance.ts
1062
1037
  /**
@@ -1074,7 +1049,28 @@ function enhance(module, extra) {
1074
1049
  }
1075
1050
  });
1076
1051
  }
1077
-
1052
+ //#endregion
1053
+ //#region src/tree/flatTree.ts
1054
+ function flatTree(roots, options = {}) {
1055
+ const { childrenKey = "children", includeSelf = true, map } = options;
1056
+ const out = [];
1057
+ function walk(nodes, parent, depth, path) {
1058
+ nodes.forEach((node, index) => {
1059
+ const nextPath = [...path, node];
1060
+ if (includeSelf) out.push(map ? map({
1061
+ node,
1062
+ parent,
1063
+ depth,
1064
+ index,
1065
+ path: nextPath
1066
+ }) : node);
1067
+ const children = node[childrenKey];
1068
+ if (Array.isArray(children) && children.length > 0) walk(children, node, depth + 1, nextPath);
1069
+ });
1070
+ }
1071
+ walk(roots, null, 0, []);
1072
+ return out;
1073
+ }
1078
1074
  //#endregion
1079
1075
  //#region src/module/interopDefault.ts
1080
1076
  /**
@@ -1095,7 +1091,6 @@ async function interopDefault(mod) {
1095
1091
  const resolved = await mod;
1096
1092
  return resolved.default || resolved;
1097
1093
  }
1098
-
1099
1094
  //#endregion
1100
1095
  //#region src/module/resolveSubOptions.ts
1101
1096
  /**
@@ -1128,14 +1123,12 @@ async function interopDefault(mod) {
1128
1123
  function resolveSubOptions(options, key) {
1129
1124
  return typeof options[key] === "boolean" ? {} : options[key] || {};
1130
1125
  }
1131
-
1132
1126
  //#endregion
1133
1127
  //#region src/object/omit.ts
1134
1128
  function omit(object, ...keys) {
1135
1129
  keys.forEach((key) => delete object[key]);
1136
1130
  return object;
1137
1131
  }
1138
-
1139
1132
  //#endregion
1140
1133
  //#region src/object/hasOwn.ts
1141
1134
  /**
@@ -1148,7 +1141,6 @@ function hasOwn(object, key) {
1148
1141
  if (object === null) return false;
1149
1142
  return Object.prototype.hasOwnProperty.call(object, key);
1150
1143
  }
1151
-
1152
1144
  //#endregion
1153
1145
  //#region src/object/pick.ts
1154
1146
  function pick(object, keys) {
@@ -1157,7 +1149,6 @@ function pick(object, keys) {
1157
1149
  return result;
1158
1150
  }, {});
1159
1151
  }
1160
-
1161
1152
  //#endregion
1162
1153
  //#region src/object/clean.ts
1163
1154
  /**
@@ -1181,7 +1172,6 @@ function cleanObject(obj, options = {}) {
1181
1172
  });
1182
1173
  return obj;
1183
1174
  }
1184
-
1185
1175
  //#endregion
1186
1176
  //#region src/object/isKeyOf.ts
1187
1177
  /**
@@ -1195,7 +1185,6 @@ function cleanObject(obj, options = {}) {
1195
1185
  function isKeyOf(obj, k) {
1196
1186
  return k in obj;
1197
1187
  }
1198
-
1199
1188
  //#endregion
1200
1189
  //#region src/object/isPlainObject.ts
1201
1190
  /**
@@ -1209,32 +1198,30 @@ function isPlainObject(value) {
1209
1198
  const prototype = Object.getPrototypeOf(value);
1210
1199
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
1211
1200
  }
1212
-
1213
1201
  //#endregion
1214
1202
  //#region src/object/sortObject.ts
1215
1203
  /**
1216
1204
  * Sort object properties
1217
1205
  */
1218
- function sortObject(obj, options = {}) {
1206
+ function sortObject(object, options = {}) {
1219
1207
  const { compareFn = (a, b) => a.localeCompare(b) } = options;
1220
- function sortKeys(obj$1) {
1221
- const sortedKeys = Object.keys(obj$1).sort(compareFn);
1208
+ function sortKeys(obj) {
1209
+ const sortedKeys = Object.keys(obj).sort(compareFn);
1222
1210
  const result = {};
1223
1211
  for (const key of sortedKeys) {
1224
- const value = obj$1[key];
1212
+ const value = obj[key];
1225
1213
  let newValue;
1226
1214
  if (options.deep && isPlainObject(value)) newValue = sortKeys(value);
1227
1215
  else newValue = value;
1228
1216
  Object.defineProperty(result, key, {
1229
- ...Object.getOwnPropertyDescriptor(obj$1, key),
1217
+ ...Object.getOwnPropertyDescriptor(obj, key),
1230
1218
  value: newValue
1231
1219
  });
1232
1220
  }
1233
1221
  return result;
1234
1222
  }
1235
- return sortKeys(obj);
1223
+ return sortKeys(object);
1236
1224
  }
1237
-
1238
1225
  //#endregion
1239
1226
  //#region src/constants/char.ts
1240
1227
  /**
@@ -1248,7 +1235,6 @@ const SPECIAL_CHAR = {
1248
1235
  newline: "\n",
1249
1236
  whitespace: " "
1250
1237
  };
1251
-
1252
1238
  //#endregion
1253
1239
  //#region src/constants/regexp.ts
1254
1240
  /**
@@ -1265,6 +1251,5 @@ const RE_LINE_COMMENT = /\/\/.*/;
1265
1251
  * JavaScript block comment
1266
1252
  */
1267
1253
  const RE_BLOCK_COMMENT = /\/\*[\s\S]*?\*\//g;
1268
-
1269
1254
  //#endregion
1270
- export { Color, NOOP, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, SPECIAL_CHAR, STORAGE_UNITS, TIME_UNITS, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
1255
+ export { Color, NOOP, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, SPECIAL_CHAR, STORAGE_UNITS, TIME_UNITS, at, cAF, chunk, clamp, cleanObject, convertFromBytes, convertFromMilliseconds, convertStorageUnit, convertTimeUnit, convertToBytes, convertToMilliseconds, createPadString, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, escapeStringRegexp, flatTree, flattenArrayable, getFileExtension, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBlob, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFile, isFormData, isFunction, isHTMLElement, isInteger, isIterable, isKeyOf, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPlainObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isUrlString, isWhitespaceString, isZero, join, last, mergeArrayable, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, remove, removeFileExtension, resolveSubOptions, scrollElementIntoView, shuffle, slash, slugify, sortObject, throttle, toArray, toInteger, toNumber, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce };
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "@ntnyq/utils",
3
- "type": "module",
4
- "version": "0.11.0",
3
+ "version": "0.11.2",
5
4
  "description": "Common used utils.",
6
5
  "keywords": [
7
6
  "utils"
8
7
  ],
8
+ "homepage": "https://github.com/ntnyq/utils#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/ntnyq/utils/issues"
11
+ },
9
12
  "license": "MIT",
10
13
  "author": {
11
14
  "name": "ntnyq",
12
15
  "email": "ntnyq13@gmail.com"
13
16
  },
14
- "homepage": "https://github.com/ntnyq/utils#readme",
15
17
  "repository": "ntnyq/utils",
16
- "bugs": {
17
- "url": "https://github.com/ntnyq/utils/issues"
18
- },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "type": "module",
22
+ "sideEffects": false,
23
+ "main": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
19
25
  "exports": {
20
26
  "./package.json": "./package.json",
21
27
  ".": {
@@ -23,40 +29,35 @@
23
29
  "default": "./dist/index.js"
24
30
  }
25
31
  },
26
- "main": "./dist/index.js",
27
- "types": "./dist/index.d.ts",
28
- "files": [
29
- "dist"
30
- ],
31
- "sideEffects": false,
32
32
  "devDependencies": {
33
- "@ntnyq/eslint-config": "^5.9.0",
34
- "@ntnyq/prettier-config": "^3.0.1",
35
33
  "@ntnyq/tsconfig": "^3.1.0",
36
- "bumpp": "^10.3.2",
37
- "eslint": "^9.39.2",
34
+ "@typescript/native-preview": "^7.0.0-dev.20260320.1",
35
+ "bumpp": "^11.0.1",
38
36
  "husky": "^9.1.7",
39
37
  "nano-staged": "^0.9.0",
40
38
  "npm-run-all2": "^8.0.4",
41
- "prettier": "^3.7.4",
42
- "tsdown": "^0.18.3",
43
- "typescript": "^5.9.3",
44
- "vitest": "^4.0.16"
39
+ "oxfmt": "^0.41.0",
40
+ "oxlint": "^1.56.0",
41
+ "tsdown": "^0.21.4",
42
+ "vitest": "^4.1.0"
43
+ },
44
+ "nano-staged": {
45
+ "*.{js,ts,mjs,tsx}": "oxlint --fix",
46
+ "*": "oxfmt --no-error-on-unmatched-pattern"
45
47
  },
46
48
  "engines": {
47
49
  "node": "^20.19.0 || ^22.13.0 || >=24"
48
50
  },
49
- "nano-staged": {
50
- "*.{js,ts,mjs,cjs,md,yml,yaml,toml,json}": "eslint --fix"
51
- },
52
51
  "scripts": {
53
52
  "build": "tsdown",
54
53
  "dev": "tsdown --watch src",
55
- "lint": "eslint",
54
+ "format": "oxfmt",
55
+ "format:check": "oxfmt --check",
56
+ "lint": "oxlint",
56
57
  "release": "run-s release:check release:version",
57
- "release:check": "run-s lint typecheck test",
58
+ "release:check": "run-s format:check lint typecheck test",
58
59
  "release:version": "bumpp",
59
60
  "test": "vitest",
60
- "typecheck": "tsc --noEmit"
61
+ "typecheck": "tsgo --noEmit"
61
62
  }
62
63
  }