# vpo

> Value/path helper functions for javascript objects

Latest version **2.0.0** (published 2016-01-28) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.0.0 |
| Published | 2016-01-28 |
| First published | 2014-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Luciano Colosio |
| Maintainers | unlucio |
| Keywords | objects, value, path |

## Links

- npm: https://www.npmjs.com/package/vpo
- Repository: https://github.com/unlucio/vpo
- Issues: https://github.com/unlucio/vpo/issues
- npm.io page: https://npm.io/package/vpo

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2016-01-28
- 1.3.0 — 2016-01-28
- 1.2.0 — 2015-12-21
- 1.1.1 — 2015-06-21
- 1.1.0 — 2015-03-09
- 1.0.0 — 2014-11-05
- 0.1.0 — 2014-09-04
- 0.0.0 — 2014-06-05

## README

# VPO

[![Build Status](https://travis-ci.org/unlucio/vpo.svg?branch=master)](https://travis-ci.org/unlucio/vpo)

#### Value/path helper functions for javascript objects

It's a set of simple functions that let you query or set values on your objects by a given string path.

## How to get it:

Either:

```
git clone git://github.com/unlucio/vpo.git
```

or

```
npm install vpo
```

or

```
bower install vpo
```

## Changelog:

v 2.0 - better handling of null/undefined. The default returned value is now `undefined` istead of `null` if none is given.

## Examples:

Given the following dummy object:

```javascript
{
	key1: {
		foo1: {
			bar1: 'bao',
			bar2: 'bao'
		},
		foo2: {
			bar2: 'bao'
		},
		foo3: {
			bar3: 'bao'
		}
	},
	key2: {
		foo1: {
			bar1: 'bao',
			bar2: 'bao'
		},
		foo2: {
			bar2: 'bao'
		},
		foo3: {
			bar3: 'bao'
		}
	}
}
```

#### setting a value:

``` javascript
vpo.set(testObj, 'key1.foo2.bar2', 'resetBao');
```

#### getting a value:

``` javascript
vpo.get(testObj, 'key1.foo2.bar2');
```

#### getting a value specifing a default return value:

``` javascript
vpo.get(testObj, 'key1.foo2.barNoExists', 'default');
```

#### getting a value from a list of possible paths:

``` javascript
vpo.getSome(testObj, ['key5.foo2.bar2', 'key1.foo2.bar2']);
```

#### getting a value from a list of possible paths specifing a default return value:

``` javascript
vpo.getSome(testObj, ['key1.foo2.barNoExists', 'key1.foo12.barNoExists', 'key14.foo2.barNoExists'], 'default');
```

#### getting parts of your objects based on paths:

``` javascript
vpo.pick(testObj, ['key1.foo1.bar2', 'key1.foo4.bar2', 'key2.foo1']);

/**
will yield ==>
{
	key1: {
		foo1: {
			bar2: 'bao'
		}
	},
	key2: {
		foo1: {
			bar1: 'bao',
			bar2: 'bao'
		}
	}
}
*/
```

## I'm not sure who will ever be so "brave" to use it, but I'll leave it in since a dear friend of mine LOVES it :D

~~For convenince you can attach VPO to Object's prototype and have all your objects with 2 new methods:~~

``` javascript
vpo.setOnObjectPrototype();
```

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