es-toolkit 1.25.1-dev.794 → 1.25.1-dev.797
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/dist/_chunk/{isWeakSet-BuFfzX.js → isWeakSet-D8h8bS.js} +17 -19
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -3
- package/dist/compat/index.d.ts +1 -3
- package/dist/compat/index.js +1 -1
- package/dist/compat/index.mjs +1 -3
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -3
- package/dist/predicate/index.d.mts +1 -3
- package/dist/predicate/index.d.ts +1 -3
- package/dist/predicate/index.js +1 -1
- package/dist/predicate/index.mjs +1 -3
- package/dist/predicate/isJSONValue.d.mts +30 -1
- package/dist/predicate/isJSONValue.d.ts +30 -1
- package/dist/predicate/isJSONValue.mjs +25 -3
- package/package.json +1 -1
- package/dist/predicate/isJSONArray.d.mts +0 -17
- package/dist/predicate/isJSONArray.d.ts +0 -17
- package/dist/predicate/isJSONArray.mjs +0 -10
- package/dist/predicate/isJSONObject.d.mts +0 -16
- package/dist/predicate/isJSONObject.d.ts +0 -16
- package/dist/predicate/isJSONObject.mjs +0 -22
package/dist/compat/index.d.mts
CHANGED
|
@@ -60,9 +60,7 @@ export { isBlob } from '../predicate/isBlob.mjs';
|
|
|
60
60
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
61
61
|
export { isFile } from '../predicate/isFile.mjs';
|
|
62
62
|
export { isFunction } from '../predicate/isFunction.mjs';
|
|
63
|
-
export { isJSONArray } from '../predicate/
|
|
64
|
-
export { isJSONObject } from '../predicate/isJSONObject.mjs';
|
|
65
|
-
export { isJSONValue } from '../predicate/isJSONValue.mjs';
|
|
63
|
+
export { isJSONArray, isJSONObject, isJSONValue } from '../predicate/isJSONValue.mjs';
|
|
66
64
|
export { isLength } from '../predicate/isLength.mjs';
|
|
67
65
|
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
68
66
|
export { isNull } from '../predicate/isNull.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -60,9 +60,7 @@ export { isBlob } from '../predicate/isBlob.js';
|
|
|
60
60
|
export { isEqual } from '../predicate/isEqual.js';
|
|
61
61
|
export { isFile } from '../predicate/isFile.js';
|
|
62
62
|
export { isFunction } from '../predicate/isFunction.js';
|
|
63
|
-
export { isJSONArray } from '../predicate/
|
|
64
|
-
export { isJSONObject } from '../predicate/isJSONObject.js';
|
|
65
|
-
export { isJSONValue } from '../predicate/isJSONValue.js';
|
|
63
|
+
export { isJSONArray, isJSONObject, isJSONValue } from '../predicate/isJSONValue.js';
|
|
66
64
|
export { isLength } from '../predicate/isLength.js';
|
|
67
65
|
export { isNotNil } from '../predicate/isNotNil.js';
|
|
68
66
|
export { isNull } from '../predicate/isNull.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const sumBy = require('../_chunk/sumBy-BkErWJ.js');
|
|
|
10
10
|
const randomInt = require('../_chunk/randomInt-CF7bZK.js');
|
|
11
11
|
const toMerged = require('../_chunk/toMerged-BLnW4M.js');
|
|
12
12
|
const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
|
|
13
|
-
const isWeakSet$1 = require('../_chunk/isWeakSet-
|
|
13
|
+
const isWeakSet$1 = require('../_chunk/isWeakSet-D8h8bS.js');
|
|
14
14
|
const upperFirst = require('../_chunk/upperFirst-BUECmK.js');
|
|
15
15
|
|
|
16
16
|
function castArray(value) {
|
package/dist/compat/index.mjs
CHANGED
|
@@ -63,9 +63,7 @@ export { isEqual } from '../predicate/isEqual.mjs';
|
|
|
63
63
|
export { eq } from './util/eq.mjs';
|
|
64
64
|
export { isFile } from '../predicate/isFile.mjs';
|
|
65
65
|
export { isFunction } from '../predicate/isFunction.mjs';
|
|
66
|
-
export { isJSONArray } from '../predicate/
|
|
67
|
-
export { isJSONObject } from '../predicate/isJSONObject.mjs';
|
|
68
|
-
export { isJSONValue } from '../predicate/isJSONValue.mjs';
|
|
66
|
+
export { isJSONArray, isJSONObject, isJSONValue } from '../predicate/isJSONValue.mjs';
|
|
69
67
|
export { isLength } from '../predicate/isLength.mjs';
|
|
70
68
|
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
71
69
|
export { isNull } from '../predicate/isNull.mjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -107,9 +107,7 @@ export { isEqualWith } from './predicate/isEqualWith.mjs';
|
|
|
107
107
|
export { isError } from './predicate/isError.mjs';
|
|
108
108
|
export { isFile } from './predicate/isFile.mjs';
|
|
109
109
|
export { isFunction } from './predicate/isFunction.mjs';
|
|
110
|
-
export { isJSONArray } from './predicate/
|
|
111
|
-
export { isJSONObject } from './predicate/isJSONObject.mjs';
|
|
112
|
-
export { isJSONValue } from './predicate/isJSONValue.mjs';
|
|
110
|
+
export { isJSONArray, isJSONObject, isJSONValue } from './predicate/isJSONValue.mjs';
|
|
113
111
|
export { isLength } from './predicate/isLength.mjs';
|
|
114
112
|
export { isMap } from './predicate/isMap.mjs';
|
|
115
113
|
export { isNil } from './predicate/isNil.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -107,9 +107,7 @@ export { isEqualWith } from './predicate/isEqualWith.js';
|
|
|
107
107
|
export { isError } from './predicate/isError.js';
|
|
108
108
|
export { isFile } from './predicate/isFile.js';
|
|
109
109
|
export { isFunction } from './predicate/isFunction.js';
|
|
110
|
-
export { isJSONArray } from './predicate/
|
|
111
|
-
export { isJSONObject } from './predicate/isJSONObject.js';
|
|
112
|
-
export { isJSONValue } from './predicate/isJSONValue.js';
|
|
110
|
+
export { isJSONArray, isJSONObject, isJSONValue } from './predicate/isJSONValue.js';
|
|
113
111
|
export { isLength } from './predicate/isLength.js';
|
|
114
112
|
export { isMap } from './predicate/isMap.js';
|
|
115
113
|
export { isNil } from './predicate/isNil.js';
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const randomInt = require('./_chunk/randomInt-CF7bZK.js');
|
|
|
13
13
|
const math_index = require('./math/index.js');
|
|
14
14
|
const toMerged = require('./_chunk/toMerged-BLnW4M.js');
|
|
15
15
|
const object_index = require('./object/index.js');
|
|
16
|
-
const isWeakSet = require('./_chunk/isWeakSet-
|
|
16
|
+
const isWeakSet = require('./_chunk/isWeakSet-D8h8bS.js');
|
|
17
17
|
const predicate_index = require('./predicate/index.js');
|
|
18
18
|
const isPlainObject = require('./_chunk/isPlainObject-octpoD.js');
|
|
19
19
|
const upperFirst = require('./_chunk/upperFirst-BUECmK.js');
|
package/dist/index.mjs
CHANGED
|
@@ -107,9 +107,7 @@ export { isEqualWith } from './predicate/isEqualWith.mjs';
|
|
|
107
107
|
export { isError } from './predicate/isError.mjs';
|
|
108
108
|
export { isFile } from './predicate/isFile.mjs';
|
|
109
109
|
export { isFunction } from './predicate/isFunction.mjs';
|
|
110
|
-
export { isJSONArray } from './predicate/
|
|
111
|
-
export { isJSONObject } from './predicate/isJSONObject.mjs';
|
|
112
|
-
export { isJSONValue } from './predicate/isJSONValue.mjs';
|
|
110
|
+
export { isJSONArray, isJSONObject, isJSONValue } from './predicate/isJSONValue.mjs';
|
|
113
111
|
export { isLength } from './predicate/isLength.mjs';
|
|
114
112
|
export { isMap } from './predicate/isMap.mjs';
|
|
115
113
|
export { isNil } from './predicate/isNil.mjs';
|
|
@@ -7,9 +7,7 @@ export { isEqualWith } from './isEqualWith.mjs';
|
|
|
7
7
|
export { isError } from './isError.mjs';
|
|
8
8
|
export { isFile } from './isFile.mjs';
|
|
9
9
|
export { isFunction } from './isFunction.mjs';
|
|
10
|
-
export { isJSONArray } from './
|
|
11
|
-
export { isJSONObject } from './isJSONObject.mjs';
|
|
12
|
-
export { isJSONValue } from './isJSONValue.mjs';
|
|
10
|
+
export { isJSONArray, isJSONObject, isJSONValue } from './isJSONValue.mjs';
|
|
13
11
|
export { isLength } from './isLength.mjs';
|
|
14
12
|
export { isMap } from './isMap.mjs';
|
|
15
13
|
export { isNil } from './isNil.mjs';
|
|
@@ -7,9 +7,7 @@ export { isEqualWith } from './isEqualWith.js';
|
|
|
7
7
|
export { isError } from './isError.js';
|
|
8
8
|
export { isFile } from './isFile.js';
|
|
9
9
|
export { isFunction } from './isFunction.js';
|
|
10
|
-
export { isJSONArray } from './
|
|
11
|
-
export { isJSONObject } from './isJSONObject.js';
|
|
12
|
-
export { isJSONValue } from './isJSONValue.js';
|
|
10
|
+
export { isJSONArray, isJSONObject, isJSONValue } from './isJSONValue.js';
|
|
13
11
|
export { isLength } from './isLength.js';
|
|
14
12
|
export { isMap } from './isMap.js';
|
|
15
13
|
export { isNil } from './isNil.js';
|
package/dist/predicate/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const isWeakSet = require('../_chunk/isWeakSet-
|
|
5
|
+
const isWeakSet = require('../_chunk/isWeakSet-D8h8bS.js');
|
|
6
6
|
const isPlainObject = require('../_chunk/isPlainObject-octpoD.js');
|
|
7
7
|
|
|
8
8
|
function isBoolean(x) {
|
package/dist/predicate/index.mjs
CHANGED
|
@@ -7,9 +7,7 @@ export { isEqualWith } from './isEqualWith.mjs';
|
|
|
7
7
|
export { isError } from './isError.mjs';
|
|
8
8
|
export { isFile } from './isFile.mjs';
|
|
9
9
|
export { isFunction } from './isFunction.mjs';
|
|
10
|
-
export { isJSONArray } from './
|
|
11
|
-
export { isJSONObject } from './isJSONObject.mjs';
|
|
12
|
-
export { isJSONValue } from './isJSONValue.mjs';
|
|
10
|
+
export { isJSONArray, isJSONObject, isJSONValue } from './isJSONValue.mjs';
|
|
13
11
|
export { isLength } from './isLength.mjs';
|
|
14
12
|
export { isMap } from './isMap.mjs';
|
|
15
13
|
export { isNil } from './isNil.mjs';
|
|
@@ -23,5 +23,34 @@
|
|
|
23
23
|
* console.log(isJSONValue(() => {})); // false
|
|
24
24
|
*/
|
|
25
25
|
declare function isJSONValue(value: unknown): value is Record<string, any> | any[] | string | number | boolean | null;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a given value is a valid JSON array.
|
|
28
|
+
*
|
|
29
|
+
* A valid JSON array is defined as an array where all items are valid JSON values.
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} value - The value to check.
|
|
32
|
+
* @returns {value is any[]} - True if the value is a valid JSON array, otherwise false.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* console.log(isJSONArray([1, 2, 3])); // true
|
|
36
|
+
* console.log(isJSONArray(["string", null, true])); // true
|
|
37
|
+
* console.log(isJSONArray([1, 2, () => {}])); // false
|
|
38
|
+
* console.log(isJSONArray("not an array")); // false
|
|
39
|
+
*/
|
|
40
|
+
declare function isJSONArray(value: unknown): value is any[];
|
|
41
|
+
/**
|
|
42
|
+
* Checks if a value is a JSON object.
|
|
43
|
+
*
|
|
44
|
+
* A valid JSON object is defined as an object with string keys and valid JSON values.
|
|
45
|
+
*
|
|
46
|
+
* @param {unknown} obj The value to check.
|
|
47
|
+
* @returns {obj is Record<string, any>} True if `obj` is a JSON object, false otherwise.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true
|
|
51
|
+
* isJSONObject({ regexp: /test/ }); // false
|
|
52
|
+
* isJSONObject(123); // false
|
|
53
|
+
*/
|
|
54
|
+
declare function isJSONObject(obj: unknown): obj is Record<string, any>;
|
|
26
55
|
|
|
27
|
-
export { isJSONValue };
|
|
56
|
+
export { isJSONArray, isJSONObject, isJSONValue };
|
|
@@ -23,5 +23,34 @@
|
|
|
23
23
|
* console.log(isJSONValue(() => {})); // false
|
|
24
24
|
*/
|
|
25
25
|
declare function isJSONValue(value: unknown): value is Record<string, any> | any[] | string | number | boolean | null;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a given value is a valid JSON array.
|
|
28
|
+
*
|
|
29
|
+
* A valid JSON array is defined as an array where all items are valid JSON values.
|
|
30
|
+
*
|
|
31
|
+
* @param {unknown} value - The value to check.
|
|
32
|
+
* @returns {value is any[]} - True if the value is a valid JSON array, otherwise false.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* console.log(isJSONArray([1, 2, 3])); // true
|
|
36
|
+
* console.log(isJSONArray(["string", null, true])); // true
|
|
37
|
+
* console.log(isJSONArray([1, 2, () => {}])); // false
|
|
38
|
+
* console.log(isJSONArray("not an array")); // false
|
|
39
|
+
*/
|
|
40
|
+
declare function isJSONArray(value: unknown): value is any[];
|
|
41
|
+
/**
|
|
42
|
+
* Checks if a value is a JSON object.
|
|
43
|
+
*
|
|
44
|
+
* A valid JSON object is defined as an object with string keys and valid JSON values.
|
|
45
|
+
*
|
|
46
|
+
* @param {unknown} obj The value to check.
|
|
47
|
+
* @returns {obj is Record<string, any>} True if `obj` is a JSON object, false otherwise.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* isJSONObject({ nested: { boolean: true, array: [1, 2, 3], string: 'test', null: null } }); // true
|
|
51
|
+
* isJSONObject({ regexp: /test/ }); // false
|
|
52
|
+
* isJSONObject(123); // false
|
|
53
|
+
*/
|
|
54
|
+
declare function isJSONObject(obj: unknown): obj is Record<string, any>;
|
|
26
55
|
|
|
27
|
-
export { isJSONValue };
|
|
56
|
+
export { isJSONArray, isJSONObject, isJSONValue };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isJSONObject } from './isJSONObject.mjs';
|
|
1
|
+
import { isPlainObject } from './isPlainObject.mjs';
|
|
3
2
|
|
|
4
3
|
function isJSONValue(value) {
|
|
5
4
|
switch (typeof value) {
|
|
@@ -16,5 +15,28 @@ function isJSONValue(value) {
|
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
}
|
|
18
|
+
function isJSONArray(value) {
|
|
19
|
+
if (!Array.isArray(value)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return value.every(item => isJSONValue(item));
|
|
23
|
+
}
|
|
24
|
+
function isJSONObject(obj) {
|
|
25
|
+
if (!isPlainObject(obj)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const keys = Reflect.ownKeys(obj);
|
|
29
|
+
for (let i = 0; i < keys.length; i++) {
|
|
30
|
+
const key = keys[i];
|
|
31
|
+
const value = obj[key];
|
|
32
|
+
if (typeof key !== 'string') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (!isJSONValue(value)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
19
41
|
|
|
20
|
-
export { isJSONValue };
|
|
42
|
+
export { isJSONArray, isJSONObject, isJSONValue };
|
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.25.1-dev.
|
|
4
|
+
"version": "1.25.1-dev.797+904ca1a2",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|
|
@@ -1,17 +0,0 @@
|
|
|
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 };
|
|
@@ -1,17 +0,0 @@
|
|
|
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 };
|
|
@@ -1,16 +0,0 @@
|
|
|
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 };
|
|
@@ -1,16 +0,0 @@
|
|
|
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 };
|
|
@@ -1,22 +0,0 @@
|
|
|
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 };
|