2.0.0 • Published 4 years ago
amend-object v2.0.0
Amend Object
Update an object from an iterable of key/value-pairs.
Installation
npm install --save amend-objectUsage
import amendObject from 'amend-object'
const me = {
firstName: 'Linus',
lastName: 'Unnebäck'
}
amendObject(me, [
['firstName', 'Steve'],
['lastName', 'Jobs']
])
console.log(me)
// => { firstName: 'Steve', lastName: 'Jobs' }API
amendObject(target, items) => object
Update object target with items.
items should be an iterable (e.g. an array) where each item is a key/value pair.
If the same key is specified twice, the latter will take precedence.
A TypeError will be thrown in the following conditions:
itemsis not an iterable- any element in
itemsis not an object (usually an array, but can be object with the keys0and1) - any key is not a string, a number, or a symbol