| Total Complexity | 4 |
| Complexity/F | 4 |
| Lines of Code | 21 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | /** |
||
| 11 | import { fromJS } from 'immutable'; |
||
| 12 | |||
| 13 | export const getUpdatedDataRecord = ( |
||
| 14 | state, stateKey, values = {}, type, operation = 'setIn' |
||
| 15 | ) => { |
||
| 16 | if (operation === 'setIn') { |
||
| 17 | return state[operation]([stateKey], new type(values)); |
||
|
|
|||
| 18 | } |
||
| 19 | |||
| 20 | else if (operation === 'mergeIn') { |
||
| 21 | const p = state.get(stateKey) |
||
| 22 | ? state.get(stateKey) |
||
| 23 | : fromJS({}); |
||
| 24 | |||
| 25 | return state[operation]([stateKey], p.merge(values)); |
||
| 26 | } |
||
| 27 | |||
| 28 | throw new Error('Update operation has not been implemented!'); |
||
| 29 | }; |
||
| 30 | |||
| 31 | export default getUpdatedDataRecord; |
||
| 32 |