Personal Dashboard

utils.js 400B

123456789101112131415
  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. _.updateIndex(array, value, _.findIndex(array, predicate))
  9. _.idCheck = id => e => e.id === id
  10. export { Map, _ }