@ntnyq/utils 0.5.1 → 0.6.0

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
@@ -24,8 +24,6 @@ __export(index_exports, {
24
24
  NOOP: () => NOOP,
25
25
  at: () => at,
26
26
  cAF: () => cAF,
27
- camelCase: () => camelCase,
28
- capitalize: () => capitalize,
29
27
  chunk: () => chunk,
30
28
  clamp: () => clamp,
31
29
  cleanObject: () => cleanObject,
@@ -36,7 +34,6 @@ __export(index_exports, {
36
34
  ensurePrefix: () => ensurePrefix,
37
35
  ensureSuffix: () => ensureSuffix,
38
36
  escapeHtml: () => escapeHtml,
39
- flatCase: () => flatCase,
40
37
  flattenArrayable: () => flattenArrayable,
41
38
  getObjectType: () => getObjectType,
42
39
  hasOwn: () => hasOwn,
@@ -75,19 +72,15 @@ __export(index_exports, {
75
72
  isSet: () => isSet,
76
73
  isString: () => isString,
77
74
  isUndefined: () => isUndefined,
78
- isUppercase: () => isUppercase,
79
75
  isWhitespaceString: () => isWhitespaceString,
80
76
  isZero: () => isZero,
81
77
  join: () => join,
82
- kebabCase: () => kebabCase,
83
78
  last: () => last,
84
- lowerFirst: () => lowerFirst,
85
79
  mergeArrayable: () => mergeArrayable,
86
80
  minutes: () => minutes,
87
81
  noop: () => noop,
88
82
  omit: () => omit,
89
83
  once: () => once,
90
- pascalCase: () => pascalCase,
91
84
  pick: () => pick,
92
85
  rAF: () => rAF,
93
86
  randomHexColor: () => randomHexColor,
@@ -98,17 +91,12 @@ __export(index_exports, {
98
91
  resolveSubOptions: () => resolveSubOptions,
99
92
  seconds: () => seconds,
100
93
  slash: () => slash,
101
- snakeCase: () => snakeCase,
102
94
  sortObject: () => sortObject,
103
- splitByCase: () => splitByCase,
104
95
  throttle: () => throttle,
105
- titleCase: () => titleCase,
106
96
  toArray: () => toArray,
107
- trainCase: () => trainCase,
108
97
  unindent: () => unindent,
109
98
  unique: () => unique,
110
99
  uniqueBy: () => uniqueBy,
111
- upperFirst: () => upperFirst,
112
100
  waitFor: () => waitFor,
113
101
  warnOnce: () => warnOnce,
114
102
  weeks: () => weeks
@@ -122,19 +110,22 @@ function isDeepEqual(value1, value2) {
122
110
  if (type1 !== type2) {
123
111
  return false;
124
112
  }
125
- if (isArray(value1)) {
113
+ if (isArray(value1) && isArray(value2)) {
126
114
  if (value1.length !== value2.length) {
127
115
  return false;
128
116
  }
129
117
  return value1.every((item, index) => isDeepEqual(item, value2[index]));
130
118
  }
131
- if (isObject(value1)) {
119
+ if (isObject(value1) && isObject(value2)) {
132
120
  const keys = Object.keys(value1);
133
121
  if (keys.length !== Object.keys(value2).length) {
134
122
  return false;
135
123
  }
136
124
  return keys.every(
137
- (key) => isDeepEqual(value1[key], value2[key])
125
+ (key) => isDeepEqual(
126
+ value1[key],
127
+ value2[key]
128
+ )
138
129
  );
139
130
  }
140
131
  return Object.is(value1, value2);
@@ -227,7 +218,10 @@ function isError(value) {
227
218
  return getObjectType(value) === "Error";
228
219
  }
229
220
  function hasPromiseApi(value) {
230
- return isFunction(value?.then) && isFunction(value?.catch);
221
+ return (
222
+ // eslint-disable-next-line @typescript-eslint/unbound-method
223
+ isFunction(value?.then) && isFunction(value?.catch)
224
+ );
231
225
  }
232
226
  function isNativePromise(value) {
233
227
  return getObjectType(value) === "Promise";
@@ -307,7 +301,7 @@ function clamp(value, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFI
307
301
  }
308
302
 
309
303
  // src/misc/waitFor.ts
310
- function waitFor(ms) {
304
+ async function waitFor(ms) {
311
305
  return new Promise((resolve) => setTimeout(resolve, ms));
312
306
  }
313
307
 
@@ -363,13 +357,13 @@ function debounce(delay, callback, options = {}) {
363
357
 
364
358
  // src/misc/warnOnce.ts
365
359
  var warned = /* @__PURE__ */ new Set();
366
- var warnOnce = (message) => {
360
+ function warnOnce(message) {
367
361
  if (warned.has(message)) {
368
362
  return;
369
363
  }
370
364
  warned.add(message);
371
365
  console.warn(message);
372
- };
366
+ }
373
367
 
374
368
  // src/html/escapeHtml.ts
375
369
  function escapeHtml(unsafe) {
@@ -726,89 +720,6 @@ function sortObject(obj, options = {}) {
726
720
  return sortKeys(obj);
727
721
  }
728
722
 
729
- // node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
730
- var NUMBER_CHAR_RE = /\d/;
731
- var STR_SPLITTERS = ["-", "_", "/", "."];
732
- function isUppercase(char = "") {
733
- if (NUMBER_CHAR_RE.test(char)) {
734
- return void 0;
735
- }
736
- return char !== char.toLowerCase();
737
- }
738
- function splitByCase(str, separators) {
739
- const splitters = separators ?? STR_SPLITTERS;
740
- const parts = [];
741
- if (!str || typeof str !== "string") {
742
- return parts;
743
- }
744
- let buff = "";
745
- let previousUpper;
746
- let previousSplitter;
747
- for (const char of str) {
748
- const isSplitter = splitters.includes(char);
749
- if (isSplitter === true) {
750
- parts.push(buff);
751
- buff = "";
752
- previousUpper = void 0;
753
- continue;
754
- }
755
- const isUpper = isUppercase(char);
756
- if (previousSplitter === false) {
757
- if (previousUpper === false && isUpper === true) {
758
- parts.push(buff);
759
- buff = char;
760
- previousUpper = isUpper;
761
- continue;
762
- }
763
- if (previousUpper === true && isUpper === false && buff.length > 1) {
764
- const lastChar = buff.at(-1);
765
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
766
- buff = lastChar + char;
767
- previousUpper = isUpper;
768
- continue;
769
- }
770
- }
771
- buff += char;
772
- previousUpper = isUpper;
773
- previousSplitter = isSplitter;
774
- }
775
- parts.push(buff);
776
- return parts;
777
- }
778
- function upperFirst(str) {
779
- return str ? str[0].toUpperCase() + str.slice(1) : "";
780
- }
781
- function lowerFirst(str) {
782
- return str ? str[0].toLowerCase() + str.slice(1) : "";
783
- }
784
- function pascalCase(str, opts) {
785
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
786
- }
787
- function camelCase(str, opts) {
788
- return lowerFirst(pascalCase(str || "", opts));
789
- }
790
- function kebabCase(str, joiner) {
791
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
792
- }
793
- function snakeCase(str) {
794
- return kebabCase(str || "", "_");
795
- }
796
- function flatCase(str) {
797
- return kebabCase(str || "", "");
798
- }
799
- function trainCase(str, opts) {
800
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
801
- }
802
- var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
803
- function titleCase(str, opts) {
804
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
805
- (p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
806
- ).join(" ");
807
- }
808
-
809
- // src/vendor/scule.ts
810
- var capitalize = upperFirst;
811
-
812
723
  // src/module/interopDefault.ts
813
724
  async function interopDefault(mod) {
814
725
  const resolved = await mod;
@@ -825,8 +736,6 @@ function resolveSubOptions(options, key) {
825
736
  NOOP,
826
737
  at,
827
738
  cAF,
828
- camelCase,
829
- capitalize,
830
739
  chunk,
831
740
  clamp,
832
741
  cleanObject,
@@ -837,7 +746,6 @@ function resolveSubOptions(options, key) {
837
746
  ensurePrefix,
838
747
  ensureSuffix,
839
748
  escapeHtml,
840
- flatCase,
841
749
  flattenArrayable,
842
750
  getObjectType,
843
751
  hasOwn,
@@ -876,19 +784,15 @@ function resolveSubOptions(options, key) {
876
784
  isSet,
877
785
  isString,
878
786
  isUndefined,
879
- isUppercase,
880
787
  isWhitespaceString,
881
788
  isZero,
882
789
  join,
883
- kebabCase,
884
790
  last,
885
- lowerFirst,
886
791
  mergeArrayable,
887
792
  minutes,
888
793
  noop,
889
794
  omit,
890
795
  once,
891
- pascalCase,
892
796
  pick,
893
797
  rAF,
894
798
  randomHexColor,
@@ -899,17 +803,12 @@ function resolveSubOptions(options, key) {
899
803
  resolveSubOptions,
900
804
  seconds,
901
805
  slash,
902
- snakeCase,
903
806
  sortObject,
904
- splitByCase,
905
807
  throttle,
906
- titleCase,
907
808
  toArray,
908
- trainCase,
909
809
  unindent,
910
810
  unique,
911
811
  uniqueBy,
912
- upperFirst,
913
812
  waitFor,
914
813
  warnOnce,
915
814
  weeks
package/dist/index.d.cts CHANGED
@@ -1,6 +1,3 @@
1
- import { upperFirst } from 'scule';
2
- export * from 'scule';
3
-
4
1
  /**
5
2
  * check if two values are deeply equal
6
3
  */
@@ -55,7 +52,7 @@ declare const noop: () => void;
55
52
  /**
56
53
  * Alias of {@link noop}.
57
54
  */
58
- declare const NOOP: () => void;
55
+ declare const NOOP: typeof noop;
59
56
 
60
57
  declare function once<T extends unknown[]>(func: (...args: T) => void): (this: unknown, ...args: T) => boolean;
61
58
 
@@ -119,7 +116,7 @@ declare function clamp(value: number, min?: number, max?: number): number;
119
116
  * // do somthing after 3 seconds
120
117
  * ```
121
118
  */
122
- declare function waitFor(ms: number): Promise<unknown>;
119
+ declare function waitFor(ms: number): Promise<void>;
123
120
 
124
121
  interface ThrottleDebounceOptions {
125
122
  /**
@@ -142,7 +139,7 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
142
139
  cancel: () => void;
143
140
  };
144
141
 
145
- declare const warnOnce: (message: string) => void;
142
+ declare function warnOnce(message: string): void;
146
143
 
147
144
  declare function escapeHtml(unsafe: string): string;
148
145
 
@@ -194,6 +191,19 @@ type JsonPrimitive = boolean | number | string | null;
194
191
  */
195
192
  type JsonValue = JsonArray | JsonObject | JsonPrimitive;
196
193
 
194
+ /**
195
+ * A literal type that supports custom further strings but preserves autocompletion in IDEs.
196
+ *
197
+ * @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609
198
+ */
199
+ type LiteralUnion<Union extends Base, Base = string> = Union | (Base & {
200
+ zz_IGNORE_ME?: never;
201
+ });
202
+ /**
203
+ * Non empty object `{}`
204
+ */
205
+ type NonEmptyObject<T> = T extends Record<string, never> ? never : T;
206
+
197
207
  /**
198
208
  * interop module
199
209
  */
@@ -452,16 +462,6 @@ interface SortObjectOptions {
452
462
  */
453
463
  declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
454
464
 
455
- /**
456
- * @file case utils
457
- * @module vendor
458
- */
459
-
460
- /**
461
- * @deprecated use upperFirst instead
462
- */
463
- declare const capitalize: typeof upperFirst;
464
-
465
465
  /**
466
466
  * Interop default export from a module
467
467
  *
@@ -524,4 +524,4 @@ interface RamdomNumberOptions {
524
524
  */
525
525
  declare function randomNumber(min: number, max?: number, options?: RamdomNumberOptions): number;
526
526
 
527
- export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type RamdomNumberOptions, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
527
+ export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type LiteralUnion, type MayBe, NOOP, type NonEmptyObject, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type RamdomNumberOptions, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { upperFirst } from 'scule';
2
- export * from 'scule';
3
-
4
1
  /**
5
2
  * check if two values are deeply equal
6
3
  */
@@ -55,7 +52,7 @@ declare const noop: () => void;
55
52
  /**
56
53
  * Alias of {@link noop}.
57
54
  */
58
- declare const NOOP: () => void;
55
+ declare const NOOP: typeof noop;
59
56
 
60
57
  declare function once<T extends unknown[]>(func: (...args: T) => void): (this: unknown, ...args: T) => boolean;
61
58
 
@@ -119,7 +116,7 @@ declare function clamp(value: number, min?: number, max?: number): number;
119
116
  * // do somthing after 3 seconds
120
117
  * ```
121
118
  */
122
- declare function waitFor(ms: number): Promise<unknown>;
119
+ declare function waitFor(ms: number): Promise<void>;
123
120
 
124
121
  interface ThrottleDebounceOptions {
125
122
  /**
@@ -142,7 +139,7 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
142
139
  cancel: () => void;
143
140
  };
144
141
 
145
- declare const warnOnce: (message: string) => void;
142
+ declare function warnOnce(message: string): void;
146
143
 
147
144
  declare function escapeHtml(unsafe: string): string;
148
145
 
@@ -194,6 +191,19 @@ type JsonPrimitive = boolean | number | string | null;
194
191
  */
195
192
  type JsonValue = JsonArray | JsonObject | JsonPrimitive;
196
193
 
194
+ /**
195
+ * A literal type that supports custom further strings but preserves autocompletion in IDEs.
196
+ *
197
+ * @see https://github.com/microsoft/TypeScript/issues/29729#issuecomment-471566609
198
+ */
199
+ type LiteralUnion<Union extends Base, Base = string> = Union | (Base & {
200
+ zz_IGNORE_ME?: never;
201
+ });
202
+ /**
203
+ * Non empty object `{}`
204
+ */
205
+ type NonEmptyObject<T> = T extends Record<string, never> ? never : T;
206
+
197
207
  /**
198
208
  * interop module
199
209
  */
@@ -452,16 +462,6 @@ interface SortObjectOptions {
452
462
  */
453
463
  declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
454
464
 
455
- /**
456
- * @file case utils
457
- * @module vendor
458
- */
459
-
460
- /**
461
- * @deprecated use upperFirst instead
462
- */
463
- declare const capitalize: typeof upperFirst;
464
-
465
465
  /**
466
466
  * Interop default export from a module
467
467
  *
@@ -524,4 +524,4 @@ interface RamdomNumberOptions {
524
524
  */
525
525
  declare function randomNumber(min: number, max?: number, options?: RamdomNumberOptions): number;
526
526
 
527
- export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type RamdomNumberOptions, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
527
+ export { type AnyFn, type Arrayable, type Awaitable, type Callable, type CleanObjectOptions, Color, type CreatePadStringOptions, type InteropModuleDefault, type JsonArray, type JsonObject, type JsonPrimitive, type JsonValue, type LiteralUnion, type MayBe, NOOP, type NonEmptyObject, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type RamdomNumberOptions, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
package/dist/index.js CHANGED
@@ -5,19 +5,22 @@ function isDeepEqual(value1, value2) {
5
5
  if (type1 !== type2) {
6
6
  return false;
7
7
  }
8
- if (isArray(value1)) {
8
+ if (isArray(value1) && isArray(value2)) {
9
9
  if (value1.length !== value2.length) {
10
10
  return false;
11
11
  }
12
12
  return value1.every((item, index) => isDeepEqual(item, value2[index]));
13
13
  }
14
- if (isObject(value1)) {
14
+ if (isObject(value1) && isObject(value2)) {
15
15
  const keys = Object.keys(value1);
16
16
  if (keys.length !== Object.keys(value2).length) {
17
17
  return false;
18
18
  }
19
19
  return keys.every(
20
- (key) => isDeepEqual(value1[key], value2[key])
20
+ (key) => isDeepEqual(
21
+ value1[key],
22
+ value2[key]
23
+ )
21
24
  );
22
25
  }
23
26
  return Object.is(value1, value2);
@@ -110,7 +113,10 @@ function isError(value) {
110
113
  return getObjectType(value) === "Error";
111
114
  }
112
115
  function hasPromiseApi(value) {
113
- return isFunction(value?.then) && isFunction(value?.catch);
116
+ return (
117
+ // eslint-disable-next-line @typescript-eslint/unbound-method
118
+ isFunction(value?.then) && isFunction(value?.catch)
119
+ );
114
120
  }
115
121
  function isNativePromise(value) {
116
122
  return getObjectType(value) === "Promise";
@@ -190,7 +196,7 @@ function clamp(value, min = Number.NEGATIVE_INFINITY, max = Number.POSITIVE_INFI
190
196
  }
191
197
 
192
198
  // src/misc/waitFor.ts
193
- function waitFor(ms) {
199
+ async function waitFor(ms) {
194
200
  return new Promise((resolve) => setTimeout(resolve, ms));
195
201
  }
196
202
 
@@ -246,13 +252,13 @@ function debounce(delay, callback, options = {}) {
246
252
 
247
253
  // src/misc/warnOnce.ts
248
254
  var warned = /* @__PURE__ */ new Set();
249
- var warnOnce = (message) => {
255
+ function warnOnce(message) {
250
256
  if (warned.has(message)) {
251
257
  return;
252
258
  }
253
259
  warned.add(message);
254
260
  console.warn(message);
255
- };
261
+ }
256
262
 
257
263
  // src/html/escapeHtml.ts
258
264
  function escapeHtml(unsafe) {
@@ -609,89 +615,6 @@ function sortObject(obj, options = {}) {
609
615
  return sortKeys(obj);
610
616
  }
611
617
 
612
- // node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
613
- var NUMBER_CHAR_RE = /\d/;
614
- var STR_SPLITTERS = ["-", "_", "/", "."];
615
- function isUppercase(char = "") {
616
- if (NUMBER_CHAR_RE.test(char)) {
617
- return void 0;
618
- }
619
- return char !== char.toLowerCase();
620
- }
621
- function splitByCase(str, separators) {
622
- const splitters = separators ?? STR_SPLITTERS;
623
- const parts = [];
624
- if (!str || typeof str !== "string") {
625
- return parts;
626
- }
627
- let buff = "";
628
- let previousUpper;
629
- let previousSplitter;
630
- for (const char of str) {
631
- const isSplitter = splitters.includes(char);
632
- if (isSplitter === true) {
633
- parts.push(buff);
634
- buff = "";
635
- previousUpper = void 0;
636
- continue;
637
- }
638
- const isUpper = isUppercase(char);
639
- if (previousSplitter === false) {
640
- if (previousUpper === false && isUpper === true) {
641
- parts.push(buff);
642
- buff = char;
643
- previousUpper = isUpper;
644
- continue;
645
- }
646
- if (previousUpper === true && isUpper === false && buff.length > 1) {
647
- const lastChar = buff.at(-1);
648
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
649
- buff = lastChar + char;
650
- previousUpper = isUpper;
651
- continue;
652
- }
653
- }
654
- buff += char;
655
- previousUpper = isUpper;
656
- previousSplitter = isSplitter;
657
- }
658
- parts.push(buff);
659
- return parts;
660
- }
661
- function upperFirst(str) {
662
- return str ? str[0].toUpperCase() + str.slice(1) : "";
663
- }
664
- function lowerFirst(str) {
665
- return str ? str[0].toLowerCase() + str.slice(1) : "";
666
- }
667
- function pascalCase(str, opts) {
668
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
669
- }
670
- function camelCase(str, opts) {
671
- return lowerFirst(pascalCase(str || "", opts));
672
- }
673
- function kebabCase(str, joiner) {
674
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
675
- }
676
- function snakeCase(str) {
677
- return kebabCase(str || "", "_");
678
- }
679
- function flatCase(str) {
680
- return kebabCase(str || "", "");
681
- }
682
- function trainCase(str, opts) {
683
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
684
- }
685
- var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
686
- function titleCase(str, opts) {
687
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
688
- (p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
689
- ).join(" ");
690
- }
691
-
692
- // src/vendor/scule.ts
693
- var capitalize = upperFirst;
694
-
695
618
  // src/module/interopDefault.ts
696
619
  async function interopDefault(mod) {
697
620
  const resolved = await mod;
@@ -707,8 +630,6 @@ export {
707
630
  NOOP,
708
631
  at,
709
632
  cAF,
710
- camelCase,
711
- capitalize,
712
633
  chunk,
713
634
  clamp,
714
635
  cleanObject,
@@ -719,7 +640,6 @@ export {
719
640
  ensurePrefix,
720
641
  ensureSuffix,
721
642
  escapeHtml,
722
- flatCase,
723
643
  flattenArrayable,
724
644
  getObjectType,
725
645
  hasOwn,
@@ -758,19 +678,15 @@ export {
758
678
  isSet,
759
679
  isString,
760
680
  isUndefined,
761
- isUppercase,
762
681
  isWhitespaceString,
763
682
  isZero,
764
683
  join,
765
- kebabCase,
766
684
  last,
767
- lowerFirst,
768
685
  mergeArrayable,
769
686
  minutes,
770
687
  noop,
771
688
  omit,
772
689
  once,
773
- pascalCase,
774
690
  pick,
775
691
  rAF,
776
692
  randomHexColor,
@@ -781,17 +697,12 @@ export {
781
697
  resolveSubOptions,
782
698
  seconds,
783
699
  slash,
784
- snakeCase,
785
700
  sortObject,
786
- splitByCase,
787
701
  throttle,
788
- titleCase,
789
702
  toArray,
790
- trainCase,
791
703
  unindent,
792
704
  unique,
793
705
  uniqueBy,
794
- upperFirst,
795
706
  waitFor,
796
707
  warnOnce,
797
708
  weeks
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ntnyq/utils",
3
3
  "type": "module",
4
- "version": "0.5.1",
4
+ "version": "0.6.0",
5
5
  "description": "Common used utils.",
6
6
  "keywords": [
7
7
  "utils"
@@ -36,28 +36,25 @@
36
36
  "dist"
37
37
  ],
38
38
  "sideEffects": false,
39
- "dependencies": {
40
- "scule": "^1.3.0"
41
- },
42
39
  "devDependencies": {
43
- "@ntnyq/eslint-config": "^4.0.0-beta.3",
44
- "@ntnyq/prettier-config": "^2.0.0-beta.2",
45
- "@vitest/coverage-v8": "^3.0.5",
40
+ "@ntnyq/eslint-config": "^4.0.0-beta.7",
41
+ "@ntnyq/prettier-config": "^2.0.0",
42
+ "@vitest/coverage-v8": "^3.0.6",
46
43
  "bumpp": "^10.0.3",
47
- "eslint": "^9.20.0",
44
+ "eslint": "^9.20.1",
48
45
  "husky": "^9.1.7",
49
46
  "nano-staged": "^0.8.0",
50
47
  "npm-run-all2": "^7.0.2",
51
- "prettier": "^3.5.0",
48
+ "prettier": "^3.5.1",
52
49
  "tsup": "^8.3.6",
53
50
  "typescript": "^5.7.3",
54
- "vitest": "^3.0.5"
51
+ "vitest": "^3.0.6"
55
52
  },
56
53
  "engines": {
57
54
  "node": ">=18.18.0"
58
55
  },
59
56
  "nano-staged": {
60
- "*.{js,ts,mjs,cjs,json,md,yml,yaml}": "eslint --fix"
57
+ "*.{js,ts,mjs,cjs,md,yml,yaml,json}": "eslint --fix"
61
58
  },
62
59
  "scripts": {
63
60
  "build": "tsup",