# @nhz.io/ref-node

> Value reference node Class

Latest version **1.0.8** (published 2016-09-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nhz.io/ref-node
pnpm add @nhz.io/ref-node
yarn add @nhz.io/ref-node
bun add @nhz.io/ref-node
```

## 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.8 |
| Published | 2016-09-10 |
| First published | 2016-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ishi Ruy |
| Maintainers | nhz.io |
| Keywords | ref-node, nhz.io |

## Links

- npm: https://www.npmjs.com/package/@nhz.io/ref-node
- Repository: https://github.com/nhz-io/ref-node
- Issues: https://github.com/nhz-io/ref-node/issues
- npm.io page: https://npm.io/package/@nhz.io/ref-node

## Recent versions

- 1.0.8 (latest) — 2016-09-10
- 1.0.7 — 2016-09-10
- 1.0.6 — 2016-09-10
- 1.0.5 — 2016-09-10
- 1.0.4 — 2016-09-09
- 1.0.3 — 2016-09-09
- 1.0.2 — 2016-09-09
- 1.0.1 — 2016-09-09
- 1.0.0 — 2016-09-09

## README

<h1 align="center">@nhz.io/ref-node</h1>

<p align="center">
  <a href="https://npmjs.org/package/@nhz.io/ref-node">
    <img src="https://img.shields.io/npm/v/@nhz.io/ref-node.svg?style=flat"
         alt="NPM Version">
  </a>

  <a href="https://www.bithound.io/github/nhz-io/ref-node">
    <img src="https://www.bithound.io/github/nhz-io/ref-node/badges/score.svg"
         alt="Bithound Status">
  </a>

  <a href="https://github.com/nhz-io/ref-node/blob/master/LICENSE">
    <img src="https://img.shields.io/github/license/nhz-io/ref-node.svg?style=flat"
         alt="License">
  </a>

  <a href="https://npmjs.org/package/@nhz.io/ref-node">
  <img src="http://img.shields.io/npm/dm/@nhz.io/ref-node.svg?style=flat"
  alt="Downloads">
  </a>  
</p>

<h3 align="center">"Value reference node" Class<h2>

## Install
```
npm i -S @nhz.io/ref-node
```

## Class: RefNode
### new RefNode(root, path)
* `root` - `{Array | Object}`
* `path` - `{Array<String | Number>}`

#### Creates a reference node for the root object at the given path.
* With root: `{a: {b: 'foo'}}` and path: `['a', 'b']`, the node will
reference `'foo'` value of the `a.b` Object   

* With root; `{a: b: [null, 'bar']}` and path: `['a', 'b', 1]`, the node
will reference `'bar'` value of the `a.b` Array at index `1`

### Properties

* `root` - Root getter/setter
* `parent` - Parent getter
* `path` -  Path getter/setter
* `key` - Key getter/setter
* `resolves` - Resolves getter

## Example

### Object key reference
```javascript

const RefNode = require('@nhz.io/ref-node')
const root = {a: {b: 'foobar'}}
const node = new RefNode(root, ['a', 'b'])
console.log(node.value) // Prints 'foobar'
node.value = 'barfoo'
console.log(root.a.b) // Prints 'barfoo'
```

### Array element reference
```javascript
const RefNode = require('@nhz.io/ref-node')
const root = {a: {b: [null, 'foobar']}}
const node = new RefNode(root, ['a', 'b', 1])
console.log(node.value) // Prints 'foobar'
node.value = 'barfoo'
console.log(root.a.b[1]) // Prints 'barfoo'
```

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