es-toolkit 1.29.0 → 1.30.0-dev.963

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 (131) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/_chunk/{rangeRight-w3WrXN.js → range-HnEIT7.js} +0 -17
  3. package/dist/_chunk/{zipWith-Bb2eZI.js → zipWith-nbzldx.js} +11 -10
  4. package/dist/array/index.d.mts +1 -0
  5. package/dist/array/index.d.ts +1 -0
  6. package/dist/array/index.js +12 -2
  7. package/dist/array/index.mjs +1 -0
  8. package/dist/array/pull.d.mts +19 -0
  9. package/dist/array/pull.d.ts +19 -0
  10. package/dist/array/pull.mjs +11 -0
  11. package/dist/browser.global.js +1 -1
  12. package/dist/browser.global.js.map +1 -1
  13. package/dist/compat/_internal/isIndex.mjs +2 -2
  14. package/dist/compat/_internal/isPrototype.mjs +1 -1
  15. package/dist/compat/array/differenceWith.d.mts +91 -0
  16. package/dist/compat/array/differenceWith.d.ts +91 -0
  17. package/dist/compat/array/differenceWith.mjs +19 -0
  18. package/dist/compat/array/map.d.mts +182 -0
  19. package/dist/compat/array/map.d.ts +182 -0
  20. package/dist/compat/array/map.mjs +21 -0
  21. package/dist/compat/array/nth.d.mts +14 -0
  22. package/dist/compat/array/nth.d.ts +14 -0
  23. package/dist/compat/array/nth.mjs +15 -0
  24. package/dist/compat/array/pull.d.mts +19 -0
  25. package/dist/compat/array/pull.d.ts +19 -0
  26. package/dist/compat/array/pull.mjs +8 -0
  27. package/dist/compat/array/takeRightWhile.d.mts +84 -0
  28. package/dist/compat/array/takeRightWhile.d.ts +84 -0
  29. package/dist/compat/array/takeRightWhile.mjs +15 -0
  30. package/dist/compat/function/after.d.mts +31 -0
  31. package/dist/compat/function/after.d.ts +31 -0
  32. package/dist/compat/function/after.mjs +15 -0
  33. package/dist/compat/function/delay.d.mts +29 -0
  34. package/dist/compat/function/delay.d.ts +29 -0
  35. package/dist/compat/function/delay.mjs +10 -0
  36. package/dist/compat/function/nthArg.d.mts +22 -0
  37. package/dist/compat/function/nthArg.d.ts +22 -0
  38. package/dist/compat/function/nthArg.mjs +9 -0
  39. package/dist/compat/index.d.mts +30 -12
  40. package/dist/compat/index.d.ts +30 -12
  41. package/dist/compat/index.js +369 -49
  42. package/dist/compat/index.mjs +31 -12
  43. package/dist/compat/math/range.d.mts +47 -0
  44. package/dist/compat/math/range.d.ts +47 -0
  45. package/dist/compat/math/range.mjs +26 -0
  46. package/dist/compat/math/rangeRight.d.mts +47 -0
  47. package/dist/compat/math/rangeRight.d.ts +47 -0
  48. package/dist/compat/math/rangeRight.mjs +26 -0
  49. package/dist/compat/math/sumBy.d.mts +2 -2
  50. package/dist/compat/math/sumBy.d.ts +2 -2
  51. package/dist/compat/object/findKey.d.mts +58 -0
  52. package/dist/compat/object/findKey.d.ts +58 -0
  53. package/dist/compat/object/findKey.mjs +30 -0
  54. package/dist/compat/object/keys.d.mts +22 -0
  55. package/dist/compat/object/keys.d.ts +22 -0
  56. package/dist/compat/object/keys.mjs +32 -0
  57. package/dist/compat/object/propertyOf.d.mts +22 -0
  58. package/dist/compat/object/propertyOf.d.ts +22 -0
  59. package/dist/compat/object/propertyOf.mjs +9 -0
  60. package/dist/compat/predicate/isArrayLike.d.mts +1 -1
  61. package/dist/compat/predicate/isArrayLike.d.ts +1 -1
  62. package/dist/compat/predicate/isArrayLikeObject.d.mts +1 -1
  63. package/dist/compat/predicate/isArrayLikeObject.d.ts +1 -1
  64. package/dist/compat/predicate/isElement.d.mts +1 -1
  65. package/dist/compat/predicate/isElement.d.ts +1 -1
  66. package/dist/compat/predicate/isFinite.d.mts +1 -1
  67. package/dist/compat/predicate/isFinite.d.ts +1 -1
  68. package/dist/compat/predicate/isNaN.d.mts +1 -1
  69. package/dist/compat/predicate/isNaN.d.ts +1 -1
  70. package/dist/compat/predicate/isObject.d.mts +1 -1
  71. package/dist/compat/predicate/isObject.d.ts +1 -1
  72. package/dist/compat/predicate/isObjectLike.d.mts +1 -1
  73. package/dist/compat/predicate/isObjectLike.d.ts +1 -1
  74. package/dist/compat/string/deburr.d.mts +22 -0
  75. package/dist/compat/string/deburr.d.ts +22 -0
  76. package/dist/compat/string/deburr.mjs +8 -0
  77. package/dist/compat/string/escapeRegExp.d.mts +14 -0
  78. package/dist/compat/string/escapeRegExp.d.ts +14 -0
  79. package/dist/compat/string/escapeRegExp.mjs +8 -0
  80. package/dist/compat/string/lowerFirst.d.mts +14 -0
  81. package/dist/compat/string/lowerFirst.d.ts +14 -0
  82. package/dist/compat/string/lowerFirst.mjs +8 -0
  83. package/dist/compat/string/toLower.d.mts +20 -0
  84. package/dist/compat/string/toLower.d.ts +20 -0
  85. package/dist/compat/string/toLower.mjs +7 -0
  86. package/dist/compat/string/unescape.d.mts +16 -0
  87. package/dist/compat/string/unescape.d.ts +16 -0
  88. package/dist/compat/string/unescape.mjs +8 -0
  89. package/dist/compat/string/upperFirst.d.mts +14 -0
  90. package/dist/compat/string/upperFirst.d.ts +14 -0
  91. package/dist/compat/string/upperFirst.mjs +8 -0
  92. package/dist/compat/util/invoke.d.mts +23 -0
  93. package/dist/compat/util/invoke.d.ts +23 -0
  94. package/dist/compat/util/invoke.mjs +48 -0
  95. package/dist/compat/util/lt.d.mts +15 -0
  96. package/dist/compat/util/lt.d.ts +15 -0
  97. package/dist/compat/util/lt.mjs +10 -0
  98. package/dist/compat/util/lte.d.mts +15 -0
  99. package/dist/compat/util/lte.d.ts +15 -0
  100. package/dist/compat/util/lte.mjs +10 -0
  101. package/dist/compat/util/method.d.mts +22 -0
  102. package/dist/compat/util/method.d.ts +22 -0
  103. package/dist/compat/util/method.mjs +9 -0
  104. package/dist/compat/util/now.d.mts +18 -0
  105. package/dist/compat/util/now.d.ts +18 -0
  106. package/dist/compat/util/now.mjs +5 -0
  107. package/dist/compat/util/stubArray.d.mts +10 -0
  108. package/dist/compat/util/stubArray.d.ts +10 -0
  109. package/dist/compat/util/stubArray.mjs +5 -0
  110. package/dist/compat/util/stubFalse.d.mts +10 -0
  111. package/dist/compat/util/stubFalse.d.ts +10 -0
  112. package/dist/compat/util/stubFalse.mjs +5 -0
  113. package/dist/compat/util/stubObject.d.mts +10 -0
  114. package/dist/compat/util/stubObject.d.ts +10 -0
  115. package/dist/compat/util/stubObject.mjs +5 -0
  116. package/dist/compat/util/stubString.d.mts +10 -0
  117. package/dist/compat/util/stubString.d.ts +10 -0
  118. package/dist/compat/util/stubString.mjs +5 -0
  119. package/dist/compat/util/stubTrue.d.mts +10 -0
  120. package/dist/compat/util/stubTrue.d.ts +10 -0
  121. package/dist/compat/util/stubTrue.mjs +5 -0
  122. package/dist/compat/util/toArray.mjs +0 -3
  123. package/dist/compat/util/toPlainObject.d.mts +16 -0
  124. package/dist/compat/util/toPlainObject.d.ts +16 -0
  125. package/dist/compat/util/toPlainObject.mjs +24 -0
  126. package/dist/index.d.mts +1 -0
  127. package/dist/index.d.ts +1 -0
  128. package/dist/index.js +13 -12
  129. package/dist/index.mjs +1 -0
  130. package/dist/math/index.js +26 -10
  131. package/package.json +1 -1
