New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

upsert

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

upsert

Upsert [![Build Status](https://travis-ci.org/pajtai/upsert.png?branch=master)](https://travis-ci.org/pajtai/upsert) ===

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Upsert Build Status

Takes an array and modifies it by either updating the object matched by the predicate, or inserting a new object:

upsert(array, test, object)

var upsert = require('upsert')

upsert(
    arrayOfPeople,
    function(item) {
        item.name = 'jane';
    },
    {
        degree: 'doctorate'
    });

If the test doesn't match anything in the array, "object" will be pushed onto the array. If the test matches something in the array, then object will be extended onto what was matched.

If there are multiple matches, only the first one is modified.

The array that is passed in is modified, and it is also - for convenience - returned.

To run the tests do, npm install && npm test.

FAQs

Package last updated on 02 Mar 2015

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