@ntnyq/utils 0.3.3 → 0.4.1

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/README.md CHANGED
@@ -10,18 +10,22 @@
10
10
 
11
11
  ## Install
12
12
 
13
- ```bash
13
+ ```shell
14
14
  npm install @ntnyq/utils
15
15
  ```
16
16
 
17
- ```bash
17
+ ```shell
18
18
  yarn add @ntnyq/utils
19
19
  ```
20
20
 
21
- ```bash
21
+ ```shell
22
22
  pnpm add @ntnyq/utils
23
23
  ```
24
24
 
25
+ ## Credits
26
+
27
+ - [antfu/utils](https://github.com/antfu/utils)
28
+
25
29
  ## License
26
30
 
27
31
  [MIT](./LICENSE) License © 2024-PRESENT [ntnyq](https://github.com/ntnyq)
package/dist/index.cjs CHANGED
@@ -15,7 +15,6 @@ 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"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
 
21
20
  // src/index.ts
@@ -24,6 +23,7 @@ __export(src_exports, {
24
23
  NOOP: () => NOOP,
25
24
  at: () => at,
26
25
  cAF: () => cAF,
26
+ camelCase: () => camelCase,
27
27
  capitalize: () => capitalize,
28
28
  chunk: () => chunk,
29
29
  clamp: () => clamp,
@@ -32,6 +32,8 @@ __export(src_exports, {
32
32
  debounce: () => debounce,
33
33
  ensurePrefix: () => ensurePrefix,
34
34
  ensureSuffix: () => ensureSuffix,
35
+ escapeHtml: () => escapeHtml,
36
+ flatCase: () => flatCase,
35
37
  flattenArrayable: () => flattenArrayable,
36
38
  getObjectType: () => getObjectType,
37
39
  hasOwn: () => hasOwn,
@@ -60,25 +62,34 @@ __export(src_exports, {
60
62
  isSet: () => isSet,
61
63
  isString: () => isString,
62
64
  isUndefined: () => isUndefined,
65
+ isUppercase: () => isUppercase,
63
66
  isWhitespaceString: () => isWhitespaceString,
64
67
  isZero: () => isZero,
65
68
  join: () => join,
69
+ kebabCase: () => kebabCase,
66
70
  last: () => last,
71
+ lowerFirst: () => lowerFirst,
67
72
  mergeArrayable: () => mergeArrayable,
68
73
  minutes: () => minutes,
69
74
  noop: () => noop,
70
75
  omit: () => omit,
71
76
  once: () => once,
77
+ pascalCase: () => pascalCase,
72
78
  pick: () => pick,
73
79
  rAF: () => rAF,
74
80
  seconds: () => seconds,
75
81
  slash: () => slash,
82
+ snakeCase: () => snakeCase,
76
83
  sortObject: () => sortObject,
84
+ splitByCase: () => splitByCase,
77
85
  throttle: () => throttle,
86
+ titleCase: () => titleCase,
78
87
  toArray: () => toArray,
88
+ trainCase: () => trainCase,
79
89
  unindent: () => unindent,
80
90
  unique: () => unique,
81
91
  uniqueBy: () => uniqueBy,
92
+ upperFirst: () => upperFirst,
82
93
  waitFor: () => waitFor,
83
94
  warnOnce: () => warnOnce,
84
95
  weeks: () => weeks
@@ -314,6 +325,11 @@ var warnOnce = (message) => {
314
325
  console.warn(message);
315
326
  };
316
327
 
328
+ // src/html/escapeHtml.ts
329
+ function escapeHtml(unsafe) {
330
+ return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
331
+ }
332
+
317
333
  // src/array/at.ts
318
334
  function at(array, index) {
319
335
  const length = array.length;
@@ -390,10 +406,10 @@ function unindent(input) {
390
406
  const lines = (typeof input === "string" ? input : input[0]).split("\n");
391
407
  const whitespaceLines = lines.map((line) => _RE_FULL_WS.test(line));
392
408
  const commonIndent = lines.reduce((min, line, idx) => {
393
- if (!whitespaceLines[idx]) {
409
+ if (whitespaceLines[idx]) {
394
410
  return min;
395
411
  }
396
- const indent = line.match(/^\s/)?.[0].length;
412
+ const indent = line.match(/^\s*/)?.[0].length;
397
413
  return indent === void 0 ? min : Math.min(min, indent);
398
414
  }, Number.POSITIVE_INFINITY);
399
415
  let emptylinesHead = 0;
@@ -516,31 +532,94 @@ function sortObject(obj, options = {}) {
516
532
  return sortKeys(obj);
517
533
  }
518
534
 
519
- // src/vendor/index.ts
520
- var vendor_exports = {};
521
- __export(vendor_exports, {
522
- capitalize: () => capitalize
523
- });
535
+ // node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
536
+ var NUMBER_CHAR_RE = /\d/;
537
+ var STR_SPLITTERS = ["-", "_", "/", "."];
538
+ function isUppercase(char = "") {
539
+ if (NUMBER_CHAR_RE.test(char)) {
540
+ return void 0;
541
+ }
542
+ return char !== char.toLowerCase();
543
+ }
544
+ function splitByCase(str, separators) {
545
+ const splitters = separators ?? STR_SPLITTERS;
546
+ const parts = [];
547
+ if (!str || typeof str !== "string") {
548
+ return parts;
549
+ }
550
+ let buff = "";
551
+ let previousUpper;
552
+ let previousSplitter;
553
+ for (const char of str) {
554
+ const isSplitter = splitters.includes(char);
555
+ if (isSplitter === true) {
556
+ parts.push(buff);
557
+ buff = "";
558
+ previousUpper = void 0;
559
+ continue;
560
+ }
561
+ const isUpper = isUppercase(char);
562
+ if (previousSplitter === false) {
563
+ if (previousUpper === false && isUpper === true) {
564
+ parts.push(buff);
565
+ buff = char;
566
+ previousUpper = isUpper;
567
+ continue;
568
+ }
569
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
570
+ const lastChar = buff.at(-1);
571
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
572
+ buff = lastChar + char;
573
+ previousUpper = isUpper;
574
+ continue;
575
+ }
576
+ }
577
+ buff += char;
578
+ previousUpper = isUpper;
579
+ previousSplitter = isSplitter;
580
+ }
581
+ parts.push(buff);
582
+ return parts;
583
+ }
584
+ function upperFirst(str) {
585
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
586
+ }
587
+ function lowerFirst(str) {
588
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
589
+ }
590
+ function pascalCase(str, opts) {
591
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
592
+ }
593
+ function camelCase(str, opts) {
594
+ return lowerFirst(pascalCase(str || "", opts));
595
+ }
596
+ function kebabCase(str, joiner) {
597
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
598
+ }
599
+ function snakeCase(str) {
600
+ return kebabCase(str || "", "_");
601
+ }
602
+ function flatCase(str) {
603
+ return kebabCase(str || "", "");
604
+ }
605
+ function trainCase(str, opts) {
606
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
607
+ }
608
+ var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
609
+ function titleCase(str, opts) {
610
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
611
+ (p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
612
+ ).join(" ");
613
+ }
524
614
 
525
615
  // src/vendor/scule.ts
526
- var scule_exports = {};
527
- __export(scule_exports, {
528
- capitalize: () => capitalize
529
- });
530
- var import_scule = require("scule");
531
- __reExport(scule_exports, require("scule"));
532
- var capitalize = import_scule.upperFirst;
533
-
534
- // src/vendor/index.ts
535
- __reExport(vendor_exports, scule_exports);
536
-
537
- // src/index.ts
538
- __reExport(src_exports, vendor_exports, module.exports);
616
+ var capitalize = upperFirst;
539
617
  // Annotate the CommonJS export names for ESM import in node:
540
618
  0 && (module.exports = {
541
619
  NOOP,
542
620
  at,
543
621
  cAF,
622
+ camelCase,
544
623
  capitalize,
545
624
  chunk,
546
625
  clamp,
@@ -549,6 +628,8 @@ __reExport(src_exports, vendor_exports, module.exports);
549
628
  debounce,
550
629
  ensurePrefix,
551
630
  ensureSuffix,
631
+ escapeHtml,
632
+ flatCase,
552
633
  flattenArrayable,
553
634
  getObjectType,
554
635
  hasOwn,
@@ -577,25 +658,34 @@ __reExport(src_exports, vendor_exports, module.exports);
577
658
  isSet,
578
659
  isString,
579
660
  isUndefined,
661
+ isUppercase,
580
662
  isWhitespaceString,
581
663
  isZero,
582
664
  join,
665
+ kebabCase,
583
666
  last,
667
+ lowerFirst,
584
668
  mergeArrayable,
585
669
  minutes,
586
670
  noop,
587
671
  omit,
588
672
  once,
673
+ pascalCase,
589
674
  pick,
590
675
  rAF,
591
676
  seconds,
592
677
  slash,
678
+ snakeCase,
593
679
  sortObject,
680
+ splitByCase,
594
681
  throttle,
682
+ titleCase,
595
683
  toArray,
684
+ trainCase,
596
685
  unindent,
597
686
  unique,
598
687
  uniqueBy,
688
+ upperFirst,
599
689
  waitFor,
600
690
  warnOnce,
601
691
  weeks
package/dist/index.d.cts CHANGED
@@ -136,6 +136,8 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
136
136
 
137
137
  declare const warnOnce: (message: string) => void;
138
138
 
139
+ declare function escapeHtml(unsafe: string): string;
140
+
139
141
  /**
140
142
  * Get array item by index, negative for backward
141
143
  * @param array - given array
@@ -244,7 +246,7 @@ declare function join(array: JoinableValue[], options?: JoinOptions): string;
244
246
  declare function slash(input: string): string;
245
247
 
246
248
  /**
247
- * Remove leading whitespace from a template string
249
+ * Remove common leading whitespace from a template string
248
250
  * Empty lines at the beginning and end of the template string are also removed.
249
251
  * @param input - template string
250
252
  *
@@ -360,4 +362,4 @@ declare function sortObject<T extends Record<string, any>>(obj: T, options?: Sor
360
362
  */
361
363
  declare const capitalize: typeof upperFirst;
362
364
 
363
- export { type AnyFn, type Arrayable, type Awaitable, type CleanObjectOptions, 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, cleanObject, days, debounce, ensurePrefix, ensureSuffix, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
365
+ export { type AnyFn, type Arrayable, type Awaitable, type CleanObjectOptions, 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, cleanObject, days, debounce, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, 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
@@ -136,6 +136,8 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
136
136
 
137
137
  declare const warnOnce: (message: string) => void;
138
138
 
139
+ declare function escapeHtml(unsafe: string): string;
140
+
139
141
  /**
140
142
  * Get array item by index, negative for backward
141
143
  * @param array - given array
@@ -244,7 +246,7 @@ declare function join(array: JoinableValue[], options?: JoinOptions): string;
244
246
  declare function slash(input: string): string;
245
247
 
246
248
  /**
247
- * Remove leading whitespace from a template string
249
+ * Remove common leading whitespace from a template string
248
250
  * Empty lines at the beginning and end of the template string are also removed.
249
251
  * @param input - template string
250
252
  *
@@ -360,4 +362,4 @@ declare function sortObject<T extends Record<string, any>>(obj: T, options?: Sor
360
362
  */
361
363
  declare const capitalize: typeof upperFirst;
362
364
 
363
- export { type AnyFn, type Arrayable, type Awaitable, type CleanObjectOptions, 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, cleanObject, days, debounce, ensurePrefix, ensureSuffix, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
365
+ export { type AnyFn, type Arrayable, type Awaitable, type CleanObjectOptions, 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, cleanObject, days, debounce, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, 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,87 +1,3 @@
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
- cleanObject: () => cleanObject,
29
- days: () => days,
30
- debounce: () => debounce,
31
- ensurePrefix: () => ensurePrefix,
32
- ensureSuffix: () => ensureSuffix,
33
- flattenArrayable: () => flattenArrayable,
34
- getObjectType: () => getObjectType,
35
- hasOwn: () => hasOwn,
36
- hours: () => hours,
37
- isArray: () => isArray,
38
- isArrayEqual: () => isArrayEqual,
39
- isBoolean: () => isBoolean,
40
- isBrowser: () => isBrowser,
41
- isDeepEqual: () => isDeepEqual,
42
- isEmptyArray: () => isEmptyArray,
43
- isEmptyObject: () => isEmptyObject,
44
- isEmptyString: () => isEmptyString,
45
- isEmptyStringOrWhitespace: () => isEmptyStringOrWhitespace,
46
- isFunction: () => isFunction,
47
- isInteger: () => isInteger,
48
- isNaN: () => isNaN,
49
- isNativePromise: () => isNativePromise,
50
- isNil: () => isNil,
51
- isNonEmptyString: () => isNonEmptyString,
52
- isNull: () => isNull,
53
- isNumber: () => isNumber,
54
- isNumbericString: () => isNumbericString,
55
- isObject: () => isObject,
56
- isPromise: () => isPromise,
57
- isRegExp: () => isRegExp,
58
- isSet: () => isSet,
59
- isString: () => isString,
60
- isUndefined: () => isUndefined,
61
- isWhitespaceString: () => isWhitespaceString,
62
- isZero: () => isZero,
63
- join: () => join,
64
- last: () => last,
65
- mergeArrayable: () => mergeArrayable,
66
- minutes: () => minutes,
67
- noop: () => noop,
68
- omit: () => omit,
69
- once: () => once,
70
- pick: () => pick,
71
- rAF: () => rAF,
72
- seconds: () => seconds,
73
- slash: () => slash,
74
- sortObject: () => sortObject,
75
- throttle: () => throttle,
76
- toArray: () => toArray,
77
- unindent: () => unindent,
78
- unique: () => unique,
79
- uniqueBy: () => uniqueBy,
80
- waitFor: () => waitFor,
81
- warnOnce: () => warnOnce,
82
- weeks: () => weeks
83
- });
84
-
85
1
  // src/is/isDeepEqual.ts
86
2
  function isDeepEqual(value1, value2) {
87
3
  const type1 = getObjectType(value1);
@@ -311,6 +227,11 @@ var warnOnce = (message) => {
311
227
  console.warn(message);
312
228
  };
313
229
 
230
+ // src/html/escapeHtml.ts
231
+ function escapeHtml(unsafe) {
232
+ return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
233
+ }
234
+
314
235
  // src/array/at.ts
315
236
  function at(array, index) {
316
237
  const length = array.length;
@@ -387,10 +308,10 @@ function unindent(input) {
387
308
  const lines = (typeof input === "string" ? input : input[0]).split("\n");
388
309
  const whitespaceLines = lines.map((line) => _RE_FULL_WS.test(line));
389
310
  const commonIndent = lines.reduce((min, line, idx) => {
390
- if (!whitespaceLines[idx]) {
311
+ if (whitespaceLines[idx]) {
391
312
  return min;
392
313
  }
393
- const indent = line.match(/^\s/)?.[0].length;
314
+ const indent = line.match(/^\s*/)?.[0].length;
394
315
  return indent === void 0 ? min : Math.min(min, indent);
395
316
  }, Number.POSITIVE_INFINITY);
396
317
  let emptylinesHead = 0;
@@ -513,31 +434,93 @@ function sortObject(obj, options = {}) {
513
434
  return sortKeys(obj);
514
435
  }
515
436
 
516
- // src/vendor/index.ts
517
- var vendor_exports = {};
518
- __export(vendor_exports, {
519
- capitalize: () => capitalize
520
- });
437
+ // node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
438
+ var NUMBER_CHAR_RE = /\d/;
439
+ var STR_SPLITTERS = ["-", "_", "/", "."];
440
+ function isUppercase(char = "") {
441
+ if (NUMBER_CHAR_RE.test(char)) {
442
+ return void 0;
443
+ }
444
+ return char !== char.toLowerCase();
445
+ }
446
+ function splitByCase(str, separators) {
447
+ const splitters = separators ?? STR_SPLITTERS;
448
+ const parts = [];
449
+ if (!str || typeof str !== "string") {
450
+ return parts;
451
+ }
452
+ let buff = "";
453
+ let previousUpper;
454
+ let previousSplitter;
455
+ for (const char of str) {
456
+ const isSplitter = splitters.includes(char);
457
+ if (isSplitter === true) {
458
+ parts.push(buff);
459
+ buff = "";
460
+ previousUpper = void 0;
461
+ continue;
462
+ }
463
+ const isUpper = isUppercase(char);
464
+ if (previousSplitter === false) {
465
+ if (previousUpper === false && isUpper === true) {
466
+ parts.push(buff);
467
+ buff = char;
468
+ previousUpper = isUpper;
469
+ continue;
470
+ }
471
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
472
+ const lastChar = buff.at(-1);
473
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
474
+ buff = lastChar + char;
475
+ previousUpper = isUpper;
476
+ continue;
477
+ }
478
+ }
479
+ buff += char;
480
+ previousUpper = isUpper;
481
+ previousSplitter = isSplitter;
482
+ }
483
+ parts.push(buff);
484
+ return parts;
485
+ }
486
+ function upperFirst(str) {
487
+ return str ? str[0].toUpperCase() + str.slice(1) : "";
488
+ }
489
+ function lowerFirst(str) {
490
+ return str ? str[0].toLowerCase() + str.slice(1) : "";
491
+ }
492
+ function pascalCase(str, opts) {
493
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
494
+ }
495
+ function camelCase(str, opts) {
496
+ return lowerFirst(pascalCase(str || "", opts));
497
+ }
498
+ function kebabCase(str, joiner) {
499
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
500
+ }
501
+ function snakeCase(str) {
502
+ return kebabCase(str || "", "_");
503
+ }
504
+ function flatCase(str) {
505
+ return kebabCase(str || "", "");
506
+ }
507
+ function trainCase(str, opts) {
508
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
509
+ }
510
+ var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
511
+ function titleCase(str, opts) {
512
+ return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
513
+ (p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
514
+ ).join(" ");
515
+ }
521
516
 
522
517
  // src/vendor/scule.ts
523
- var scule_exports = {};
524
- __export(scule_exports, {
525
- capitalize: () => capitalize
526
- });
527
- __reExport(scule_exports, scule_star);
528
- import { upperFirst } from "scule";
529
- import * as scule_star from "scule";
530
518
  var capitalize = upperFirst;
531
-
532
- // src/vendor/index.ts
533
- __reExport(vendor_exports, scule_exports);
534
-
535
- // src/index.ts
536
- __reExport(src_exports, vendor_exports);
537
519
  export {
538
520
  NOOP,
539
521
  at,
540
522
  cAF,
523
+ camelCase,
541
524
  capitalize,
542
525
  chunk,
543
526
  clamp,
@@ -546,6 +529,8 @@ export {
546
529
  debounce,
547
530
  ensurePrefix,
548
531
  ensureSuffix,
532
+ escapeHtml,
533
+ flatCase,
549
534
  flattenArrayable,
550
535
  getObjectType,
551
536
  hasOwn,
@@ -574,25 +559,34 @@ export {
574
559
  isSet,
575
560
  isString,
576
561
  isUndefined,
562
+ isUppercase,
577
563
  isWhitespaceString,
578
564
  isZero,
579
565
  join,
566
+ kebabCase,
580
567
  last,
568
+ lowerFirst,
581
569
  mergeArrayable,
582
570
  minutes,
583
571
  noop,
584
572
  omit,
585
573
  once,
574
+ pascalCase,
586
575
  pick,
587
576
  rAF,
588
577
  seconds,
589
578
  slash,
579
+ snakeCase,
590
580
  sortObject,
581
+ splitByCase,
591
582
  throttle,
583
+ titleCase,
592
584
  toArray,
585
+ trainCase,
593
586
  unindent,
594
587
  unique,
595
588
  uniqueBy,
589
+ upperFirst,
596
590
  waitFor,
597
591
  warnOnce,
598
592
  weeks
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ntnyq/utils",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.4.1",
5
5
  "description": "Common used utils.",
6
6
  "keywords": [
7
7
  "utils"