@@ -0,0 +1,32 @@
1
+ import { isBuffer } from '../../predicate/isBuffer.mjs';
2
+ import { isPrototype } from '../_internal/isPrototype.mjs';
3
+ import { isArrayLike } from '../predicate/isArrayLike.mjs';
4
+ import { isTypedArray } from '../predicate/isTypedArray.mjs';
5
+ import { times } from '../util/times.mjs';
6
+
7
+ function keys(object) {
8
+ if (isArrayLike(object)) {
9
+ return arrayLikeKeys(object);
10
+ }
11
+ const result = Object.keys(Object(object));
12
+ if (!isPrototype(object)) {
13
+ return result;
14
+ }
15
+ return result.filter(key => key !== 'constructor');
16
+ }
17
+ function arrayLikeKeys(object) {
18
+ const indices = times(object.length, index => `${index}`);
19
+ const filteredKeys = new Set(indices);
20
+ if (isBuffer(object)) {
21
+ filteredKeys.add('offset');
22
+ filteredKeys.add('parent');
23
+ }
24
+ if (isTypedArray(object)) {
25
+ filteredKeys.add('buffer');
26
+ filteredKeys.add('byteLength');
27
+ filteredKeys.add('byteOffset');
28
+ }
29
+ return [...indices, ...Object.keys(object).filter(key => !filteredKeys.has(key))];
30
+ }
31
+
32
+ export { keys };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates a function that returns the value at a given path of an object.
3
+ *
4
+ * Unlike `property`, which creates a function bound to a specific path and allows you to query different objects,
5
+ * `propertyOf` creates a function bound to a specific object and allows you to query different paths within that object.
6
+ *
7
+ * @param {unknown} object - The object to query.
8
+ * @returns {(path: PropertyKey | PropertyKey[]) => unknown} - Returns a new function that takes a path and retrieves the value from the object at the specified path.
9
+ *
10
+ * @example
11
+ * const getValue = propertyOf({ a: { b: { c: 3 } } });
12
+ * const result = getValue('a.b.c');
13
+ * console.log(result); // => 3
14
+ *
15
+ * @example
16
+ * const getValue = propertyOf({ a: { b: { c: 3 } } });
17
+ * const result = getValue(['a', 'b', 'c']);
18
+ * console.log(result); // => 3
19
+ */
20
+ declare function propertyOf(object: unknown): (path: PropertyKey | readonly PropertyKey[]) => unknown;
21
+
22
+ export { propertyOf };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Creates a function that returns the value at a given path of an object.
3
+ *
4
+ * Unlike `property`, which creates a function bound to a specific path and allows you to query different objects,
5
+ * `propertyOf` creates a function bound to a specific object and allows you to query different paths within that object.
6
+ *
7
+ * @param {unknown} object - The object to query.
8
+ * @returns {(path: PropertyKey | PropertyKey[]) => unknown} - Returns a new function that takes a path and retrieves the value from the object at the specified path.
9
+ *
10
+ * @example
11
+ * const getValue = propertyOf({ a: { b: { c: 3 } } });
12
+ * const result = getValue('a.b.c');
13
+ * console.log(result); // => 3
14
+ *
15
+ * @example
16
+ * const getValue = propertyOf({ a: { b: { c: 3 } } });
17
+ * const result = getValue(['a', 'b', 'c']);
18
+ * console.log(result); // => 3
19
+ */
20
+ declare function propertyOf(object: unknown): (path: PropertyKey | readonly PropertyKey[]) => unknown;
21
+
22
+ export { propertyOf };
@@ -0,0 +1,9 @@
1
+ import { get } from './get.mjs';
2
+
3
+ function propertyOf(object) {
4
+ return function (path) {
5
+ return get(object, path);
6
+ };
7
+ }
8
+
9
+ export { propertyOf };
@@ -12,6 +12,6 @@
12
12
  * isArrayLike(null); // false
