es-toolkit 1.22.0-dev.695 → 1.22.0-dev.697

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 (36) hide show
  1. package/dist/_chunk/{isPlainObject-BIekvL.js → isPlainObject-DKBeLp.js} +7 -7
  2. package/dist/_chunk/{isWeakSet-clQklw.js → isWeakSet-DDVaWr.js} +46 -2
  3. package/dist/_chunk/{toMerged-2WPeoI.js → toMerged-DD-s3X.js} +3 -3
  4. package/dist/browser.global.js +1 -1
  5. package/dist/browser.global.js.map +1 -1
  6. package/dist/compat/index.d.mts +3 -0
  7. package/dist/compat/index.d.ts +3 -0
  8. package/dist/compat/index.js +8 -5
  9. package/dist/compat/index.mjs +3 -0
  10. package/dist/compat/object/has.mjs +1 -1
  11. package/dist/compat/object/pick.mjs +1 -1
  12. package/dist/index.d.mts +3 -0
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.js +6 -3
  15. package/dist/index.mjs +3 -0
  16. package/dist/object/cloneDeep.mjs +2 -2
  17. package/dist/object/index.js +2 -2
  18. package/dist/object/pick.mjs +1 -1
  19. package/dist/predicate/index.d.mts +3 -0
  20. package/dist/predicate/index.d.ts +3 -0
  21. package/dist/predicate/index.js +5 -2
  22. package/dist/predicate/index.mjs +3 -0
  23. package/dist/predicate/isEqual.mjs +1 -1
  24. package/dist/predicate/isJSONArray.d.mts +17 -0
  25. package/dist/predicate/isJSONArray.d.ts +17 -0
  26. package/dist/predicate/isJSONArray.mjs +10 -0
  27. package/dist/predicate/isJSONObject.d.mts +16 -0
  28. package/dist/predicate/isJSONObject.d.ts +16 -0
  29. package/dist/predicate/isJSONObject.mjs +22 -0
  30. package/dist/predicate/isJSONValue.d.mts +27 -0
  31. package/dist/predicate/isJSONValue.d.ts +27 -0
  32. package/dist/predicate/isJSONValue.mjs +20 -0
  33. package/dist/predicate/isPlainObject.d.mts +3 -3
  34. package/dist/predicate/isPlainObject.d.ts +3 -3
  35. package/dist/predicate/isPlainObject.mjs +7 -7
  36. package/package.json +1 -1
@@ -79,6 +79,9 @@ export { isUndefined } from '../predicate/isUndefined.mjs';
79
79
  export { isLength } from '../predicate/isLength.mjs';
80
80
  export { isFunction } from '../predicate/isFunction.mjs';
81
81
  export { isPrimitive } from '../predicate/isPrimitive.mjs';
82
+ export { isJSONObject } from '../predicate/isJSONObject.mjs';
83
+ export { isJSONValue } from '../predicate/isJSONValue.mjs';
84
+ export { isJSONArray } from '../predicate/isJSONArray.mjs';
82
85
  export { isSet } from '../predicate/isSet.mjs';
83
86
  export { delay } from '../promise/delay.mjs';
84
87
  export { withTimeout } from '../promise/withTimeout.mjs';
@@ -79,6 +79,9 @@ export { isUndefined } from '../predicate/isUndefined.js';
79
79
  export { isLength } from '../predicate/isLength.js';
80
80
  export { isFunction } from '../predicate/isFunction.js';
81
81
  export { isPrimitive } from '../predicate/isPrimitive.js';
82
+ export { isJSONObject } from '../predicate/isJSONObject.js';
83
+ export { isJSONValue } from '../predicate/isJSONValue.js';
84
+ export { isJSONArray } from '../predicate/isJSONArray.js';
82
85
  export { isSet } from '../predicate/isSet.js';
83
86
  export { delay } from '../promise/delay.js';
84
87
  export { withTimeout } from '../promise/withTimeout.js';
@@ -7,9 +7,9 @@ const promise_index = require('../_chunk/index-BGZDR9.js');
7
7
  const flowRight = require('../_chunk/flowRight-BzdOZX.js');
8
8
  const range = require('../_chunk/range-BXlMmn.js');
