es-toolkit 1.50.0-dev.2001 → 1.50.0-dev.2025

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 (58) hide show
  1. package/dist/browser.global.js +3 -3
  2. package/dist/compat/array/chunk.js +1 -0
  3. package/dist/compat/array/chunk.mjs +1 -0
  4. package/dist/compat/array/dropRight.d.mts +2 -3
  5. package/dist/compat/array/dropRight.d.ts +2 -3
  6. package/dist/compat/array/dropRight.js +4 -4
  7. package/dist/compat/array/dropRight.mjs +4 -4
  8. package/dist/compat/array/every.js +9 -9
  9. package/dist/compat/array/every.mjs +9 -9
  10. package/dist/compat/array/fill.js +5 -0
  11. package/dist/compat/array/fill.mjs +5 -0
  12. package/dist/compat/array/findIndex.js +3 -19
  13. package/dist/compat/array/findIndex.mjs +3 -19
  14. package/dist/compat/array/findLast.js +3 -3
  15. package/dist/compat/array/findLast.mjs +3 -3
  16. package/dist/compat/array/flatMap.js +3 -8
  17. package/dist/compat/array/flatMap.mjs +3 -7
  18. package/dist/compat/array/flatMapDepth.js +1 -1
  19. package/dist/compat/array/flatMapDepth.mjs +1 -1
  20. package/dist/compat/array/includes.js +13 -13
  21. package/dist/compat/array/includes.mjs +13 -13
  22. package/dist/compat/array/map.js +3 -3
  23. package/dist/compat/array/map.mjs +3 -3
  24. package/dist/compat/array/orderBy.js +1 -2
  25. package/dist/compat/array/orderBy.mjs +1 -2
  26. package/dist/compat/compat.js +1 -1
  27. package/dist/compat/compat.mjs +1 -1
  28. package/dist/compat/index.js +1 -1
  29. package/dist/compat/index.mjs +1 -1
  30. package/dist/compat/util/toArray.js +5 -1
  31. package/dist/compat/util/toArray.mjs +5 -1
  32. package/dist/compat/util/toString.js +4 -1
  33. package/dist/compat/util/toString.mjs +4 -1
  34. package/dist/function/retry.js +4 -2
  35. package/dist/function/retry.mjs +1 -1
  36. package/dist/index.d.mts +4 -1
  37. package/dist/index.d.ts +4 -1
  38. package/dist/index.js +9 -3
  39. package/dist/index.mjs +7 -4
  40. package/dist/object/index.d.mts +4 -1
  41. package/dist/object/index.d.ts +4 -1
  42. package/dist/object/index.js +6 -0
  43. package/dist/object/index.mjs +4 -1
  44. package/dist/object/toConstantCaseKeys.d.mts +53 -0
  45. package/dist/object/toConstantCaseKeys.d.ts +53 -0
  46. package/dist/object/toConstantCaseKeys.js +66 -0
  47. package/dist/object/toConstantCaseKeys.mjs +66 -0
  48. package/dist/object/toKebabCaseKeys.d.mts +55 -0
  49. package/dist/object/toKebabCaseKeys.d.ts +55 -0
  50. package/dist/object/toKebabCaseKeys.js +66 -0
  51. package/dist/object/toKebabCaseKeys.mjs +66 -0
  52. package/dist/object/toPascalCaseKeys.d.mts +56 -0
  53. package/dist/object/toPascalCaseKeys.d.ts +56 -0
  54. package/dist/object/toPascalCaseKeys.js +66 -0
  55. package/dist/object/toPascalCaseKeys.mjs +66 -0
  56. package/dist/string/index.js +3 -3
  57. package/dist/string/index.mjs +3 -3
  58. package/package.json +1 -1
