# underscore-keypath

> Adds Key-Path mechanism extensions for underscore

Latest version **0.9.3** (published 2016-02-12) · EPL-1.0 license · 0 weekly downloads

## Install

```sh
npm install underscore-keypath
pnpm add underscore-keypath
yarn add underscore-keypath
bun add underscore-keypath
```

## Health

**Score 5/100 (F)** — status: abandoned.

Warnings: low downloads; no types; no esm support; has vulnerabilities; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.3 |
| Published | 2016-02-12 |
| First published | 2014-02-07 |
| Weekly downloads | 0 |
| License | EPL-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 1 |
| Install scripts | no |
| Author | Jeeeyul Lee |
| Maintainers | jeeeyul |
| Keywords | underscore, objective-c, keypath |

## Links

- npm: https://www.npmjs.com/package/underscore-keypath
- Repository: https://github.com/jeeeyul/underscore-keypath
- Homepage: https://github.com/jeeeyul/underscore-keypath#readme
- Issues: https://github.com/jeeeyul/underscore-keypath/issues
- npm.io page: https://npm.io/package/underscore-keypath

## Dependencies (1)

- [underscore](https://npm.io/package/underscore.md) *

## 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

- 0.9.3 (latest) — 2016-02-12
- 0.9.2 — 2016-02-02
- 0.9.1 — 2015-08-27
- 0.9.0 — 2015-08-27
- 0.0.22 — 2015-02-05
- 0.0.21 — 2015-01-23
- 0.0.20 — 2015-01-22
- 0.0.19 — 2015-01-22
- 0.0.18 — 2015-01-22
- 0.0.17 — 2015-01-14
- 0.0.15 — 2014-02-24
- 0.0.14 — 2014-02-24
- 0.0.13 — 2014-02-24
- 0.0.12 — 2014-02-12
- 0.0.11 — 2014-02-11
- … 6 more at https://npm.io/package/underscore-keypath/versions

## README

# underscore-keypath

[![Join the chat at https://gitter.im/jeeeyul/underscore-keypath](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jeeeyul/underscore-keypath?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/jeeeyul/underscore-keypath.png?branch=master)](https://travis-ci.org/jeeeyul/underscore-keypath)

key-path mechanism extensions for underscore (mixin).

**underscore-keypath** let you access JavaScript objects and arrays with keypath easily.

```javascript
var foo = {
  bar : {
    name : "Cool!"
  },
  scores : [55, 27, 100, 33]
};

_(foo).valueForKeyPath("bar.name");           // --> "Cool!"
_(foo).setValueForKeyPath("bar.name", "BAR"); // --> sets foo.bar.name as "BAR"
_(foo).valueForKeyPath("scores.@max");        // --> 100
```

## Install
### NodeJS
```bash
$ npm install underscore-keypath
```

```javascript
var _ = require("underscore-keypath");
```

or you may want to use origianl underscore:

```javascript
var _ = require("underscore");
require("underscore-keypath"); // it will extend original underscore
```
in this case, please install "underscore" first.
```bash
$ npm install underscore
$ npm install underscore-keypath
```
Otherwise, underscore-keypath extends separated underscore in sandbox.

### Meteor
```bash
$ meteor add jeeeyul:underscore-keypath
```

### Front-end
```bash
$ bower install underscore-keypath
```
Or just download [underscore-keypath.js](https://github.com/jeeeyul/underscore-keypath/tree/master/lib/underscore-keypath.js) manually.

## Examples
```javascript
var list = [{
  name : "foo",
  info : {
    favoriteColor : "red",
    age : 20
  }
},{
  name : "bar",
  info : {
    favoriteColor : "green",
    age : 17
  }
},{
  name : "zar",
  info : {
    favoriteColor : "red",
    age : 34
  }
}];

_(list).pluckByKeyPath("info.age");           // --> [20, 17, 34]
_(list).sortByKeyPath("info.age");            // --> [{name:"bar", ..}, {name:"foo", ..}, {name:"zar", ..}]
_(list).groupByKeyPath("info.favoriteColor"); // --> {red:2, green:1}

```

See [API Document](https://github.com/jeeeyul/underscore-keypath/wiki/API)

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