function museAmp(state: AppState = initialState, action: Action): AppState { console.info(action.type); let currentPlaylist = state.playlists[state.chosenPlaylistId]; switch (action.type) { case 'ADD_PLAYLIST': return i.assign({}, state, { playlists: state.playlists.concat({ name: action.name, songIds: [] }) }); case 'ADD_SONG': return i.assign({}, state, { library: state.library.concat(action.song) }); case 'CHOOSE_PLAYLIST': return i.assoc(state, 'chosenPlaylistId', action.id); case 'CHOOSE_SONG': return i.assoc(state, 'chosenSongId', action.id); case 'PLAYLIST_ADD_SONG': return i.assocIn( state, ['playlists', state.chosenPlaylistId, 'songIds'], i.push( state.playlists[state.chosenPlaylistId].songIds, action.id ) ); case 'PLAYLIST_REMOVE_SONG': return i.assocIn( state, ['playlists', state.chosenPlaylistId, 'songIds'], i.filter( el => el !== action.id, state.playlists[state.chosenPlaylistId].songIds ) ); case 'REMOVE_PLAYLIST': return i.assign({}, state, { playlists: state.playlists.filter((el, i) => i !== action.id) }); case 'TOGGLE_SHUFFLE': return i.assocIn(state, ['playbackSettings', 'shuffle'], !state.playbackSettings.shuffle); default: (action: empty); return state; } }
checkbox: memoize((props, eventValue) => { const { model, modelValue } = props; if (isMulti(model)) { const valueWithItem = modelValue || []; const valueWithoutItem = (valueWithItem || []).filter(item => !isEqual(item, eventValue)); const value = (valueWithoutItem.length === valueWithItem.length) ? icepick.push(valueWithItem, eventValue) : valueWithoutItem; return value; } return !modelValue; }),
const obj2 = { c: { d: 2 } }; const result2: (typeof defaults & typeof obj2) = i.merge(result1, obj2); result1 === result2; // true const obj3 = { c: { d: 2 } }; const result3: (typeof defaults & typeof obj3) = i.merge(result1, obj3, function(target, source, key) { return target; }); } // arrays { const a = [1]; const result1: typeof a = i.push(a, 2); // [1, 2]; const result2: typeof a = i.unshift(a, 0); // [0, 1, 2]; const result3: typeof a = i.pop(a); // [0, 1]; const result4: typeof a = i.shift(a); // [1]; } { const coll = i.map(v => v * 2, [1, 2, 3]); // [2, 4, 6] const removeEvens = (arr: number[]) => arr.filter(v => v % 2); const result: typeof coll = removeEvens([1, 2, 3]); // [1, 3] } // chain(coll) - not defined { const coll = {