1.0.0 • Published 8 years ago
list-tweaker v1.0.0
list-tweaker
Easily modify items in an array
remove
import { remove } from 'list-tweaker'
const list = [
  { id: 'a' },
  { id: 'b' },
  { id: 'c' },
]
remove(list, { id: 'b' })
// [
//   { id: 'a' },
//   { id: 'c' },
// ]replace
import { replace } from 'list-tweaker'
const list = [
  { id: 'a' },
  { id: 'b' },
  { id: 'c' },
]
replace(list, { id: 'b', suprise: 'clown!' })
// [
//   { id: 'a' },
//   { id: 'b', suprise: 'clown!' },
//   { id: 'c' },
// ]update
import { update } from 'list-tweaker'
const list = [{
  id: 'a',
  oldField: 'Kevin Bacon',
  color: 'green',
}]
update(list, {
  id: 'a',
  newField: 'Kevin Costner',
  color: 'chartreuse',
})
// [{
//   id: 'a',
//   oldField: 'Kevin Bacon',
//   color: 'chartreuse',
//   newField: 'Kevin Costner',
// }]kickstarted by npm-boom
1.0.0
8 years ago