Add pure state-merge module with unit tests
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const initialState = Object.freeze({
|
||||
title: '',
|
||||
artist: '',
|
||||
album: '',
|
||||
albumArt: '',
|
||||
isPlaying: false,
|
||||
progress: 0,
|
||||
duration: 0,
|
||||
});
|
||||
|
||||
function mergeState(current, update) {
|
||||
return {
|
||||
title: update.title ?? current.title,
|
||||
artist: update.artist ?? current.artist,
|
||||
album: update.album ?? current.album,
|
||||
albumArt: update.albumArt ?? current.albumArt,
|
||||
isPlaying: update.isPlaying ?? current.isPlaying,
|
||||
progress: update.progress ?? current.progress,
|
||||
duration: update.duration ?? current.duration,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { initialState, mergeState };
|
||||
Reference in New Issue
Block a user