@ntnyq/utils 0.3.1 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -15,6 +15,7 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
20
 
20
21
  // src/index.ts
@@ -23,7 +24,6 @@ __export(src_exports, {
23
24
  NOOP: () => NOOP,
24
25
  at: () => at,
25
26
  cAF: () => cAF,
26
- camelCase: () => camelCase,
27
27
  capitalize: () => capitalize,
28
28
  chunk: () => chunk,
29
29
  clamp: () => clamp,
@@ -31,7 +31,6 @@ __export(src_exports, {
31
31
  debounce: () => debounce,
32
32
  ensurePrefix: () => ensurePrefix,
33
33
  ensureSuffix: () => ensureSuffix,
34
- flatCase: () => flatCase,
35
34
  flattenArrayable: () => flattenArrayable,
36
35
  getObjectType: () => getObjectType,
37
36
  hasOwn: () => hasOwn,
@@ -56,33 +55,24 @@ __export(src_exports, {
56
55
  isSet: () => isSet,
57
56
  isString: () => isString,
58
57
  isUndefined: () => isUndefined,
59
- isUppercase: () => isUppercase,
60
58
  isWhitespaceString: () => isWhitespaceString,
61
59
  join: () => join,
62
- kebabCase: () => kebabCase,
63
60
  last: () => last,
64
- lowerFirst: () => lowerFirst,
65
61
  mergeArrayable: () => mergeArrayable,
66
62
  minutes: () => minutes,
67
63
  noop: () => noop,
68
64
  omit: () => omit,
69
65
  once: () => once,
70
- pascalCase: () => pascalCase,
71
66
  pick: () => pick,
72
67
  rAF: () => rAF,
73
68
  seconds: () => seconds,
74
69
  slash: () => slash,
75
- snakeCase: () => snakeCase,
76
70
  sortObject: () => sortObject,
77
- splitByCase: () => splitByCase,
78
71
  throttle: () => throttle,
79
- titleCase: () => titleCase,
80
72
  toArray: () => toArray,
81
- trainCase: () => trainCase,
82
73
  unindent: () => unindent,
83
74
  unique: () => unique,
84
75
  uniqueBy: () => uniqueBy,
85
- upperFirst: () => upperFirst,
86
76
  waitFor: () => waitFor,
87
77
  warnOnce: () => warnOnce,
88
78
  weeks: () => weeks
@@ -175,88 +165,17 @@ function once(func) {
175
165
  // src/env/isBrowser.ts
176
166
  var isBrowser = () => typeof document !== "undefined";
177
167
 
178
- // node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
179
- var NUMBER_CHAR_RE = /\d/;
180
- var STR_SPLITTERS = ["-", "_", "/", "."];
181
- function isUppercase(char = "") {
182
- if (NUMBER_CHAR_RE.test(char)) {
183
- return void 0;
184
- }
185
- return char !== char.toLowerCase();
186
- }
187
- function splitByCase(str, separators) {
188
- const splitters = separators ?? STR_SPLITTERS;
189
- const parts = [];
190
- if (!str || typeof str !== "string") {
191
- return parts;
192
- }
193
- let buff = "";
194
- let previousUpper;
195
- let previousSplitter;
196
- for (const char of str) {
197
- const isSplitter = splitters.includes(char);
198
- if (isSplitter === true) {
199
- parts.push(buff);
200
- buff = "";
201
- previousUpper = void 0;
202
- continue;
203
- }
204
- const isUpper = isUppercase(char);
205
- if (previousSplitter === false) {
206
- if (previousUpper === false && isUpper === true) {
207
- parts.push(buff);
208
- buff = char;
209
- previousUpper = isUpper;
210
- continue;
211
- }
212
- if (previousUpper === true && isUpper === false && buff.length > 1) {
213
- const lastChar = buff.at(-1);
214
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
215
- buff = lastChar + char;
216
- previousUpper = isUpper;
217
- continue;
218
- }
219
- }
220
- buff += char;
221
- previousUpper = isUpper;
222
- previousSplitter = isSplitter;
223
- }
224
- parts.push(buff);
225
- return parts;
226
- }
227
- function upperFirst(str) {
228
- return str ? str[0].toUpperCase() + str.slice(1) : "";
229
- }
230
- function lowerFirst(str) {
231
- return str ? str[0].toLowerCase() + str.slice(1) : "";
232
- }
233
- function pascalCase(str, opts) {
234
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
235
- }
236
- function camelCase(str, opts) {
237
- return lowerFirst(pascalCase(str || "", opts));
238
- }
239
- function kebabCase(str, joiner) {
240
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
241
- }
242
- function snakeCase(str) {
243
- return kebabCase(str || "", "_");
244
- }
245
- function flatCase(str) {
246
- return kebabCase(str || "", "");
247
- }
248
- function trainCase(str, opts) {
249
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
250
- }
251
- var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
252
- function titleCase(str, opts) {
253
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
254
- (p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
255
- ).join(" ");
256
- }
257
-
258
168
  // src/case.ts
259
- var capitalize = upperFirst;
169
+ var case_exports = {};
170
+ __export(case_exports, {
171
+ capitalize: () => capitalize
172
+ });
173
+ var import_scule = require("scule");
174
+ __reExport(case_exports, require("scule"));
175
+ var capitalize = import_scule.upperFirst;
176
+
177
+ // src/index.ts
178
+ __reExport(src_exports, case_exports, module.exports);
260
179
 
261
180
  // src/misc/raf.ts
262
181
  var root = isBrowser() ? window : globalThis;
@@ -527,7 +446,6 @@ function sortObject(obj, options = {}) {
527
446
  NOOP,
528
447
  at,
529
448
  cAF,
530
- camelCase,
531
449
  capitalize,
532
450
  chunk,
533
451
  clamp,
@@ -535,7 +453,6 @@ function sortObject(obj, options = {}) {
535
453
  debounce,
536
454
  ensurePrefix,
537
455
  ensureSuffix,
538
- flatCase,
539
456
  flattenArrayable,
540
457
  getObjectType,
541
458
  hasOwn,
@@ -560,33 +477,24 @@ function sortObject(obj, options = {}) {
560
477
  isSet,
561
478
  isString,
562
479
  isUndefined,
563
- isUppercase,
564
480
  isWhitespaceString,
565
481
  join,
566
- kebabCase,
567
482
  last,
568
- lowerFirst,
569
483
  mergeArrayable,
570
484
  minutes,
571
485
  noop,
572
486
  omit,
573
487
  once,
574
- pascalCase,
575
488
  pick,
576
489
  rAF,
577
490
  seconds,
578
491
  slash,
579
- snakeCase,
580
492
  sortObject,
581
- splitByCase,
582
493
  throttle,
583
- titleCase,
584
494
  toArray,
585
- trainCase,
586
495
  unindent,
587
496
  unique,
588
497
  uniqueBy,
589
- upperFirst,
590
498
  waitFor,
591
499
  warnOnce,
592
500
  weeks
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ export * from 'scule';
3
3
 
4
4
  /**
5
5
  * @file is utils
6
- * @category is
6
+ * @module is
7
7
  * @copyright {@link https://github.com/sindresorhus/is}
8
8
  */
9
9
  type Whitespace = ' ';
@@ -54,7 +54,7 @@ declare const isBrowser: () => boolean;
54
54
 
55
55
  /**
56
56
  * @file case utils
57
- * @category Case
57
+ * @module Case
58
58
  */
59
59
 
60
60
  /**
@@ -68,20 +68,21 @@ declare const capitalize: typeof upperFirst;
68
68
  /**
69
69
  * Request animation frame
70
70
  *
71
- * @param fn callback
71
+ * @param fn - callback
72
72
  * @returns id
73
73
  */
74
74
  declare function rAF(fn: FrameRequestCallback): number;
75
75
  /**
76
76
  * Cancel animation frame
77
77
  *
78
- * @param id id
78
+ * @param id - id
79
79
  * @returns void
80
80
  */
81
81
  declare function cAF(id: number): void;
82
82
 
83
83
  /**
84
- * @category Utils - time
84
+ * @file time utils
85
+ * @module Time
85
86
  */
86
87
  declare function seconds(count: number): number;
87
88
  declare function minutes(count: number): number;
@@ -91,9 +92,9 @@ declare function weeks(count: number): number;
91
92
 
92
93
  /**
93
94
  * Clamps a number between a minimum and maximum value
94
- * @param value the value to clamp within the given range
95
- * @param min the minimum value to clamp
96
- * @param max the maximum value to clamp
95
+ * @param value - the value to clamp within the given range
96
+ * @param min - the minimum value to clamp
97
+ * @param max - the maximum value to clamp
97
98
  * @returns the new value
98
99
  */
99
100
  declare function clamp(value: number, min?: number, max?: number): number;
@@ -101,7 +102,7 @@ declare function clamp(value: number, min?: number, max?: number): number;
101
102
  /**
102
103
  * Wait for a number of milliseconds
103
104
  *
104
- * @param ms millseconds to wait
105
+ * @param ms - millseconds to wait
105
106
  * @returns a promise that resolves after ms milliseconds
106
107
  *
107
108
  * @example
@@ -152,8 +153,8 @@ declare function last<T>(array: readonly T[]): T | undefined;
152
153
 
153
154
  /**
154
155
  * Splits an array into smaller chunks of a given size.
155
- * @param array The array to split
156
- * @param size The size of each chunk
156
+ * @param array - The array to split
157
+ * @param size - The size of each chunk
157
158
  * @returns An array of arrays, where each sub-array has `size` elements from the original array.
158
159
  */
159
160
  declare function chunk<T>(array: T[], size: number): T[][];
@@ -172,16 +173,34 @@ declare function unique<T>(array: T[]): T[];
172
173
  */
173
174
  declare function uniqueBy<T>(array: T[], equalFn: (a: T, b: T) => boolean): T[];
174
175
 
175
- type Nullable<T> = T | null;
176
- type MayBe<T> = T | undefined;
176
+ /**
177
+ * interop module
178
+ */
179
+ type InteropModuleDefault<T> = T extends {
180
+ default: infer U;
181
+ } ? U : T;
182
+
177
183
  type AnyFn<T = any, R = any> = (...args: T[]) => R;
178
184
  type Arrayable<T> = T | T[];
179
- type Awaitable<T> = T | Promise<T>;
185
+ type Awaitable<T> = Promise<T> | T;
186
+ type MayBe<T> = T | undefined;
187
+ type Nullable<T> = T | null;
188
+ type PrimitiveType = bigint | boolean | number | string | symbol | null | undefined;
189
+ /**
190
+ * Prettify object type
191
+ */
180
192
  type Prettify<T> = {
181
193
  [K in keyof T]: T[K];
182
194
  } & {};
183
195
  type PrettifyV2<T> = Omit<T, never>;
184
- type PrimitiveType = number | bigint | string | boolean | symbol | null | undefined;
196
+ /**
197
+ * Overwrite some keys type
198
+ */
199
+ type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
200
+ /**
201
+ * Resolve `boolean | Record<string, any>` to `Record<string, any>`
202
+ */
203
+ type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
185
204
 
186
205
  /**
187
206
  * Converts a value to an array.
@@ -228,7 +247,7 @@ declare function slash(input: string): string;
228
247
  /**
229
248
  * Remove leading whitespace from a template string
230
249
  * Empty lines at the beginning and end of the template string are also removed.
231
- * @param input template string
250
+ * @param input - template string
232
251
  *
233
252
  * @example
234
253
  *
@@ -268,4 +287,4 @@ interface SortObjectOptions {
268
287
  */
269
288
  declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
270
289
 
271
- export { type AnyFn, type Arrayable, type Awaitable, type MayBe, NOOP, type NonEmptyString, type Nullable, type Prettify, type PrettifyV2, type PrimitiveType, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, days, debounce, ensurePrefix, ensureSuffix, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
290
+ export { type AnyFn, type Arrayable, type Awaitable, type InteropModuleDefault, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, days, debounce, ensurePrefix, ensureSuffix, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from 'scule';
3
3
 
4
4
  /**
5
5
  * @file is utils
6
- * @category is
6
+ * @module is
7
7
  * @copyright {@link https://github.com/sindresorhus/is}
8
8
  */
9
9
  type Whitespace = ' ';
@@ -54,7 +54,7 @@ declare const isBrowser: () => boolean;
54
54
 
55
55
  /**
56
56
  * @file case utils
57
- * @category Case
57
+ * @module Case
58
58
  */
59
59
 
60
60
  /**
@@ -68,20 +68,21 @@ declare const capitalize: typeof upperFirst;
68
68
  /**
69
69
  * Request animation frame
70
70
  *
71
- * @param fn callback
71
+ * @param fn - callback
72
72
  * @returns id
73
73
  */
74
74
  declare function rAF(fn: FrameRequestCallback): number;
75
75
  /**
76
76
  * Cancel animation frame
77
77
  *
78
- * @param id id
78
+ * @param id - id
79
79
  * @returns void
80
80
  */
81
81
  declare function cAF(id: number): void;
82
82
 
83
83
  /**
84
- * @category Utils - time
84
+ * @file time utils
85
+ * @module Time
85
86
  */
86
87
  declare function seconds(count: number): number;
87
88
  declare function minutes(count: number): number;
@@ -91,9 +92,9 @@ declare function weeks(count: number): number;
91
92
 
92
93
  /**
93
94
  * Clamps a number between a minimum and maximum value
94
- * @param value the value to clamp within the given range
95
- * @param min the minimum value to clamp
96
- * @param max the maximum value to clamp
95
+ * @param value - the value to clamp within the given range
96
+ * @param min - the minimum value to clamp
97
+ * @param max - the maximum value to clamp
97
98
  * @returns the new value
98
99
  */
99
100
  declare function clamp(value: number, min?: number, max?: number): number;
@@ -101,7 +102,7 @@ declare function clamp(value: number, min?: number, max?: number): number;
101
102
  /**
102
103
  * Wait for a number of milliseconds
103
104
  *
104
- * @param ms millseconds to wait
105
+ * @param ms - millseconds to wait
105
106
  * @returns a promise that resolves after ms milliseconds
106
107
  *
107
108
  * @example
@@ -152,8 +153,8 @@ declare function last<T>(array: readonly T[]): T | undefined;
152
153
 
153
154
  /**
154
155
  * Splits an array into smaller chunks of a given size.
155
- * @param array The array to split
156
- * @param size The size of each chunk
156
+ * @param array - The array to split
157
+ * @param size - The size of each chunk
157
158
  * @returns An array of arrays, where each sub-array has `size` elements from the original array.
158
159
  */
159
160
  declare function chunk<T>(array: T[], size: number): T[][];
@@ -172,16 +173,34 @@ declare function unique<T>(array: T[]): T[];
172
173
  */
173
174
  declare function uniqueBy<T>(array: T[], equalFn: (a: T, b: T) => boolean): T[];
174
175
 
175
- type Nullable<T> = T | null;
176
- type MayBe<T> = T | undefined;
176
+ /**
177
+ * interop module
178
+ */
179
+ type InteropModuleDefault<T> = T extends {
180
+ default: infer U;
181
+ } ? U : T;
182
+
177
183
  type AnyFn<T = any, R = any> = (...args: T[]) => R;
178
184
  type Arrayable<T> = T | T[];
179
- type Awaitable<T> = T | Promise<T>;
185
+ type Awaitable<T> = Promise<T> | T;
186
+ type MayBe<T> = T | undefined;
187
+ type Nullable<T> = T | null;
188
+ type PrimitiveType = bigint | boolean | number | string | symbol | null | undefined;
189
+ /**
190
+ * Prettify object type
191
+ */
180
192
  type Prettify<T> = {
181
193
  [K in keyof T]: T[K];
182
194
  } & {};
183
195
  type PrettifyV2<T> = Omit<T, never>;
184
- type PrimitiveType = number | bigint | string | boolean | symbol | null | undefined;
196
+ /**
197
+ * Overwrite some keys type
198
+ */
199
+ type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
200
+ /**
201
+ * Resolve `boolean | Record<string, any>` to `Record<string, any>`
202
+ */
203
+ type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
185
204
 
186
205
  /**
187
206
  * Converts a value to an array.
@@ -228,7 +247,7 @@ declare function slash(input: string): string;
228
247
  /**
229
248
  * Remove leading whitespace from a template string
230
249
  * Empty lines at the beginning and end of the template string are also removed.
231
- * @param input template string
250
+ * @param input - template string
232
251
  *
233
252
  * @example
234
253
  *
@@ -268,4 +287,4 @@ interface SortObjectOptions {
268
287
  */
269
288
  declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
270
289
 
271
- export { type AnyFn, type Arrayable, type Awaitable, type MayBe, NOOP, type NonEmptyString, type Nullable, type Prettify, type PrettifyV2, type PrimitiveType, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, days, debounce, ensurePrefix, ensureSuffix, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
290
+ export { type AnyFn, type Arrayable, type Awaitable, type InteropModuleDefault, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, days, debounce, ensurePrefix, ensureSuffix, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
package/dist/index.js CHANGED
@@ -1,3 +1,81 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ NOOP: () => NOOP,
23
+ at: () => at,
24
+ cAF: () => cAF,
25
+ capitalize: () => capitalize,
26
+ chunk: () => chunk,
27
+ clamp: () => clamp,
28
+ days: () => days,
29
+ debounce: () => debounce,
30
+ ensurePrefix: () => ensurePrefix,
31
+ ensureSuffix: () => ensureSuffix,
32
+ flattenArrayable: () => flattenArrayable,
33
+ getObjectType: () => getObjectType,
34
+ hasOwn: () => hasOwn,
35
+ hours: () => hours,
36
+ isArray: () => isArray,
37
+ isArrayEqual: () => isArrayEqual,
38
+ isBoolean: () => isBoolean,
39
+ isBrowser: () => isBrowser,
40
+ isEmptyString: () => isEmptyString,
41
+ isEmptyStringOrWhitespace: () => isEmptyStringOrWhitespace,
42
+ isFunction: () => isFunction,
43
+ isInteger: () => isInteger,
44
+ isNativePromise: () => isNativePromise,
45
+ isNil: () => isNil,
46
+ isNonEmptyString: () => isNonEmptyString,
47
+ isNull: () => isNull,
48
+ isNumber: () => isNumber,
49
+ isNumbericString: () => isNumbericString,
50
+ isObject: () => isObject,
51
+ isPromise: () => isPromise,
52
+ isRegExp: () => isRegExp,
53
+ isSet: () => isSet,
54
+ isString: () => isString,
55
+ isUndefined: () => isUndefined,
56
+ isWhitespaceString: () => isWhitespaceString,
57
+ join: () => join,
58
+ last: () => last,
59
+ mergeArrayable: () => mergeArrayable,
60
+ minutes: () => minutes,
61
+ noop: () => noop,
62
+ omit: () => omit,
63
+ once: () => once,
64
+ pick: () => pick,
65
+ rAF: () => rAF,
66
+ seconds: () => seconds,
67
+ slash: () => slash,
68
+ sortObject: () => sortObject,
69
+ throttle: () => throttle,
70
+ toArray: () => toArray,
71
+ unindent: () => unindent,
72
+ unique: () => unique,
73
+ uniqueBy: () => uniqueBy,
74
+ waitFor: () => waitFor,
75
+ warnOnce: () => warnOnce,
76
+ weeks: () => weeks
77
+ });
78
+
1
79
  // src/is/index.ts
2
80
  function getObjectType(value) {
3
81
  return Object.prototype.toString.call(value).slice(8, -1);
@@ -84,89 +162,19 @@ function once(func) {
84
162
  // src/env/isBrowser.ts
85
163
  var isBrowser = () => typeof document !== "undefined";
86
164
 
87
- // node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
88
- var NUMBER_CHAR_RE = /\d/;
89
- var STR_SPLITTERS = ["-", "_", "/", "."];
90
- function isUppercase(char = "") {
91
- if (NUMBER_CHAR_RE.test(char)) {
92
- return void 0;
93
- }
94
- return char !== char.toLowerCase();
95
- }
96
- function splitByCase(str, separators) {
97
- const splitters = separators ?? STR_SPLITTERS;
98
- const parts = [];
99
- if (!str || typeof str !== "string") {
100
- return parts;
101
- }
102
- let buff = "";
103
- let previousUpper;
104
- let previousSplitter;
105
- for (const char of str) {
106
- const isSplitter = splitters.includes(char);
107
- if (isSplitter === true) {
108
- parts.push(buff);
109
- buff = "";
110
- previousUpper = void 0;
111
- continue;
112
- }
113
- const isUpper = isUppercase(char);
114
- if (previousSplitter === false) {
115
- if (previousUpper === false && isUpper === true) {
116
- parts.push(buff);
117
- buff = char;
118
- previousUpper = isUpper;
119
- continue;
120
- }
121
- if (previousUpper === true && isUpper === false && buff.length > 1) {
122
- const lastChar = buff.at(-1);
123
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
124
- buff = lastChar + char;
125
- previousUpper = isUpper;
126
- continue;
127
- }
128
- }
129
- buff += char;
130
- previousUpper = isUpper;
131
- previousSplitter = isSplitter;
132
- }
133
- parts.push(buff);
134
- return parts;
135
- }
136
- function upperFirst(str) {
137
- return str ? str[0].toUpperCase() + str.slice(1) : "";
138
- }
139
- function lowerFirst(str) {
140
- return str ? str[0].toLowerCase() + str.slice(1) : "";
141
- }
142
- function pascalCase(str, opts) {
143
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
144
- }
145
- function camelCase(str, opts) {
146
- return lowerFirst(pascalCase(str || "", opts));
147
- }
148
- function kebabCase(str, joiner) {
149
- return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
150
- }
151
- function snakeCase(str) {
152
- return kebabCase(str || "", "_");
153
- }
154
- function flatCase(str) {
155
- return kebabCase(str || "", "");
156
- }
157
- function trainCase(str, opts) {
158
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
159
- }
160
- var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
161
- function titleCase(str, opts) {
162
- return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
163
- (p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
164
- ).join(" ");
165
- }
166
-
167
165
  // src/case.ts
166
+ var case_exports = {};
167
+ __export(case_exports, {
168
+ capitalize: () => capitalize
169
+ });
170
+ __reExport(case_exports, scule_star);
171
+ import { upperFirst } from "scule";
172
+ import * as scule_star from "scule";
168
173
  var capitalize = upperFirst;
169
174
 
175
+ // src/index.ts
176
+ __reExport(src_exports, case_exports);
177
+
170
178
  // src/misc/raf.ts
171
179
  var root = isBrowser() ? window : globalThis;
172
180
  var prev = Date.now();
@@ -435,7 +443,6 @@ export {
435
443
  NOOP,
436
444
  at,
437
445
  cAF,
438
- camelCase,
439
446
  capitalize,
440
447
  chunk,
441
448
  clamp,
@@ -443,7 +450,6 @@ export {
443
450
  debounce,
444
451
  ensurePrefix,
445
452
  ensureSuffix,
446
- flatCase,
447
453
  flattenArrayable,
448
454
  getObjectType,
449
455
  hasOwn,
@@ -468,33 +474,24 @@ export {
468
474
  isSet,
469
475
  isString,
470
476
  isUndefined,
471
- isUppercase,
472
477
  isWhitespaceString,
473
478
  join,
474
- kebabCase,
475
479
  last,
476
- lowerFirst,
477
480
  mergeArrayable,
478
481
  minutes,
479
482
  noop,
480
483
  omit,
481
484
  once,
482
- pascalCase,
483
485
  pick,
484
486
  rAF,
485
487
  seconds,
486
488
  slash,
487
- snakeCase,
488
489
  sortObject,
489
- splitByCase,
490
490
  throttle,
491
- titleCase,
492
491
  toArray,
493
- trainCase,
494
492
  unindent,
495
493
  unique,
496
494
  uniqueBy,
497
- upperFirst,
498
495
  waitFor,
499
496
  warnOnce,
500
497
  weeks
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ntnyq/utils",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "description": "Common used utils.",
6
6
  "keywords": [
7
7
  "utils"
@@ -40,23 +40,22 @@
40
40
  "scule": "^1.3.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@ntnyq/eslint-config": "^3.2.2",
44
- "@ntnyq/prettier-config": "^1.21.3",
45
- "@vitest/coverage-v8": "^2.1.5",
43
+ "@ntnyq/eslint-config": "^3.8.1",
44
+ "@ntnyq/prettier-config": "^1.22.0",
45
+ "@vitest/coverage-v8": "^2.1.8",
46
46
  "bumpp": "^9.8.1",
47
- "eslint": "^9.15.0",
47
+ "eslint": "^9.16.0",
48
48
  "husky": "^9.1.7",
49
49
  "nano-staged": "^0.8.0",
50
50
  "npm-run-all2": "^7.0.1",
51
- "prettier": "^3.3.3",
51
+ "prettier": "^3.4.2",
52
52
  "tsup": "^8.3.5",
53
- "typescript": "^5.6.3",
54
- "vitest": "^2.1.5"
53
+ "typescript": "^5.7.2",
54
+ "vitest": "^2.1.8"
55
55
  },
56
56
  "engines": {
57
57
  "node": ">=18.18.0"
58
58
  },
59
- "prettier": "@ntnyq/prettier-config",
60
59
  "nano-staged": {
61
60
  "*.{js,ts,mjs,cjs,json,md,yml,yaml}": "eslint --fix"
62
61
  },