File tree Expand file tree Collapse file tree 4 files changed +24
-15
lines changed
packages/is-shallow-equal Expand file tree Collapse file tree 4 files changed +24
-15
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* Returns true if the two arrays are shallow equal, or false otherwise.
3
3
*
4
- * @param { any[] } a First array to compare.
5
- * @param { any[] } b Second array to compare.
4
+ * @param a First array to compare.
5
+ * @param b Second array to compare.
6
6
*
7
- * @return { boolean } Whether the two arrays are shallow equal.
7
+ * @return Whether the two arrays are shallow equal.
8
8
*/
9
- export default function isShallowEqualArrays ( a , b ) {
9
+ export default function isShallowEqualArrays (
10
+ a : unknown [ ] ,
11
+ b : unknown [ ]
12
+ ) : boolean {
10
13
if ( a === b ) {
11
14
return true ;
12
15
}
Original file line number Diff line number Diff line change @@ -7,20 +7,18 @@ import isShallowEqualArrays from './arrays';
7
7
export { default as isShallowEqualObjects } from './objects' ;
8
8
export { default as isShallowEqualArrays } from './arrays' ;
9
9
10
- /**
11
- * @typedef {Record<string, any> } ComparableObject
12
- */
10
+ export type ComparableObject = Record < string , any > ;
13
11
14
12
/**
15
13
* Returns true if the two arrays or objects are shallow equal, or false
16
14
* otherwise. Also handles primitive values, just in case.
17
15
*
18
- * @param { unknown } a First object or array to compare.
19
- * @param { unknown } b Second object or array to compare.
16
+ * @param a First object or array to compare.
17
+ * @param b Second object or array to compare.
20
18
*
21
- * @return { boolean } Whether the two values are shallow equal.
19
+ * @return Whether the two values are shallow equal.
22
20
*/
23
- export default function isShallowEqual ( a , b ) {
21
+ export default function isShallowEqual ( a : unknown , b : unknown ) : boolean {
24
22
if ( a && b ) {
25
23
if ( a . constructor === Object && b . constructor === Object ) {
26
24
return isShallowEqualObjects ( a , b ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { ComparableObject } from '.' ;
5
+
1
6
/**
2
7
* Returns true if the two objects are shallow equal, or false otherwise.
3
8
*
4
- * @param { import('.').ComparableObject } a First object to compare.
5
- * @param { import('.').ComparableObject } b Second object to compare.
9
+ * @param a First object to compare.
10
+ * @param b Second object to compare.
6
11
*
7
- * @return { boolean } Whether the two objects are shallow equal.
12
+ * @return Whether the two objects are shallow equal.
8
13
*/
9
- export default function isShallowEqualObjects ( a , b ) {
14
+ export default function isShallowEqualObjects (
15
+ a : ComparableObject ,
16
+ b : ComparableObject
17
+ ) : boolean {
10
18
if ( a === b ) {
11
19
return true ;
12
20
}
File renamed without changes.
You can’t perform that action at this time.
0 commit comments