# 1tree-factory

> Factory that facilitates creating 1tree instances

Latest version **0.1.15** (published 2017-03-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install 1tree-factory
pnpm add 1tree-factory
yarn add 1tree-factory
bun add 1tree-factory
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.15 |
| Published | 2017-03-09 |
| First published | 2016-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nik Coughlin |
| Maintainers | andybell, nrkn |
| Keywords | 1tree, tree |

## Links

- npm: https://www.npmjs.com/package/1tree-factory
- Repository: https://github.com/mojule/1tree-factory
- Homepage: https://github.com/mojule/1tree-factory#readme
- Issues: https://github.com/mojule/1tree-factory/issues
- npm.io page: https://npm.io/package/1tree-factory

## Dependencies (1)

- [1tree](https://npm.io/package/1tree.md) ^0.4.14

## Recent versions

- 0.1.15 (latest) — 2017-03-09
- 0.1.14 — 2017-02-16
- 0.1.13 — 2017-02-08
- 0.1.12 — 2017-02-07
- 0.1.11 — 2017-01-25
- 0.1.10 — 2017-01-25
- 0.1.9 — 2017-01-25
- 0.1.8 — 2017-01-25
- 0.1.7 — 2017-01-20
- 0.1.6 — 2017-01-20
- 0.1.5 — 2017-01-20
- 0.1.4 — 2017-01-18
- 0.1.3 — 2017-01-17
- 0.1.2 — 2016-12-13
- 0.1.1 — 2016-12-01
- … 1 more at https://npm.io/package/1tree-factory/versions

## README

# 1tree-factory

Basically just a thin facade over 1tree to make the use case of creating a new
1tree instance easier when you have your own adapter/plugins etc.

1tree exports a default tree that's ready to start using provided that you want
to use 1tree's default underlying data structures, and also exposes some methods
for creating trees that use your own adapter and/or plugins.

Most people just want to start using a tree, 1tree's default export assumes
this.

However, if you want to use your own adapter, or use your own plugins but also
use 1tree's base plugins, there's a bit of fiddling around. It's not difficult
but doing it often gets old fast.

This module also inserts the plugins specified *before* 1tree's base plugins -
this is to ensure that the various 1tree plugins that do things like wrap other
plugins or extend them in some way will play nicely with your plugins. If you
want to add your plugins **after** the base plugins have been added, you can
always call the `plugin` method on the tree instance.

## usage

```javascript
/*
  we use the name Mtree (mojule tree) internally but the npm package name was
  taken
*/
const Mtree = require( '1tree-factory' )

/*
 create a tree using the default adapter but with some extra plugins that are
 added before the base plugins
*/
const tree1 = Mtree( plugin1, plugin2, plugin3 )

// same, but array instead of multiple args
const tree2 = Mtree( [ plugin1, plugin2, plugin3 ] )

// same, but with a custom adapter
const tree3 = Mtree( adapter, plugin1, plugin2, plugin3 )

// pass a boolean with true to exclude the base plugins
const tree4 = Mtree( plugin1, plugin2, plugin3, true )
const tree5 = Mtree( adapter, plugin1, plugin2, plugin3, true )

// add plugins after the fact, for example to wrap or extend existing plugins
tree5.plugin( plugin4 )

// same as just using 1tree
const tree6 = Mtree()
```

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