13
13
  * isArrayLike(undefined); // false
14
14
  */
15
- declare function isArrayLike(value: unknown): value is ArrayLike<unknown>;
15
+ declare function isArrayLike(value?: unknown): value is ArrayLike<unknown>;
16
16
 
17
17
  export { isArrayLike };
@@ -12,6 +12,6 @@
12
12
  * isArrayLike(null); // false
13
13
  * isArrayLike(undefined); // false
14
14
  */
15
- declare function isArrayLike(value: unknown): value is ArrayLike<unknown>;
15
+ declare function isArrayLike(value?: unknown): value is ArrayLike<unknown>;
16
16
 
17
17
  export { isArrayLike };
@@ -10,6 +10,6 @@
10
10
  * isArrayLikeObject('abc'); // false
11
11
  * isArrayLikeObject(()=>{}); // false
12
12
  */
13
- declare function isArrayLikeObject(value: unknown): value is ArrayLike<unknown> & object;
13
+ declare function isArrayLikeObject(value?: unknown): value is ArrayLike<unknown> & object;
14
14
 
15
15
  export { isArrayLikeObject };
@@ -10,6 +10,6 @@
10
10
  * isArrayLikeObject('abc'); // false
11
11
  * isArrayLikeObject(()=>{}); // false
12
12
  */
