list-tweaker
v1.0.0
Published
Easily modify items in an array
Downloads
6
Maintainers
Readme
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