9
9
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
10
- const toMerged = require('../_chunk/toMerged-2WPeoI.js');
11
- const isPlainObject$1 = require('../_chunk/isPlainObject-BIekvL.js');
12
- const isWeakSet$1 = require('../_chunk/isWeakSet-clQklw.js');
10
+ const toMerged = require('../_chunk/toMerged-DD-s3X.js');
11
+ const isPlainObject$1 = require('../_chunk/isPlainObject-DKBeLp.js');
12
+ const isWeakSet$1 = require('../_chunk/isWeakSet-DDVaWr.js');
13
13
  const pad$1 = require('../_chunk/pad-Cw2pvt.js');
14
14
 
15
15
  function castArray(value) {
@@ -338,7 +338,7 @@ function has(object, path) {
338
338
  let current = object;
339
339
  for (let i = 0; i < resolvedPath.length; i++) {
340
340
  const key = resolvedPath[i];
341
- if (current == null || !Object.prototype.hasOwnProperty.call(current, key)) {
341
+ if (current == null || !Object.hasOwn(current, key)) {
342
342
  const isSparseIndex = (Array.isArray(current) || isArguments(current)) && isIndex(key) && key < current.length;
343
343
  if (!isSparseIndex) {
344
344
  return false;
@@ -1152,7 +1152,7 @@ function pick(obj, ...keysArr) {
1152
1152
  }
1153
1153
  for (const key of keys) {
1154
1154
  const value = get(obj, key);
1155
- if (typeof key === 'string' && Object.prototype.hasOwnProperty.call(obj, key)) {
1155
+ if (typeof key === 'string' && Object.hasOwn(obj, key)) {
1156
1156
  result[key] = value;
1157
1157
  }
1158
1158
  else {
@@ -1873,6 +1873,9 @@ exports.isPrimitive = isPlainObject$1.isPrimitive;
1873
1873
  exports.isDate = isWeakSet$1.isDate;
1874
1874
  exports.isEqual = isWeakSet$1.isEqual;
1875
1875
  exports.isFunction = isWeakSet$1.isFunction;
1876
+ exports.isJSONArray = isWeakSet$1.isJSONArray;
1877
+ exports.isJSONObject = isWeakSet$1.isJSONObject;
1878
+ exports.isJSONValue = isWeakSet$1.isJSONValue;
1876
1879
  exports.isLength = isWeakSet$1.isLength;
1877
1880
  exports.isMap = isWeakSet$1.isMap;
1878
1881
  exports.isNotNil = isWeakSet$1.isNotNil;
@@ -80,6 +80,9 @@ export { isNull } from '../predicate/isNull.mjs';
80
80
  export { isUndefined } from '../predicate/isUndefined.mjs';
81
81
  export { isLength } from '../predicate/isLength.mjs';
82
82
  export { isFunction } from '../predicate/isFunction.mjs';
83
+ export { isJSONObject } from '../predicate/isJSONObject.mjs';
84
+ export { isJSONValue } from '../predicate/isJSONValue.mjs';
85
+ export { isJSONArray } from '../predicate/isJSONArray.mjs';
83
86
  export { isSet } from '../predicate/isSet.mjs';
84
87
  export { delay } from '../promise/delay.mjs';
85
88
  export { withTimeout } from '../promise/withTimeout.mjs';
@@ -20,7 +20,7 @@ function has(object, path) {
20
20
  let current = object;
21
21
  for (let i = 0; i < resolvedPath.length; i++) {
22
22
  const key = resolvedPath[i];
23
- if (current == null || !Object.prototype.hasOwnProperty.call(current, key)) {
23
+ if (current == null || !Object.hasOwn(current, key)) {
24
24
  const isSparseIndex = (Array.isArray(current) || isArguments(current)) && isIndex(key) && key < current.length;
25
25
  if (!isSparseIndex) {
26
26
  return false;
@@ -25,7 +25,7 @@ function pick(obj, ...keysArr) {
25
25
  }
26
26
  for (const key of keys) {
27
27
  const value = get(obj, key);
28
- if (typeof key === 'string' && Object.prototype.hasOwnProperty.call(obj, key)) {
28
+ if (typeof key === 'string' && Object.hasOwn(obj, key)) {
29
29
  result[key] = value;
30
30
  }
31
31
  else {
package/dist/index.d.mts CHANGED
@@ -113,6 +113,9 @@ export { isRegExp } from './predicate/isRegExp.mjs';
113
113
  export { isBoolean } from './predicate/isBoolean.mjs';
114
114
  export { isSymbol } from './predicate/isSymbol.mjs';
115
115
  export { isString } from './predicate/isString.mjs';
116
+ export { isJSONObject } from './predicate/isJSONObject.mjs';
117
+ export { isJSONValue } from './predicate/isJSONValue.mjs';
118
+ export { isJSONArray } from './predicate/isJSONArray.mjs';
116
119
  export { isSet } from './predicate/isSet.mjs';
117
120
  export { isWeakMap } from './predicate/isWeakMap.mjs';
118
121
  export { isWeakSet } from './predicate/isWeakSet.mjs';
package/dist/index.d.ts CHANGED
@@ -113,6 +113,9 @@ export { isRegExp } from './predicate/isRegExp.js';
113
113
  export { isBoolean } from './predicate/isBoolean.js';
114
114
  export { isSymbol } from './predicate/isSymbol.js';
115
115
  export { isString } from './predicate/isString.js';
116
+ export { isJSONObject } from './predicate/isJSONObject.js';
117
+ export { isJSONValue } from './predicate/isJSONValue.js';
118
+ export { isJSONArray } from './predicate/isJSONArray.js';
116
119
  export { isSet } from './predicate/isSet.js';
117
120
  export { isWeakMap } from './predicate/isWeakMap.js';
118
121
  export { isWeakSet } from './predicate/isWeakSet.js';
package/dist/index.js CHANGED
@@ -11,10 +11,10 @@ const range = require('./_chunk/range-BXlMmn.js');
11
11
  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
- const toMerged = require('./_chunk/toMerged-2WPeoI.js');
15
- const isWeakSet = require('./_chunk/isWeakSet-clQklw.js');
14
+ const toMerged = require('./_chunk/toMerged-DD-s3X.js');
15
+ const isWeakSet = require('./_chunk/isWeakSet-DDVaWr.js');
16
16
  const predicate_index = require('./predicate/index.js');
17
- const isPlainObject = require('./_chunk/isPlainObject-BIekvL.js');
17
+ const isPlainObject = require('./_chunk/isPlainObject-DKBeLp.js');
18
18
  const pad = require('./_chunk/pad-Cw2pvt.js');
19
19
  const string_index = require('./string/index.js');
20
20
 
@@ -124,6 +124,9 @@ exports.toMerged = toMerged.toMerged;
124
124
  exports.isDate = isWeakSet.isDate;
125
125
  exports.isEqual = isWeakSet.isEqual;
126
126
  exports.isFunction = isWeakSet.isFunction;
127
+ exports.isJSONArray = isWeakSet.isJSONArray;
128
+ exports.isJSONObject = isWeakSet.isJSONObject;
129
+ exports.isJSONValue = isWeakSet.isJSONValue;
127
130
  exports.isLength = isWeakSet.isLength;
128
131
  exports.isMap = isWeakSet.isMap;
129
132
  exports.isNil = isWeakSet.isNil;
package/dist/index.mjs CHANGED
@@ -113,6 +113,9 @@ export { isRegExp } from './predicate/isRegExp.mjs';
113
113
  export { isBoolean } from './predicate/isBoolean.mjs';
114
114
  export { isSymbol } from './predicate/isSymbol.mjs';
115
115
  export { isString } from './predicate/isString.mjs';
116
+ export { isJSONObject } from './predicate/isJSONObject.mjs';
117
+ export { isJSONValue } from './predicate/isJSONValue.mjs';
118
+ export { isJSONArray } from './predicate/isJSONArray.mjs';
116
119
  export { isSet } from './predicate/isSet.mjs';
117
120
  export { isWeakMap } from './predicate/isWeakMap.mjs';
118
121
  export { isWeakSet } from './predicate/isWeakSet.mjs';
@@ -17,10 +17,10 @@ function cloneDeepImpl(obj, stack = new Map()) {
17
17
  for (let i = 0; i < obj.length; i++) {
18
18
  result[i] = cloneDeepImpl(obj[i], stack);
19
19
  }
20
- if (Object.prototype.hasOwnProperty.call(obj, 'index')) {
20
+ if (Object.hasOwn(obj, 'index')) {
21
21
  result.index = obj.index;
22
22
  }
23
- if (Object.prototype.hasOwnProperty.call(obj, 'input')) {
23
+ if (Object.hasOwn(obj, 'input')) {
24
24
  result.input = obj.input;
25
25
  }
26
26
  return result;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const toMerged = require('../_chunk/toMerged-2WPeoI.js');
5
+ const toMerged = require('../_chunk/toMerged-DD-s3X.js');
6
6
 
7
7
  function omit(obj, keys) {
8
8
  const result = { ...obj };
@@ -17,7 +17,7 @@ function pick(obj, keys) {
17
17
  const result = {};
18
18
  for (let i = 0; i < keys.length; i++) {
19
19
  const key = keys[i];
20
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
20
+ if (Object.hasOwn(obj, key)) {
21
21
  result[key] = obj[key];
22
22
  }
23
23
  }
@@ -2,7 +2,7 @@ function pick(obj, keys) {
2
2
  const result = {};
3
3
  for (let i = 0; i < keys.length; i++) {
4
4
  const key = keys[i];
5
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
5
+ if (Object.hasOwn(obj, key)) {
6
6
  result[key] = obj[key];
7
7
  }
8
8
  }
@@ -15,6 +15,9 @@ export { isRegExp } from './isRegExp.mjs';
15
15
  export { isBoolean } from './isBoolean.mjs';
16
16
  export { isSymbol } from './isSymbol.mjs';
17
17
  export { isString } from './isString.mjs';
18
+ export { isJSONObject } from './isJSONObject.mjs';
19
+ export { isJSONValue } from './isJSONValue.mjs';
20
+ export { isJSONArray } from './isJSONArray.mjs';
18
21
  export { isSet } from './isSet.mjs';
19
22
  export { isWeakMap } from './isWeakMap.mjs';
20
23
  export { isWeakSet } from './isWeakSet.mjs';
@@ -15,6 +15,9 @@ export { isRegExp } from './isRegExp.js';
15
15
  export { isBoolean } from './isBoolean.js';
16
16
  export { isSymbol } from './isSymbol.js';
17
17
  export { isString } from './isString.js';
18
+ export { isJSONObject } from './isJSONObject.js';
19
+ export { isJSONValue } from './isJSONValue.js';
20
+ export { isJSONArray } from './isJSONArray.js';
18
21
  export { isSet } from './isSet.js';
19
22
  export { isWeakMap } from './isWeakMap.js';
20
23
  export { isWeakSet } from './isWeakSet.js';
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-clQklw.js');
6
- const isPlainObject = require('../_chunk/isPlainObject-BIekvL.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-DDVaWr.js');
6
+ const isPlainObject = require('../_chunk/isPlainObject-DKBeLp.js');
7
7
 
8
8
  function isError(value) {
9
9
  return value instanceof Error;
@@ -24,6 +24,9 @@ function isString(value) {
24
24
  exports.isDate = isWeakSet.isDate;
25
25
  exports.isEqual = isWeakSet.isEqual;
26
26
  exports.isFunction = isWeakSet.isFunction;
27
+ exports.isJSONArray = isWeakSet.isJSONArray;
28
+ exports.isJSONObject = isWeakSet.isJSONObject;
29
+ exports.isJSONValue = isWeakSet.isJSONValue;
27
30
  exports.isLength = isWeakSet.isLength;
28
31
  exports.isMap = isWeakSet.isMap;
29
32
  exports.isNil = isWeakSet.isNil;
@@ -15,6 +15,9 @@ export { isRegExp } from './isRegExp.mjs';
15
15
  export { isBoolean } from './isBoolean.mjs';
16
16
  export { isSymbol } from './isSymbol.mjs';
17
17
  export { isString } from './isString.mjs';
18
+ export { isJSONObject } from './isJSONObject.mjs';
19
+ export { isJSONValue } from './isJSONValue.mjs';
20
+ export { isJSONArray } from './isJSONArray.mjs';
18
21
  export { isSet } from './isSet.mjs';
19
22
  export { isWeakMap } from './isWeakMap.mjs';
20
23
  export { isWeakSet } from './isWeakSet.mjs';
@@ -152,7 +152,7 @@ function areObjectsEqual(a, b, stack) {
152
152
  for (let i = 0; i < aKeys.length; i++) {
153
153
  const propKey = aKeys[i];
154
154
  const aProp = a[propKey];
155
- if (!Object.prototype.hasOwnProperty.call(b, propKey)) {
155
+ if (!Object.hasOwn(b, propKey)) {
156
156
  return false;
157
157
  }
158
158
  const bProp = b[propKey];
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON array.
3
+ *
4
+ * A valid JSON array is defined as an array where all items are valid JSON values.
5
+ *
6
+ * @param {unknown} value - The value to check.
7
+ * @returns {value is any[]} - True if the value is a valid JSON array, otherwise false.
8
+ *
9
+ * @example
10
+ * console.log(isJSONArray([1, 2, 3])); // true
11
+ * console.log(isJSONArray(["string", null, true])); // true
12
+ * console.log(isJSONArray([1, 2, () => {}])); // false
13
+ * console.log(isJSONArray("not an array")); // false
14
+ */
15
+ declare function isJSONArray(value: unknown): value is any[];
16
+
17
+ export { isJSONArray };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON array.
3
+ *
4
+ * A valid JSON array is defined as an array where all items are valid JSON values.
5
+ *
6
+ * @param {unknown} value - The value to check.
7
+ * @returns {value is any[]} - True if the value is a valid JSON array, otherwise false.
8
+ *
9
+ * @example
10
+ * console.log(isJSONArray([1, 2, 3])); // true
11
+ * console.log(isJSONArray(["string", null, true])); // true
12
+ * console.log(isJSONArray([1, 2, () => {}])); // false
13
+ * console.log(isJSONArray("not an array")); // false
14
+ */
15
+ declare function isJSONArray(value: unknown): value is any[];
16
+
17
+ export { isJSONArray };
@@ -0,0 +1,10 @@
1
+ import { isJSONValue } from './isJSONValue.mjs';
2
+
3
+ function isJSONArray(value) {
4
+ if (!Array.isArray(value)) {
5
+ return false;
6
+ }
7
+ return value.every(item => isJSONValue(item));
8
+ }
9
+
10
+ export { isJSONArray };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Checks if a value is a JSON object.
3
+ *
4
+ * A valid JSON object is defined as an object with string keys and valid JSON values.
5
+ *
6
+ * @param {unknown} obj The value to check.
7
+ * @returns {obj is Record<string, any>} True if `obj` is a JSON object, false otherwise.
8
+ *
9
+ * @example
10
+ * isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true
11
+ * isJSONObject({ regexp: /test/ }); // false
12
+ * isJSONObject(123); // false
13
+ */
14
+ declare function isJSONObject(obj: unknown): obj is Record<string, any>;
15
+
16
+ export { isJSONObject };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Checks if a value is a JSON object.
3
+ *
4
+ * A valid JSON object is defined as an object with string keys and valid JSON values.
5
+ *
6
+ * @param {unknown} obj The value to check.
7
+ * @returns {obj is Record<string, any>} True if `obj` is a JSON object, false otherwise.
8
+ *
9
+ * @example
10
+ * isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true
11
+ * isJSONObject({ regexp: /test/ }); // false
12
+ * isJSONObject(123); // false
13
+ */
14
+ declare function isJSONObject(obj: unknown): obj is Record<string, any>;
15
+
16
+ export { isJSONObject };
@@ -0,0 +1,22 @@
1
+ import { isJSONValue } from './isJSONValue.mjs';
2
+ import { isPlainObject } from './isPlainObject.mjs';
3
+
4
+ function isJSONObject(obj) {
5
+ if (!isPlainObject(obj)) {
6
+ return false;
7
+ }
8
+ const keys = Reflect.ownKeys(obj);
9
+ for (let i = 0; i < keys.length; i++) {
10
+ const key = keys[i];
11
+ const value = obj[key];
12
+ if (typeof key !== 'string') {
13
+ return false;
14
+ }
15
+ if (!isJSONValue(value)) {
16
+ return false;
17
+ }
18
+ }
19
+ return true;
20
+ }
21
+
22
+ export { isJSONObject };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON value.
3
+ *
4
+ * A valid JSON value can be:
5
+ * - null
6
+ * - a JSON object (an object with string keys and valid JSON values)
7
+ * - a JSON array (an array of valid JSON values)
8
+ * - a string
9
+ * - a number
10
+ * - a boolean
11
+ *
12
+ * @param {unknown} value - The value to check.
13
+ * @returns {boolean} - True if the value is a valid JSON value, otherwise false.
14
+ *
15
+ * @example
16
+ * console.log(isJSONValue(null)); // true
17
+ * console.log(isJSONValue({ key: "value" })); // true
18
+ * console.log(isJSONValue([1, 2, 3])); // true
19
+ * console.log(isJSONValue("Hello")); // true
20
+ * console.log(isJSONValue(42)); // true
21
+ * console.log(isJSONValue(true)); // true
22
+ * console.log(isJSONValue(undefined)); // false
23
+ * console.log(isJSONValue(() => {})); // false
24
+ */
25
+ declare function isJSONValue(value: unknown): value is Record<string, any> | any[] | string | number | boolean | null;
26
+
27
+ export { isJSONValue };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Checks if a given value is a valid JSON value.
3
+ *
4
+ * A valid JSON value can be:
5
+ * - null
6
+ * - a JSON object (an object with string keys and valid JSON values)
7
+ * - a JSON array (an array of valid JSON values)
8
+ * - a string
9
+ * - a number
10
+ * - a boolean
11
+ *
12
+ * @param {unknown} value - The value to check.
13
+ * @returns {boolean} - True if the value is a valid JSON value, otherwise false.
14
+ *
15
+ * @example
16
+ * console.log(isJSONValue(null)); // true
17
+ * console.log(isJSONValue({ key: "value" })); // true
18
+ * console.log(isJSONValue([1, 2, 3])); // true
19
+ * console.log(isJSONValue("Hello")); // true
20
+ * console.log(isJSONValue(42)); // true
21
+ * console.log(isJSONValue(true)); // true
22
+ * console.log(isJSONValue(undefined)); // false
23
+ * console.log(isJSONValue(() => {})); // false
24
+ */
25
+ declare function isJSONValue(value: unknown): value is Record<string, any> | any[] | string | number | boolean | null;
26
+
27
+ export { isJSONValue };
@@ -0,0 +1,20 @@
1
+ import { isJSONArray } from './isJSONArray.mjs';
2
+ import { isJSONObject } from './isJSONObject.mjs';
3
+
4
+ function isJSONValue(value) {
5
+ switch (typeof value) {
6
+ case 'object': {
7
+ return value === null || isJSONArray(value) || isJSONObject(value);
8
+ }
9
+ case 'string':
10
+ case 'number':
11
+ case 'boolean': {
12
+ return true;
13
+ }
14
+ default: {
15
+ return false;
16
+ }
17
+ }
18
+ }
19
+
20
+ export { isJSONValue };
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Checks if a given value is a plain object.
3
3
  *
4
- * @param {object} object - The value to check.
5
- * @returns {boolean} - True if the value is a plain object, otherwise false.
4
+ * @param {object} value - The value to check.
5
+ * @returns {value is Record<PropertyKey, any>} - True if the value is a plain object, otherwise false.
6
6
  *
7
7
  * @example
8
8
  * console.log(isPlainObject({})); // true
@@ -11,6 +11,6 @@
11
11
  * console.log(isPlainObject(Object.create(null))); // true
12
12
  * console.log(Buffer.from('hello, world')); // false
13
13
  */
14
- declare function isPlainObject(object: object): boolean;
14
+ declare function isPlainObject(value: unknown): value is Record<PropertyKey, any>;
15
15
 
16
16
  export { isPlainObject };
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Checks if a given value is a plain object.
3
3
  *
4
- * @param {object} object - The value to check.
5
- * @returns {boolean} - True if the value is a plain object, otherwise false.
4
+ * @param {object} value - The value to check.
5
+ * @returns {value is Record<PropertyKey, any>} - True if the value is a plain object, otherwise false.
6
6
  *
7
7
  * @example
8
8
  * console.log(isPlainObject({})); // true
@@ -11,6 +11,6 @@
11
11
  * console.log(isPlainObject(Object.create(null))); // true
12
12
  * console.log(Buffer.from('hello, world')); // false
13
13
  */
14
- declare function isPlainObject(object: object): boolean;
14
+ declare function isPlainObject(value: unknown): value is Record<PropertyKey, any>;
15
15
 
16
16
  export { isPlainObject };
@@ -1,21 +1,21 @@
1
- function isPlainObject(object) {
2
- if (typeof object !== 'object') {
1
+ function isPlainObject(value) {
2
+ if (typeof value !== 'object') {
3
3
  return false;
4
4
  }
5
- if (object == null) {
5
+ if (value == null) {
6
6
  return false;
7
7
  }
8
- if (Object.getPrototypeOf(object) === null) {
8
+ if (Object.getPrototypeOf(value) === null) {
9
9
  return true;
10
10
  }
11
- if (object.toString() !== '[object Object]') {
11
+ if (value.toString() !== '[object Object]') {
12
12
  return false;
13
13
  }
14
- let proto = object;
14
+ let proto = value;
15
15
  while (Object.getPrototypeOf(proto) !== null) {
16
16
  proto = Object.getPrototypeOf(proto);
17
17
  }
18
- return Object.getPrototypeOf(object) === proto;
18
+ return Object.getPrototypeOf(value) === proto;
19
19
  }
20
20
 
21
21
  export { isPlainObject };
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.22.0-dev.695+a093c732",
4
+ "version": "1.22.0-dev.697+ded56755",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {