# obus

> deep access to object properties

Latest version **6.0.0** (published 2017-01-05) · MIT license · 0 weekly downloads

## Install

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

## 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 | 6.0.0 |
| Published | 2017-01-05 |
| First published | 2014-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Golyshev Dmitrii |
| Maintainers | golyshevd |

## Links

- npm: https://www.npmjs.com/package/obus
- Repository: https://github.com/golyshevd/obus
- Homepage: https://github.com/golyshevd/obus#readme
- Issues: https://github.com/golyshevd/obus/issues
- npm.io page: https://npm.io/package/obus

## Dependencies (2)

- [lru-dict](https://npm.io/package/lru-dict.md) 0.1.1
- [to-single-quotes](https://npm.io/package/to-single-quotes.md) ~2.0.0

## Recent versions

- 6.0.0 (latest) — 2017-01-05
- 5.0.1 — 2015-11-27
- 5.0.0 — 2015-11-27
- 4.0.0 — 2015-11-17
- 3.0.0 — 2015-11-09
- 2.1.4 — 2015-11-06
- 2.1.3 — 2015-11-05
- 2.1.2 — 2015-11-04
- 2.1.1 — 2015-11-04
- 2.1.0 — 2015-11-04
- 2.0.0 — 2015-11-01
- 1.0.2 — 2015-06-11
- 1.0.1 — 2015-06-11
- 1.0.0 — 2014-11-26
- 1.0.0-1 — 2014-11-12
- … 6 more at https://npm.io/package/obus/versions

## README

# obus [![Build Status](https://travis-ci.org/golyshevd/obus.svg)](https://travis-ci.org/golyshevd/obus)

`obus` is deep object accessor

## Usage

```js
var Obus = require('obus');
var obus = new Obus();
obus.set('a.b.c', 42);
```

## API

### `Obus new Obus()`
Creates new `Obus` object

```js
var obus = new Obus();
```

### `* obus.set(String path, * data)`
Puts the given object deep into object according to given path

```js
var obus = new Obus();
obus.set('a.b.c', 42);
obus.valueOf(); // -> {a: {b: {c: 42}}}
```

### `* obus.get(String path[, * defaultValue])`
Returns the value placed deep in object according to given path. Returns the second argument if returning value is `undefined`

```js
var obus = new Obus();
obus.set('a.b.c', 42);
obus.get('a.b'); // -> {c: 42}
obus.get('a.b.c'); // -> 42
obus.get('a.b.c.d'); // -> undefined
obus.get('a.b.c.d', 146); // -> 146
```

### `Boolean obus.del(String path)`
Deletes data from given path. Returns true if the data was deleted else false

```js
var obus = new Obus();
obus.set('a', 42);
obus.del('a'); // -> true
obus.del('a'); // -> false
```

### `Boolean obus.has(String path)`
Checks if any truey (not `undefined`) data placed by the given path

```js
var obus = new Obus();
obus.set('a.b', 42);
obus.has('a.b'); // -> true
obus.has('a'); // -> true
obus.has('a.b.c'); // -> false
```

### `* obus.add(String path, * data)`
Extends existing data with the given value

```js
var obus = new Obus();
obus.set('a.b', 42);
obus.add('a', {c: 42});
obus.valueOf(); // -> {a: {b: 42, c: 42}}
```

## Also
You can use brace accessors if the properties you want is not identifiers.

```js
var obus = new Obus();
obus.set('foo.bar-baz', 42);  // error
// Obus supports string literals
obus.set('foo["bar-baz"]', 42); // done
obus.set("foo['bar-baz']", 42); // done
```

---------
LICENSE [MIT](LICENSE)

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