all files / src/structure/immutable/ index.js

100% Statements 15/15
100% Branches 6/6
100% Functions 6/6
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                             
import { Map, Iterable, fromJS } from 'immutable'
import toPath from 'lodash.topath'
import deleteWithPath from './deleteWithPath'
 
const structure = {
  empty: Map(),
  getIn: (state, field) => state.getIn(toPath(field)),
  setIn: (state, field, value) => state.setIn(toPath(field), value),
  deleteIn: (state, field) => state.deleteIn(toPath(field)),
  deleteWithPath,
  fromJS: jsValue => fromJS(jsValue, (key, value) =>
    Iterable.isIndexed(value) ? value.toList() : value.toMap())
}
 
export default structure