# index-by

> Index an array of objects

Latest version **0.0.1** (published 2014-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install index-by
pnpm add index-by
yarn add index-by
bun add index-by
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-09-26 |
| First published | 2014-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Thomas Jensen |
| Maintainers | thomas-jensen |
| Keywords | array, index |

## Links

- npm: https://www.npmjs.com/package/index-by
- Repository: https://github.com/srcagency/index-by
- Issues: https://github.com/srcagency/index-by/issues
- npm.io page: https://npm.io/package/index-by

## Dependencies (2)

- [dotty](https://npm.io/package/dotty.md) ^0.0.2
- [pluck-key-values](https://npm.io/package/pluck-key-values.md) ^0.0.1

## Recent versions

- 0.0.1 (latest) — 2014-09-26

## README

# indexBy

Create an object from an array of objects indexed by a chosen key

## Install

```
npm install index-by
```

## Usage

```js
var chickens = [
	{ name: 'Gurli', hunger: 3 },
	{ name: 'Obik', hunger: 1 },
	{ name: 'Lui', hunger: 5 },
];

var indexBy = require('index-by');

indexBy(chickens, 'name');
// { Gurli: .., Obik: .., Lui: .. }

indexBy(chickens, [ 'name', 'hunger' ]);
// { 'Gurli.3': .., 'Obik.1': .., 'Lui.5': .. }

indexBy(chickens, callback);
// index by the return value of: callback(currentValue, index, array)

indexBy.path(list, 'path.to.key');
// index by a deep key
```

All functions take a third argument `map` which is an existing map to
amend

## License

[MIT](http://opensource.org/licenses/MIT) © [src.agency](http://src.agency) / Thomas Jensen

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