Personal Dashboard

utils.js 436B

1234567891011121314151617
  1. import * as _ from 'lodash'
  2. Map.prototype.toObj = function() {
  3. return [...this].reduce((o, [k, v]) => (o[k] = v, o), {});
  4. }
  5. _.updateIndex = (array, value, index) =>
  6. [...array.slice(0, index), value, ...array.slice(index + 1)]
  7. _.updateWhere = (array, value, predicate) => {
  8. const index = _.findIndex(array, predicate)
  9. return _.updateIndex(array, value, index)
  10. }
  11. _.idCheck = id => e => e.id === id
  12. export { Map, _ }