amend-object
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Amend Object

Update an object from an iterable of key/value-pairs.

Installation

npm install --save amend-object

Usage

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:

  • items is not an iterable
  • any element in items is not an object (usually an array, but can be object with the keys 0 and 1)
  • any key is not a string, a number, or a symbol

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i amend-object

    Weekly Downloads

    4

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    3.79 kB

    Total Files

    7

    Last publish

    Collaborators

    • linusu