@@ -0,0 +1,66 @@
1
+ const require_isArray = require("../compat/predicate/isArray.js");
2
+ const require_isPlainObject = require("../compat/predicate/isPlainObject.js");
3
+ const require_pascalCase = require("../string/pascalCase.js");
4
+ //#region src/object/toPascalCaseKeys.ts
5
+ /**
6
+ * Creates a new object composed of the properties with keys converted to PascalCase.
7
+ *
8
+ * This function takes an object and returns a new object that includes the same properties,
9
+ * but with all keys converted to PascalCase format.
10
+ *
11
+ * @template T - The type of object.
12
+ * @param obj - The object to convert keys from.
13
+ * @returns A new object with all keys converted to PascalCase.
14
+ *
15
+ * @example
16
+ * // Example with objects
17
+ * const obj = { userId: 1, firstName: 'John' };
18
+ * const result = toPascalCaseKeys(obj);
19
+ * // result will be { UserId: 1, FirstName: 'John' }
20
+ *
21
+ * // Example with arrays of objects
22
+ * const arr = [
23
+ * { userId: 1, firstName: 'John' },
24
+ * { userId: 2, firstName: 'Jane' }
25
+ * ];
26
+ * const arrResult = toPascalCaseKeys(arr);
27
+ * // arrResult will be [{ UserId: 1, FirstName: 'John' }, { UserId: 2, FirstName: 'Jane' }]
28
+ *
29
+ * // Example with nested objects
30
+ * const nested = {
31
+ * userData: {
32
+ * userId: 1,
33
+ * userAddress: {
34
+ * streetName: 'Main St',
35
+ * zipCode: '12345'
36
+ * }
37
+ * }
38
+ * };
39
+ * const nestedResult = toPascalCaseKeys(nested);
40
+ * // nestedResult will be:
41
+ * // {
42
+ * // UserData: {
43
+ * // UserId: 1,
44
+ * // UserAddress: {
45
+ * // StreetName: 'Main St',
46
+ * // ZipCode: '12345'
47
+ * // }
48
+ * // }
49
+ * // }
50
+ */
51
+ function toPascalCaseKeys(obj) {
52
+ if (require_isArray.isArray(obj)) return obj.map((item) => toPascalCaseKeys(item));
53
+ if (require_isPlainObject.isPlainObject(obj)) {
54
+ const result = {};
55
+ const keys = Object.keys(obj);
56
+ for (let i = 0; i < keys.length; i++) {
57
+ const key = keys[i];
58
+ const pascalKey = require_pascalCase.pascalCase(key);
59
+ result[pascalKey] = toPascalCaseKeys(obj[key]);
60
+ }
61
+ return result;
62
+ }
63
+ return obj;
64
+ }
65
+ //#endregion
66
+ exports.toPascalCaseKeys = toPascalCaseKeys;
@@ -0,0 +1,66 @@
1
+ import { isArray } from "../compat/predicate/isArray.mjs";
2
+ import { isPlainObject } from "../compat/predicate/isPlainObject.mjs";
3
+ import { pascalCase } from "../string/pascalCase.mjs";
4
+ //#region src/object/toPascalCaseKeys.ts
5
+ /**
6
+ * Creates a new object composed of the properties with keys converted to PascalCase.
7
+ *
8
+ * This function takes an object and returns a new object that includes the same properties,
9
+ * but with all keys converted to PascalCase format.
10
+ *
11
+ * @template T - The type of object.
12
+ * @param obj - The object to convert keys from.
13
+ * @returns A new object with all keys converted to PascalCase.
14
+ *
15
+ * @example
16
+ * // Example with objects
17
+ * const obj = { userId: 1, firstName: 'John' };
18
+ * const result = toPascalCaseKeys(obj);
19
+ * // result will be { UserId: 1, FirstName: 'John' }
20
+ *
21
+ * // Example with arrays of objects
22
+ * const arr = [
23
+ * { userId: 1, firstName: 'John' },
24
+ * { userId: 2, firstName: 'Jane' }
25
+ * ];
26
+ * const arrResult = toPascalCaseKeys(arr);
27
+ * // arrResult will be [{ UserId: 1, FirstName: 'John' }, { UserId: 2, FirstName: 'Jane' }]
28
+ *
29
+ * // Example with nested objects
30
+ * const nested = {
31
+ * userData: {
32
+ * userId: 1,
33
+ * userAddress: {
34
+ * streetName: 'Main St',
35
+ * zipCode: '12345'
36
+ * }
37
+ * }
38
+ * };
39
+ * const nestedResult = toPascalCaseKeys(nested);
40
+ * // nestedResult will be:
41
+ * // {
42
+ * // UserData: {
43
+ * // UserId: 1,
44
+ * // UserAddress: {
45
+ * // StreetName: 'Main St',
46
+ * // ZipCode: '12345'
47
+ * // }
48
+ * // }
49
+ * // }
50
+ */
51
+ function toPascalCaseKeys(obj) {
52
+ if (isArray(obj)) return obj.map((item) => toPascalCaseKeys(item));
53
+ if (isPlainObject(obj)) {
54
+ const result = {};
55
+ const keys = Object.keys(obj);
56
+ for (let i = 0; i < keys.length; i++) {
57
+ const key = keys[i];
58
+ const pascalKey = pascalCase(key);
59
+ result[pascalKey] = toPascalCaseKeys(obj[key]);
60
+ }
61
+ return result;
62
+ }
63
+ return obj;
64
+ }
65
+ //#endregion
66
+ export { toPascalCaseKeys };
@@ -2,16 +2,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_capitalize = require("./capitalize.js");
3
3
  const require_words = require("./words.js");
