# @tangle/overwrite

> a strategy for over-writing transformations

Latest version **3.0.1** (published 2023-03-01) · LGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @tangle/overwrite
pnpm add @tangle/overwrite
yarn add @tangle/overwrite
bun add @tangle/overwrite
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2023-03-01 |
| First published | 2020-10-11 |
| Weekly downloads | 0 |
| License | LGPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mixmix |
| Maintainers | mixmix, chereseeriepa, cpilbrow |
| Keywords | tangle, strategy |

## Links

- npm: https://www.npmjs.com/package/@tangle/overwrite
- Repository: https://gitlab.com/tangle-js/strategies/overwrite
- Issues: https://gitlab.com/tangle-js/strategies/overwrite/issues
- npm.io page: https://npm.io/package/@tangle/overwrite

## Dependencies (2)

- [lodash.isequal](https://npm.io/package/lodash.isequal.md) ^4.5.0
- [is-my-json-valid](https://npm.io/package/is-my-json-valid.md) ^2.20.5

## Recent versions

- 3.0.1 (latest) — 2023-03-01
- 3.0.0 — 2021-12-05
- 2.1.0 — 2021-10-26
- 2.0.2 — 2021-06-15
- 2.0.1 — 2021-02-03
- 2.0.0 — 2021-01-26
- 1.2.0 — 2020-11-01
- 1.1.1 — 2020-10-28
- 1.1.0 — 2020-10-28
- 1.0.0 — 2020-10-11

## README

# @tangle/overwrite

see tests for examples.

## API

### `Overwrite(opts) => overwrite`

opts *Object* (optional) can have properties:
- `identity`
    - define the identity transformation for this strategy
    - default `{}`
- `reifiedIdentity`
    - define with `reify(identity)` resolves to
    - default `null`,
- `valueSchema` *Object*
    - add a JSON-schema to validate the values which are allowed to be passed in
    - default (see code, allows string / object / boolean / number)

### `overwrite.schema`
### `overwrite.isValid`
### `overwrite.identity() => I`
### `overwrite.concat(R, S) => T`
### `overwrite.mapFromInput(input, currentTips) => T`
### `overwrite.mapToOutput(T) => t`

### `overwrite.isConflict(graph, nodeIds, field) => Boolean`

where:
- `graph` is a `@tangle/graph` instance
- `nodeIds` is an Array of nodeIds you're wanting to check for conflict
- `field` *String* is the data field `node.data[field]` you're checking for conflicts

### `overwrite.isValidMerge(graph, mergeNode, field) => Boolean`

where:
- `graph` is a `@tangle/graph` instance
- `mergeNode` is the proposed merge-node
- `field` *String* is the data field `node.data[field]` you're checking for merge validity

### `overwrite.merge(graph, mergeNode, field) => T`

similar to `isValidMerge`, but return a transformation, `T`
If it cannot, an error is thrown!

---

Used with modules such as:
- @tangle/strategy
- ssb-crut

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