# upsert

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

Latest version **0.0.3** (published 2015-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install upsert
pnpm add upsert
yarn add upsert
bun add upsert
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2015-03-02 |
| First published | 2015-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Peter Ajtai |
| Maintainers | pajtai |

## Links

- npm: https://www.npmjs.com/package/upsert
- Repository: https://github.com/pajtai/upsert
- Issues: https://github.com/pajtai/upsert/issues
- npm.io page: https://npm.io/package/upsert

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^3.3.1

## Recent versions

- 0.0.3 (latest) — 2015-03-02
- 0.0.2 — 2015-03-02
- 0.0.1 — 2015-03-02
- 0.0.0 — 2015-03-02

## README

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

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

`upsert(array, test, object)`

```javascript
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`.

---
_Source: https://npm.io/package/upsert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
