es-toolkit 1.20.0-dev.634 → 1.20.0-dev.636

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.
@@ -9,7 +9,7 @@ const range = require('../_chunk/range-BXlMmn.js');
9
9
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
10
10
  const toMerged = require('../_chunk/toMerged-Bzkqyz.js');
11
11
  const isPlainObject$1 = require('../_chunk/isPlainObject-BIekvL.js');
12
- const isWeakSet$1 = require('../_chunk/isWeakSet-E_VMwB.js');
12
+ const isWeakSet$1 = require('../_chunk/isWeakSet-1xFSnK.js');
13
13
  const string_index = require('../string/index.js');
14
14
 
15
15
  function castArray(value) {
@@ -561,7 +561,7 @@ const compareValues = (a, b, order) => {
561
561
  };
562
562
 
563
563
  function isSymbol(value) {
564
- return typeof value === 'symbol' || (value != null && value instanceof Symbol);
564
+ return typeof value === 'symbol' || value instanceof Symbol;
565
565
  }
566
566
 
567
567
  const regexIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
@@ -1228,14 +1228,8 @@ function isObject(value) {
1228
1228
  return value !== null && (typeof value === 'object' || typeof value === 'function');
1229
1229
  }
1230
1230
 
1231
- function isBoolean(x) {
1232
- if (x === true || x === false) {
1233
- return true;
1234
- }
1235
- if (typeof x === 'object' && x != null && isWeakSet$1.getTag(x) === '[object Boolean]') {
1236
- return true;
1237
- }
1238
- return false;
1231
+ function isBoolean(value) {
1232
+ return typeof value === 'boolean' || value instanceof Boolean;
1239
1233
  }
1240
1234
 
1241
1235
  function isError(value) {
@@ -1243,17 +1237,11 @@ function isError(value) {
1243
1237
  }
1244
1238
 
1245
1239
  function isRegExp(value) {
1246
- return isWeakSet$1.getTag(value) === '[object RegExp]';
1240
+ return isWeakSet$1.isRegExp(value);
1247
1241
  }
1248
1242
 
1249
1243
  function isString(value) {
1250
- if (typeof value === 'string') {
1251
- return true;
1252
- }
1253
- if (typeof value === 'object' && value != null && isWeakSet$1.getTag(value) === '[object String]') {
1254
- return true;
1255
- }
1256
- return false;
1244
+ return typeof value === 'string' || value instanceof String;
1257
1245
  }
1258
1246
 
1259
1247
  function isWeakMap(value) {
@@ -1297,10 +1285,7 @@ function isSafeInteger(value) {
1297
1285
  }
1298
1286
 
1299
1287
  function isNumber(value) {
1300
- if (typeof value === 'object' && value != null && isWeakSet$1.getTag(value) === '[object Number]') {
1301
- return true;
1302
- }
1303
- return typeof value === 'number';
1288
+ return typeof value === 'number' || value instanceof Number;
1304
1289
  }
1305
1290
 
1306
1291
  function isNaN(value) {
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
8
8
  *
9
- * @param {unknown} x - The Value to test if it is boolean.
10
- * @returns {x is boolean} True if the value is boolean, false otherwise.
9
+ * @param {unknown} value - The Value to test if it is boolean.
10
+ * @returns {value is boolean} True if the value is boolean, false otherwise.
11
11
  *
12
12
  * @example
13
13
  *
@@ -20,6 +20,6 @@
20
20
  * console.log(isBoolean(value3)); // false
21
21
  *
22
22
  */
23
- declare function isBoolean(x: unknown): x is boolean;
23
+ declare function isBoolean(value?: unknown): value is boolean;
24
24
 
25
25
  export { isBoolean };
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
8
8
  *
9
- * @param {unknown} x - The Value to test if it is boolean.
10
- * @returns {x is boolean} True if the value is boolean, false otherwise.
9
+ * @param {unknown} value - The Value to test if it is boolean.
10
+ * @returns {value is boolean} True if the value is boolean, false otherwise.
11
11
  *
12
12
  * @example
13
13
  *
@@ -20,6 +20,6 @@
20
20
  * console.log(isBoolean(value3)); // false
21
21
  *
22
22
  */
23
- declare function isBoolean(x: unknown): x is boolean;
23
+ declare function isBoolean(value?: unknown): value is boolean;
24
24
 
25
25
  export { isBoolean };
@@ -1,13 +1,5 @@
1
- import { getTag } from '../_internal/getTag.mjs';
2
-
3
- function isBoolean(x) {
4
- if (x === true || x === false) {
5
- return true;
6
- }
7
- if (typeof x === 'object' && x != null && getTag(x) === '[object Boolean]') {
8
- return true;
9
- }
10
- return false;
1
+ function isBoolean(value) {
2
+ return typeof value === 'boolean' || value instanceof Boolean;
11
3
  }
12
4
 
13
5
  export { isBoolean };
@@ -1,10 +1,5 @@
1
- import { getTag } from '../_internal/getTag.mjs';
2
-
3
1
  function isNumber(value) {
4
- if (typeof value === 'object' && value != null && getTag(value) === '[object Number]') {
5
- return true;
6
- }
7
- return typeof value === 'number';
2
+ return typeof value === 'number' || value instanceof Number;
8
3
  }
9
4
 
10
5
  export { isNumber };
@@ -1,7 +1,7 @@
1
- import { getTag } from '../_internal/getTag.mjs';
1
+ import { isRegExp as isRegExp$1 } from '../../predicate/isRegExp.mjs';
2
2
 
3
3
  function isRegExp(value) {
4
- return getTag(value) === '[object RegExp]';
4
+ return isRegExp$1(value);
5
5
  }
6
6
 
7
7
  export { isRegExp };
@@ -15,6 +15,6 @@
15
15
  * console.log(isString(value2)); // false
16
16
  * console.log(isString(value3)); // false
17
17
  */
18
- declare function isString(value: unknown): value is string;
18
+ declare function isString(value?: unknown): value is string;
19
19
 
20
20
  export { isString };
@@ -15,6 +15,6 @@
15
15
  * console.log(isString(value2)); // false
16
16
  * console.log(isString(value3)); // false
17
17
  */
18
- declare function isString(value: unknown): value is string;
18
+ declare function isString(value?: unknown): value is string;
19
19
 
20
20
  export { isString };
@@ -1,13 +1,5 @@
1
- import { getTag } from '../_internal/getTag.mjs';
2
-
3
1
  function isString(value) {
4
- if (typeof value === 'string') {
5
- return true;
6
- }
7
- if (typeof value === 'object' && value != null && getTag(value) === '[object String]') {
8
- return true;
9
- }
10
- return false;
2
+ return typeof value === 'string' || value instanceof String;
11
3
  }
12
4
 
13
5
  export { isString };
@@ -1,5 +1,5 @@
1
1
  function isSymbol(value) {
2
- return typeof value === 'symbol' || (value != null && value instanceof Symbol);
2
+ return typeof value === 'symbol' || value instanceof Symbol;
3
3
  }
4
4
 
5
5
  export { isSymbol };
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ const randomInt = require('./_chunk/randomInt-CF7bZK.js');
12
12
  const math_index = require('./math/index.js');
13
13
  const object_index = require('./object/index.js');
14
14
  const toMerged = require('./_chunk/toMerged-Bzkqyz.js');
15
- const isWeakSet = require('./_chunk/isWeakSet-E_VMwB.js');
15
+ const isWeakSet = require('./_chunk/isWeakSet-1xFSnK.js');
16
16
  const predicate_index = require('./predicate/index.js');
17
17
  const isPlainObject = require('./_chunk/isPlainObject-BIekvL.js');
18
18
  const string_index = require('./string/index.js');
@@ -125,12 +125,12 @@ exports.isLength = isWeakSet.isLength;
125
125
  exports.isNil = isWeakSet.isNil;
126
126
  exports.isNotNil = isWeakSet.isNotNil;
127
127
  exports.isNull = isWeakSet.isNull;
128
+ exports.isRegExp = isWeakSet.isRegExp;
128
129
  exports.isUndefined = isWeakSet.isUndefined;
129
130
  exports.isWeakMap = isWeakSet.isWeakMap;
130
131
  exports.isWeakSet = isWeakSet.isWeakSet;
131
132
  exports.isBoolean = predicate_index.isBoolean;
132
133
  exports.isError = predicate_index.isError;
133
- exports.isRegExp = predicate_index.isRegExp;
134
134
  exports.isString = predicate_index.isString;
135
135
  exports.isSymbol = predicate_index.isSymbol;
136
136
  exports.isPlainObject = isPlainObject.isPlainObject;
@@ -2,17 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-E_VMwB.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-1xFSnK.js');
6
6
  const isPlainObject = require('../_chunk/isPlainObject-BIekvL.js');
7
7
 
8
8
  function isError(value) {
9
9
  return value instanceof Error;
10
10
  }
11
11
 
12
- function isRegExp(value) {
13
- return value instanceof RegExp;
14
- }
15
-
16
12
  function isBoolean(x) {
17
13
  return typeof x === 'boolean';
18
14
  }
@@ -32,6 +28,7 @@ exports.isLength = isWeakSet.isLength;
32
28
  exports.isNil = isWeakSet.isNil;
33
29
  exports.isNotNil = isWeakSet.isNotNil;
34
30
  exports.isNull = isWeakSet.isNull;
31
+ exports.isRegExp = isWeakSet.isRegExp;
35
32
  exports.isUndefined = isWeakSet.isUndefined;
36
33
  exports.isWeakMap = isWeakSet.isWeakMap;
37
34
  exports.isWeakSet = isWeakSet.isWeakSet;
@@ -40,6 +37,5 @@ exports.isPrimitive = isPlainObject.isPrimitive;
40
37
  exports.isTypedArray = isPlainObject.isTypedArray;
41
38
  exports.isBoolean = isBoolean;
42
39
  exports.isError = isError;
43
- exports.isRegExp = isRegExp;
44
40
  exports.isString = isString;
45
41
  exports.isSymbol = isSymbol;
@@ -11,10 +11,16 @@
11
11
  * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.
12
12
  *
13
13
  * @example
14
+ * async function fetchData() {
15
+ * const response = await fetch('https://example.com/data');
16
+ * return response.json();
17
+ * }
18
+ *
14
19
  * try {
15
- * await withTimeout(() => {}, 1000); // Timeout exception after 1 second
20
+ * const data = await withTimeout(fetchData, 1000);
21
+ * console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second.
16
22
  * } catch (error) {
17
- * console.error(error); // Will log 'TimeoutError'
23
+ * console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second.
18
24
  * }
19
25
  */
20
26
  declare function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T>;
@@ -11,10 +11,16 @@
11
11
  * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.
12
12
  *
13
13
  * @example
14
+ * async function fetchData() {
15
+ * const response = await fetch('https://example.com/data');
16
+ * return response.json();
17
+ * }
18
+ *
14
19
  * try {
15
- * await withTimeout(() => {}, 1000); // Timeout exception after 1 second
20
+ * const data = await withTimeout(fetchData, 1000);
21
+ * console.log(data); // Logs the fetched data if `fetchData` is resolved within 1 second.
16
22
  * } catch (error) {
17
- * console.error(error); // Will log 'TimeoutError'
23
+ * console.error(error); // Will log 'TimeoutError' if `fetchData` is not resolved within 1 second.
18
24
  * }
19
25
  */
20
26
  declare function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.20.0-dev.634+d2af34e0",
4
+ "version": "1.20.0-dev.636+a4de80c2",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {