Skip to content

Commit 02424b8

Browse files
committed
refactor: move deepComparePlayList to utils
1 parent f295457 commit 02424b8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/utils.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* deep compares two values for the "playlist prop"
3+
*
4+
* @param {string | string[]} lastPlayList
5+
* @param {string | string[]} playList
6+
* @returns true if the two are equal
7+
*/
8+
const deepComparePlayList = (lastPlayList, playList) => {
9+
if (lastPlayList === playList) {
10+
return true;
11+
}
12+
13+
if (Array.isArray(lastPlayList) && Array.isArray(playList)) {
14+
return lastPlayList.join('') === playList.join('');
15+
}
16+
17+
return false;
18+
};
19+
20+
export {deepComparePlayList};

0 commit comments

Comments
 (0)