# object-take

> A really small library, almost 150 bytes minified and gzipped, to take value from object using a string for path expression or returns a placeholder if value is undefined or unreachable.

Latest version **0.1.3** (published 2018-09-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install object-take
pnpm add object-take
yarn add object-take
bun add object-take
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2018-09-06 |
| First published | 2018-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Vitor Luiz Cavalcanti |
| Maintainers | vitorluizc |

## Links

- npm: https://www.npmjs.com/package/object-take
- Repository: https://github.com/VitorLuizC/object-take
- Homepage: https://github.com/VitorLuizC/object-take#readme
- Issues: https://github.com/VitorLuizC/object-take/issues
- npm.io page: https://npm.io/package/object-take

## Recent versions

- 0.1.3 (latest) — 2018-09-06
- 0.1.2 — 2018-08-01
- 0.1.1 — 2018-08-01
- 0.1.0 — 2018-08-01

## README

# object-take

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

A really small library, almost 150 bytes minified and gzipped, to take value from object using a string for path expression or returns a placeholder if value is undefined or unreachable.

It's approach is based on [idx](https://github.com/facebookincubator/idx), from Facebook, and a _insight_ from Vue.js meetup where @IgorHalfeld shows a way to get a property using eval. Yeah, eval.

## Install

This module is published under NPM registry, so you can install from any package manager.

```sh
npm install --save object-take

# If you're using Yarn use the command below.
yarn add object-take
```

## Usage

Just import take function and take a value from object using a path expression.

```js
import take from 'object-take';

// ...

const name = take(response, 'data.user.name', 'Unknown');
```

You can use brackets, even on first property.

```js
const title = take(paragraphs, '["data"].children[0].textContent');
```

Also, expressions could be attached to path.

```js
const id = take(response, 'data.keys[0].number.toString(16)');
```

## License

Released under the [MIT License](./LICENSE).

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