@adobe/spacecat-shared-utils 1.1.0 → 1.2.0
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/functions.js +14 -3
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.2.0](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.1.0...@adobe/spacecat-shared-utils-v1.2.0) (2023-11-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add isArray function ([eeb45a6](https://github.com/adobe-rnd/spacecat-shared/commit/eeb45a6784c6406403d0a59b65ba873a107c654c))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-utils-v1.1.0](https://github.com/adobe-rnd/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.0.1...@adobe/spacecat-shared-utils-v1.1.0) (2023-11-29)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/functions.js
CHANGED
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
const REGEX_ISO_DATE = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/;
|
|
15
15
|
const REGEX_TIME_OFFSET_DATE = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}(Z|[+-]\d{2}:\d{2})/;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Determines if the given parameter is an array.
|
|
19
|
+
*
|
|
20
|
+
* @param {*} value - The value to check.
|
|
21
|
+
* @returns {boolean} True if the parameter is an array, false otherwise.
|
|
22
|
+
*/
|
|
23
|
+
function isArray(value) {
|
|
24
|
+
return Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* Determines case-insensitively if the given value is a boolean or a string
|
|
19
29
|
* representation of a boolean.
|
|
@@ -53,7 +63,7 @@ function isNumber(value) {
|
|
|
53
63
|
* @returns {boolean} True if the parameter is an object, false otherwise.
|
|
54
64
|
*/
|
|
55
65
|
function isObject(value) {
|
|
56
|
-
return !
|
|
66
|
+
return !isArray(value) && value !== null && typeof value === 'object';
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
/**
|
|
@@ -150,14 +160,15 @@ function toBoolean(value) {
|
|
|
150
160
|
* @param {Array} b - The second array to compare.
|
|
151
161
|
* @returns {boolean} True if the arrays are equal, false otherwise.
|
|
152
162
|
*/
|
|
153
|
-
const arrayEquals = (a, b) =>
|
|
154
|
-
&&
|
|
163
|
+
const arrayEquals = (a, b) => isArray(a)
|
|
164
|
+
&& isArray(b)
|
|
155
165
|
&& a.length === b.length
|
|
156
166
|
&& a.every((val, index) => val === b[index]);
|
|
157
167
|
|
|
158
168
|
export {
|
|
159
169
|
arrayEquals,
|
|
160
170
|
hasText,
|
|
171
|
+
isArray,
|
|
161
172
|
isBoolean,
|
|
162
173
|
isInteger,
|
|
163
174
|
isValidDate,
|