4
4
  const require_camelCase = require("./camelCase.js");
5
- const require_snakeCase = require("./snakeCase.js");
6
5
  const require_constantCase = require("./constantCase.js");
6
+ const require_kebabCase = require("./kebabCase.js");
7
+ const require_pascalCase = require("./pascalCase.js");
8
+ const require_snakeCase = require("./snakeCase.js");
7
9
  const require_deburr = require("./deburr.js");
8
10
  const require_escape = require("./escape.js");
9
11
  const require_escapeRegExp = require("./escapeRegExp.js");
10
- const require_kebabCase = require("./kebabCase.js");
11
12
  const require_lowerCase = require("./lowerCase.js");
12
13
  const require_lowerFirst = require("./lowerFirst.js");
13
14
  const require_pad = require("./pad.js");
14
- const require_pascalCase = require("./pascalCase.js");
15
15
  const require_reverseString = require("./reverseString.js");
16
16
  const require_startCase = require("./startCase.js");
17
17
  const require_trimEnd = require("./trimEnd.js");
@@ -1,16 +1,16 @@
1
1
  import { capitalize } from "./capitalize.mjs";
2
2
  import { words } from "./words.mjs";
3
3
  import { camelCase } from "./camelCase.mjs";
4
- import { snakeCase } from "./snakeCase.mjs";
5
4
  import { constantCase } from "./constantCase.mjs";
5
+ import { kebabCase } from "./kebabCase.mjs";
6
+ import { pascalCase } from "./pascalCase.mjs";
7
+ import { snakeCase } from "./snakeCase.mjs";
6
8
  import { deburr } from "./deburr.mjs";
7
9
  import { escape } from "./escape.mjs";
8
10
  import { escapeRegExp } from "./escapeRegExp.mjs";
9
- import { kebabCase } from "./kebabCase.mjs";
10
11
  import { lowerCase } from "./lowerCase.mjs";
11
12
  import { lowerFirst } from "./lowerFirst.mjs";
12
13
  import { pad } from "./pad.mjs";
13
- import { pascalCase } from "./pascalCase.mjs";
14
14
  import { reverseString } from "./reverseString.mjs";
15
15
  import { startCase } from "./startCase.mjs";
16
16
  import { trimEnd } from "./trimEnd.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
- "version": "1.50.0-dev.2001+6b2b062e",
3
+ "version": "1.50.0-dev.2025+5f783dc2",
4
4
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
5
5
  "homepage": "https://es-toolkit.dev",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",