# organic-dna-fold

> DNA utility function folding DNA structure with support for array manupulations and node overriding

Latest version **1.0.1** (published 2021-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install organic-dna-fold
pnpm add organic-dna-fold
yarn add organic-dna-fold
bun add organic-dna-fold
```

## 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 | 1.0.1 |
| Published | 2021-12-06 |
| First published | 2014-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Boris Filipov |
| Maintainers | outbounder |

## Links

- npm: https://www.npmjs.com/package/organic-dna-fold
- Repository: https://github.com/node-organic/organic-dna-fold
- Issues: https://github.com/node-organic/organic-dna-fold/issues
- npm.io page: https://npm.io/package/organic-dna-fold

## Recent versions

- 1.0.1 (latest) — 2021-12-06
- 1.0.0 — 2017-10-17
- 0.1.1 — 2014-11-25
- 0.1.0 — 2014-08-26
- 0.0.2 — 2014-06-20
- 0.0.1 — 2014-05-10

## README

# organic-dna-fold

DNA utility function folding DNA structure with support for array manupulations and node overriding

## api and usage

    var fold = require("organic-dna-fold")
    var DNA = require("organic").DNA
    var dna = new DNA({
      "modeA": {
        "property": "new value"
      },
      "property": "value",
      "anotherOne": "value"
    })

    fold(dna, dna.modeA) // fold modeA branch over dna root

    console.log(dna.property) // == "new value"
    console.log(dna.anotherOne) // == "value"

### folding with override instead of merge

    var dna = new DNA({
      "modeA": {
        "~plasma": {
          "property": "value"
        },
        "~array": []
      },
      "plasma": {
        "property": "",
        "anotherOne": ""
      },
      "array": ["a", "b", "c"]
    })

    fold(dna, dna.modeA)

    console.log(dna.anotherOne) // == undefined
    console.log(dna.property) // == "value"

    console.log(dna.array) // == []

### folding and push to array merge

    var dna = new DNA({
      "modeA": {
        "array": [
          {
            "$push": "atEndOfArray"
          }
        ]
      },
      "array": ["0", 1]
    })

    fold(dna, dna.modeA)

    console.log(dna.array) // == ["0", 1, "atEndOfArray"]

### folding and unshift to array merge

    var dna = new DNA({
      "modeA": {
        "array": [
          {
            "$unshift": "atStartOfArray"
          }
        ]
      },
      "array": ["0", 1]
    })

    fold(dna, dna.modeA)

    console.log(dna.array) // == ["atStartOfArray", "0", 1]

### folding and insert to array

    var dna = new DNA({
      "modeA": {
        "array": [
          {
            "$insert": {
              "1": "atMiddleOfArray"
            }
          }
        ]
      },
      "array": ["0", 1]
    })

    fold(dna, dna.modeA)

    console.log(dna.array) // == ["0", "atMiddleOfArray", 1]

### folding and merge array element

    var dna = new DNA({
      "modeA": {
        "array": [
          {
            "$merge": {
              "2": {
                "newProperty": true
              }
            }
          }
        ]
      },
      "array": ["0", 1, { property: "value" }]
    })

    fold(dna, dna.modeA)

    console.log(dna.array) // == ["0", 1, { property:"value", "newProperty": true }]

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