13
- declare function isArrayLikeObject(value: unknown): value is ArrayLike<unknown> & object;
13
+ declare function isArrayLikeObject(value?: unknown): value is ArrayLike<unknown> & object;
14
14
 
15
15
  export { isArrayLikeObject };
@@ -8,6 +8,6 @@
8
8
  * console.log(isElement(document.body)); // true
9
9
  * console.log(isElement('<body>')); // false
10
10
  */
11
- declare function isElement(value: any): boolean;
11
+ declare function isElement(value?: any): boolean;
12
12
 
13
13
  export { isElement };
@@ -8,6 +8,6 @@
8
8
  * console.log(isElement(document.body)); // true
9
9
  * console.log(isElement('<body>')); // false
10
10
  */
11
- declare function isElement(value: any): boolean;
11
+ declare function isElement(value?: any): boolean;
12
12
 
13
13
  export { isElement };
@@ -15,6 +15,6 @@
15
15
  * console.log(isFinite(value3)); // false
16
16
  * ```
17
17
  */
18
- declare function isFinite(value: unknown): value is number;
18
+ declare function isFinite(value?: unknown): value is number;
19
19
 
20
20
  export { isFinite };
@@ -15,6 +15,6 @@
15
15
  * console.log(isFinite(value3)); // false
16
16
  * ```
17
17
  */
18
- declare function isFinite(value: unknown): value is number;
18
+ declare function isFinite(value?: unknown): value is number;
19
19
 
20
20
  export { isFinite };
@@ -10,6 +10,6 @@
10
10
  * isNaN('NaN'); // false
11
11
  * isNaN(undefined); // false
12
12
  */
13
- declare function isNaN(value: unknown): value is typeof NaN;
13
+ declare function isNaN(value?: unknown): value is typeof NaN;
14
14
 
15
15
  export { isNaN };
@@ -10,6 +10,6 @@
10
10
  * isNaN('NaN'); // false
