# normaltree

> normalized tree for efficient lookup

Latest version **0.2.1** (published 2017-03-24) · MIT license · 0 weekly downloads

## Install

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

## 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.2.1 |
| Published | 2017-03-24 |
| First published | 2017-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Julian Knodt |
| Maintainers | tomzer0 |

## Links

- npm: https://www.npmjs.com/package/normaltree
- Repository: https://github.com/JulianKnodt/FlatTree
- Homepage: https://github.com/JulianKnodt/FlatTree#readme
- Issues: https://github.com/JulianKnodt/FlatTree/issues
- npm.io page: https://npm.io/package/normaltree

## Recent versions

- 0.2.1 (latest) — 2017-03-24
- 0.1.1 — 2017-03-23
- 0.1.0 — 2017-03-23
- 0.0.9 — 2017-03-22
- 0.0.8 — 2017-03-22

## README

# NormalTree/FlatTree


`npm install normaltree`

```
const FlatTree = require('normaltree');

let sharedStorage = {};
let primaryKey = model => model.id;
//Both of these are optional parameters.
let ft = new FlatTree(sharedStorage, primaryKey);
ft.index("name", model => model.name);
ft.addChild({id: 1, name: "John Doe"});
```

##### More:
```
ft.getByIndexedValue("name", "John Doe"); //[FlatTreeNode]
ft.getByIndexOneOrNone("name", "John Doe"); //FlatTreeNode
ft.get({id: 1}) // FlatTreeNode
ft.get({id: 1}) === ft.getByIndexOneOrNone("name", "John Doe"); // true
ft.getByKey(1); //FlatTreeNode
ft.getByKey(1).addChild({id: 2, name: "Alice Bailey"}); //new FlatTreeNode

ft.getByKey(1).children // [FlatTreeNode Alice]

ft.getByKey(1).delete();
ft.getByKey(1); //undefined

```

> FlatTree is pass by value.

> Cannot Index Null Values

> Built-in uid function might lead to hash collisions

---
### MIT

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