# nested-or-nothing

> Get a deeply nested value from an object or undefined if an intermediate key is missing

Latest version **0.1.1** (published 2014-03-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install nested-or-nothing
pnpm add nested-or-nothing
yarn add nested-or-nothing
bun add nested-or-nothing
```

## 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.1.1 |
| Published | 2014-03-04 |
| First published | 2014-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Artem Shitov |
| Maintainers | artemshitov |
| Keywords | nested, json, object, maybe |

## Links

- npm: https://www.npmjs.com/package/nested-or-nothing
- Repository: https://github.com/artemshitov/nested-or-nothing
- Issues: https://github.com/artemshitov/nested-or-nothing/issues
- npm.io page: https://npm.io/package/nested-or-nothing

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-03-04
- 0.1.0 — 2014-02-25

## README

# Nested or Nothing

A utility function that helps you find deeply nested values in your objects when you don't know for sure if they are present. If any intermediate key is missing, the function returns `undefined`.

## Installation

```shell
npm install nested-or-nothing
```

## Usage

```js
var non = require('nested-or-nothing');

var object = {
  a: {
    b: {
      c: 1
    }
  }
};

non(object, 'a', 'b');      // returns {c: 1}
non(object, 'a', 'b', 'c'); // returns 1

non(object, 'a', 'd', 'c'); // returns undefined
```

## Caution

Since the function uses strings for keys, your code may break when using static code optimizers like Google Closure Compiler in advanced mode. In such cases it is recommended to use safer patterns:

```js
((object.a || {}).b || {}).c;
// same as:
non(object, 'a', 'b', 'c');
```

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