11
11
  * isNaN(undefined); // false
12
12
  */
13
- declare function isNaN(value: unknown): value is typeof NaN;
13
+ declare function isNaN(value?: unknown): value is typeof NaN;
14
14
 
15
15
  export { isNaN };
@@ -21,6 +21,6 @@
21
21
  * console.log(isObject(value3)); // true
22
22
  * console.log(isObject(value4)); // false
23
23
  */
24
- declare function isObject(value: unknown): value is object;
24
+ declare function isObject(value?: unknown): value is object;
25
25
 
26
26
  export { isObject };
@@ -21,6 +21,6 @@
21
21
  * console.log(isObject(value3)); // true
22
22
  * console.log(isObject(value4)); // false
23
23
  */
24
- declare function isObject(value: unknown): value is object;
24
+ declare function isObject(value?: unknown): value is object;
25
25
 
26
26
  export { isObject };
@@ -22,6 +22,6 @@
22
22
  * console.log(isObjectLike(value4)); // false
23
23
  * console.log(isObjectLike(value5)); // false
24
24
  */
25
- declare function isObjectLike(value: unknown): value is object;
25
+ declare function isObjectLike(value?: unknown): value is object;
26
26
 
27
27
  export { isObjectLike };
@@ -22,6 +22,6 @@
22
22
  * console.log(isObjectLike(value4)); // false
23
23
  * console.log(isObjectLike(value5)); // false
24
24
  */
25
- declare function isObjectLike(value: unknown): value is object;
25
+ declare function isObjectLike(value?: unknown): value is object;
26
26
 
27
27
  export { isObjectLike };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
