🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

amend-object

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amend-object

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

2.0.0
latest
Source
npm
Version published
Weekly downloads
17
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 21 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts