# pick-by-alias

> Pick properties by aliases

Latest version **1.2.0** (published 2017-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install pick-by-alias
pnpm add pick-by-alias
yarn add pick-by-alias
bun add pick-by-alias
```

## 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.2.0 |
| Published | 2017-11-25 |
| First published | 2017-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dima Yv |
| Maintainers | dfcreative |
| Keywords | pick, object |

## Links

- npm: https://www.npmjs.com/package/pick-by-alias
- Repository: https://github.com/dfcreative/pick-by-alias
- Homepage: https://github.com/dfcreative/pick-by-alias#readme
- Issues: https://github.com/dfcreative/pick-by-alias/issues
- npm.io page: https://npm.io/package/pick-by-alias

## Recent versions

- 1.2.0 (latest) — 2017-11-25
- 1.1.2 — 2017-11-03
- 1.1.1 — 2017-10-12
- 1.1.0 — 2017-09-20
- 1.0.0 — 2017-09-17

## README

# pick-by-alias [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges)

Pick object properties by synonyms. Useful to avoid remembering exact option names from user perspective.

[![npm install pick-by-alias](https://nodei.co/npm/pick-by-alias.png?mini=true)](https://npmjs.org/package/pick-by-alias/)

```js
let pick = require('pick-by-alias')

let result = pick({
  positions: [...],
  color: 'rgba(0, 100, 200, .75)',
  viewBox: null,
  extra: 123
}, {
  positions: 'positions points data coordinates',
  color: 'colors color stroke',
  viewport: 'viewport viewBox'
})
```

### `pick(object, properties, keepRest=false)`

Return an object with properties picked by the list or dict with aliases. Aliases are matched in priority order, ie. first matching name is picked. Each alias can be an array or a comma/space-separated string.

```js
// pick by dict
let {a, b} = pick(src, {a: ['a', 'b', 'c'], b: 'd e f'})

// pick by list
let {c, d, e} = pick(src, ['c', 'd', 'e'])

// pick by string
let {f, g} = pick(src, 'f g')
```

`keepRest` defines if not listed object properties should be transfered to resulting object or discarded.

## Related

* [defined](https://www.npmjs.com/package/defined) − get first non-undefined out of a list of values
* [update-diff](https://github.com/dfcreative/update-diff) − update object state by mapping diff.

## License

(c) 2017 Dima Yv. MIT License

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