3
+ * For example, "Crème brûlée" becomes "Creme brulee".
4
+ *
5
+ * @param {string} str - The input string to be deburred.
6
+ * @returns {string} - The deburred string with special characters replaced by their ASCII equivalents.
7
+ *
8
+ * @example
9
+ * // Basic usage:
10
+ * deburr('Æthelred') // returns 'Aethelred'
11
+ *
12
+ * @example
13
+ * // Handling diacritical marks:
14
+ * deburr('München') // returns 'Munchen'
15
+ *
16
+ * @example
17
+ * // Special characters:
18
+ * deburr('Crème brûlée') // returns 'Creme brulee'
19
+ */
20
+ declare function deburr(str?: string): string;
21
+
22
+ export { deburr };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
3
+ * For example, "Crème brûlée" becomes "Creme brulee".
4
+ *
5
+ * @param {string} str - The input string to be deburred.
6
+ * @returns {string} - The deburred string with special characters replaced by their ASCII equivalents.
7
+ *
8
+ * @example
9
+ * // Basic usage:
10
+ * deburr('Æthelred') // returns 'Aethelred'
11
+ *
12
+ * @example
13
+ * // Handling diacritical marks:
14
+ * deburr('München') // returns 'Munchen'
15
+ *
16
+ * @example
17
+ * // Special characters:
18
+ * deburr('Crème brûlée') // returns 'Creme brulee'
19
+ */
20
+ declare function deburr(str?: string): string;
21
+
22
+ export { deburr };
@@ -0,0 +1,8 @@
1
+ import { deburr as deburr$1 } from '../../string/deburr.mjs';
2
+ import { toString } from '../util/toString.mjs';
3
+
4
+ function deburr(str) {
5
+ return deburr$1(toString(str));
6
+ }
7
+
8
+ export { deburr };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
3
+ *
4
+ * @param {string} str The string to escape.
5
+ * @returns {string} Returns the escaped string.
6
+ *
7
+ * @example
8
+ * import { escapeRegExp } from 'es-toolkit/string';
9
+ *
10
+ * escapeRegExp('[es-toolkit](https://es-toolkit.slash.page/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.slash\.page/\)'
11
+ */
12
+ declare function escapeRegExp(str?: string): string;
13
+
14
+ export { escapeRegExp };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Escapes the RegExp special characters "^", "$", "\\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in `str`.
3
+ *
4
+ * @param {string} str The string to escape.
5
+ * @returns {string} Returns the escaped string.
6
+ *
7
+ * @example
8
+ * import { escapeRegExp } from 'es-toolkit/string';
9
+ *
10
+ * escapeRegExp('[es-toolkit](https://es-toolkit.slash.page/)'); // returns '\[es-toolkit\]\(https://es-toolkit\.slash\.page/\)'
11
+ */
12
+ declare function escapeRegExp(str?: string): string;
13
+
14
+ export { escapeRegExp };
@@ -0,0 +1,8 @@
1
+ import { escapeRegExp as escapeRegExp$1 } from '../../string/escapeRegExp.mjs';
2
+ import { toString } from '../util/toString.mjs';
3
+
4
+ function escapeRegExp(str) {
5
+ return escapeRegExp$1(toString(str));
6
+ }
7
+
8
+ export { escapeRegExp };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts the first character of string to lower case.
3
+ *
4
+ * @param {string} str - The string that is to be changed
5
+ * @returns {string} - The converted string.
6
+ *
7
+ * @example
8
+ * const convertedStr1 = lowerCase('fred') // returns 'fred'
9
+ * const convertedStr2 = lowerCase('Fred') // returns 'fred'
10
+ * const convertedStr3 = lowerCase('FRED') // returns 'fRED'
11
+ */
12
+ declare function lowerFirst(str?: string): string;
13
+
14
+ export { lowerFirst };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts the first character of string to lower case.
3
+ *
4
+ * @param {string} str - The string that is to be changed
5
+ * @returns {string} - The converted string.
6
+ *
7
+ * @example
8
+ * const convertedStr1 = lowerCase('fred') // returns 'fred'
9
+ * const convertedStr2 = lowerCase('Fred') // returns 'fred'
10
+ * const convertedStr3 = lowerCase('FRED') // returns 'fRED'
11
+ */
12
+ declare function lowerFirst(str?: string): string;
13
+
14
+ export { lowerFirst };
@@ -0,0 +1,8 @@
1
+ import { lowerFirst as lowerFirst$1 } from '../../string/lowerFirst.mjs';
2
+ import { toString } from '../util/toString.mjs';
3
+
4
+ function lowerFirst(str) {
5
+ return lowerFirst$1(toString(str));
6
+ }
7
+
8
+ export { lowerFirst };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts the given value to a string and transforms it to lower case.
3
+ * The function can handle various input types by first converting them to strings.
4
+ *
5
+ * @param {unknown} [value=''] The value to convert.
6
+ * @returns {string} Returns the lower cased string.
7
+ * @example
8
+ *
9
+ * toLower('--FOO-BAR--');
10
+ * // => '--foo-bar--'
11
+ *
12
+ * toLower(null);
13
+ * // => ''
14
+ *
15
+ * toLower([1, 2, 3]);
16
+ * // => '1,2,3'
17
+ */
18
+ declare function toLower(value?: unknown): string;
19
+
20
+ export { toLower };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts the given value to a string and transforms it to lower case.
3
+ * The function can handle various input types by first converting them to strings.
4
+ *
5
+ * @param {unknown} [value=''] The value to convert.
6
+ * @returns {string} Returns the lower cased string.
7
+ * @example
8
+ *
9
+ * toLower('--FOO-BAR--');
10
+ * // => '--foo-bar--'
11
+ *
12
+ * toLower(null);
13
+ * // => ''
14
+ *
15
+ * toLower([1, 2, 3]);
16
+ * // => '1,2,3'
17
+ */
18
+ declare function toLower(value?: unknown): string;
19
+
20
+ export { toLower };
@@ -0,0 +1,7 @@
1
+ import { toString } from '../util/toString.mjs';
2
+
3
+ function toLower(value) {
4
+ return toString(value).toLowerCase();
5
+ }
6
+
7
+ export { toLower };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `str` to their corresponding characters.
3
+ * It is the inverse of `escape`.
4
+ *
5
+ * @param {string} str The string to unescape.
6
+ * @returns {string} Returns the unescaped string.
7
+ *
8
+ * @example
9
+ * unescape('This is a &lt;div&gt; element.'); // returns 'This is a <div> element.'
10
+ * unescape('This is a &quot;quote&quot;'); // returns 'This is a "quote"'
11
+ * unescape('This is a &#39;quote&#39;'); // returns 'This is a 'quote''
12
+ * unescape('This is a &amp; symbol'); // returns 'This is a & symbol'
13
+ */
14
+ declare function unescape(str?: string): string;
15
+
16
+ export { unescape };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `str` to their corresponding characters.
3
+ * It is the inverse of `escape`.
4
+ *
5
+ * @param {string} str The string to unescape.
6
+ * @returns {string} Returns the unescaped string.
7
+ *
8
+ * @example
9
+ * unescape('This is a &lt;div&gt; element.'); // returns 'This is a <div> element.'
10
+ * unescape('This is a &quot;quote&quot;'); // returns 'This is a "quote"'
11
+ * unescape('This is a &#39;quote&#39;'); // returns 'This is a 'quote''
12
+ * unescape('This is a &amp; symbol'); // returns 'This is a & symbol'
13
+ */
14
+ declare function unescape(str?: string): string;
15
+
16
+ export { unescape };
@@ -0,0 +1,8 @@
1
+ import { unescape as unescape$1 } from '../../string/unescape.mjs';
2
+ import { toString } from '../util/toString.mjs';
3
+
4
+ function unescape(str) {
5
+ return unescape$1(toString(str));
6
+ }
7
+
8
+ export { unescape };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts the first character of string to upper case.
3
+ *
4
+ * @param {string} str - The string that is to be changed
5
+ * @returns {string} - The converted string.
6
+ *
7
+ * @example
8
+ * const convertedStr1 = upperFirst('fred') // returns 'Fred'
9
+ * const convertedStr2 = upperFirst('Fred') // returns 'Fred'
10
+ * const convertedStr3 = upperFirst('FRED') // returns 'FRED'
11
+ */
12
+ declare function upperFirst(str?: string): string;
13
+
14
+ export { upperFirst };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Converts the first character of string to upper case.
3
+ *
4
+ * @param {string} str - The string that is to be changed
5
+ * @returns {string} - The converted string.
6
+ *
7
+ * @example
8
+ * const convertedStr1 = upperFirst('fred') // returns 'Fred'
9
+ * const convertedStr2 = upperFirst('Fred') // returns 'Fred'
10
+ * const convertedStr3 = upperFirst('FRED') // returns 'FRED'
11
+ */
12
+ declare function upperFirst(str?: string): string;
13
+
14
+ export { upperFirst };
@@ -0,0 +1,8 @@
1
+ import { upperFirst as upperFirst$1 } from '../../string/upperFirst.mjs';
2
+ import { toString } from '../util/toString.mjs';
3
+
4
+ function upperFirst(str) {
5
+ return upperFirst$1(toString(str));
6
+ }
7
+
8
+ export { upperFirst };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Invokes the method at `path` of `object` with the given arguments.
3
+ *
4
+ * @param {unknown} object - The object to query.
5
+ * @param {PropertyKey | PropertyKey[]} path - The path of the method to invoke.
6
+ * @param {any[]} args - The arguments to invoke the method with.
7
+ * @returns {any} - Returns the result of the invoked method.
8
+ *
9
+ * @example
10
+ * const object = {
11
+ * a: {
12
+ * b: function (x, y) {
13
+ * return x + y;
14
+ * }
15
+ * }
16
+ * };
17
+ *
18
+ * invoke(object, 'a.b', [1, 2]); // => 3
19
+ * invoke(object, ['a', 'b'], [1, 2]); // => 3
20
+ */
21
+ declare function invoke(object: unknown, path: PropertyKey | PropertyKey[], args?: any[]): any;
22
+
23
+ export { invoke };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Invokes the method at `path` of `object` with the given arguments.
3
+ *
4
+ * @param {unknown} object - The object to query.
5
+ * @param {PropertyKey | PropertyKey[]} path - The path of the method to invoke.
6
+ * @param {any[]} args - The arguments to invoke the method with.
7
+ * @returns {any} - Returns the result of the invoked method.
8
+ *
9
+ * @example
10
+ * const object = {
11
+ * a: {
12
+ * b: function (x, y) {
13
+ * return x + y;
14
+ * }
15
+ * }
16
+ * };
17
+ *
18
+ * invoke(object, 'a.b', [1, 2]); // => 3
19
+ * invoke(object, ['a', 'b'], [1, 2]); // => 3
20
+ */
21
+ declare function invoke(object: unknown, path: PropertyKey | PropertyKey[], args?: any[]): any;
22
+
23
+ export { invoke };
@@ -0,0 +1,48 @@
1
+ import { toPath } from './toPath.mjs';
2
+ import { toKey } from '../_internal/toKey.mjs';
3
+ import { last } from '../array/last.mjs';
4
+ import { get } from '../object/get.mjs';
5
+
6
+ function invoke(object, path, args = []) {
7
+ if (object == null) {
8
+ return;
9
+ }
10
+ switch (typeof path) {
11
+ case 'string': {
12
+ if (typeof object === 'object' && Object.hasOwn(object, path)) {
13
+ return invokeImpl(object, [path], args);
14
+ }
15
+ return invokeImpl(object, toPath(path), args);
16
+ }
17
+ case 'number':
18
+ case 'symbol': {
19
+ return invokeImpl(object, [path], args);
20
+ }
21
+ default: {
22
+ if (Array.isArray(path)) {
23
+ return invokeImpl(object, path, args);
24
+ }
25
+ else {
26
+ return invokeImpl(object, [path], args);
27
+ }
28
+ }
29
+ }
30
+ }
31
+ function invokeImpl(object, path, args) {
32
+ const parent = get(object, path.slice(0, -1), object);
33
+ if (parent == null) {
34
+ return undefined;
35
+ }
36
+ let lastKey = last(path);
37
+ let lastValue = lastKey?.valueOf();
38
+ if (typeof lastValue === 'number') {
39
+ lastKey = toKey(lastValue);
40
+ }
41
+ else {
42
+ lastKey = String(lastKey);
43
+ }
44
+ const func = get(parent, lastKey);
45
+ return func?.apply(parent, args);
46
+ }
47
+
48
+ export { invoke };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is less than other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is less than other, else `false`.
7
+ *
8
+ * @example
9
+ * lt(1, 3); // true
10
+ * lt(3, 3); // false
11
+ * lt(3, 1); // false
12
+ */
13
+ declare function lt(value: unknown, other: unknown): boolean;
14
+
15
+ export { lt };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is less than other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is less than other, else `false`.
7
+ *
8
+ * @example
9
+ * lt(1, 3); // true
10
+ * lt(3, 3); // false
11
+ * lt(3, 1); // false
12
+ */
13
+ declare function lt(value: unknown, other: unknown): boolean;
14
+
15
+ export { lt };
@@ -0,0 +1,10 @@
1
+ import { toNumber } from './toNumber.mjs';
2
+
3
+ function lt(value, other) {
4
+ if (typeof value === 'string' && typeof other === 'string') {
5
+ return value < other;
6
+ }
7
+ return toNumber(value) < toNumber(other);
8
+ }
9
+
10
+ export { lt };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Checks if value is less than or equal to other.
3
+ *
4
+ * @param {unknown} value The value to compare.
5
+ * @param {unknown} other The other value to compare.
6
+ * @returns {boolean} Returns `true` if value is less than or equal to other, else `false`.
7
+ *
8
+ * @example
9
+ * lte(1, 3); // => true
10
+ * lte(3, 3); // => true
11
+ * lte(3, 1); // => false
12
+ */
13
+ declare function lte(value: unknown, other: unknown): boolean;
14
+
15
+ export { lte };