# optional-chain-proxy

> Optional chain access implementation in TypeScript. Uses [Proxy API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)

Latest version **0.1.2** (published 2018-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install optional-chain-proxy
pnpm add optional-chain-proxy
yarn add optional-chain-proxy
bun add optional-chain-proxy
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-04-16 |
| First published | 2018-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yayoc |
| Maintainers | yayoc |

## Links

- npm: https://www.npmjs.com/package/optional-chain-proxy
- npm.io page: https://npm.io/package/optional-chain-proxy

## Recent versions

- 0.1.2 (latest) — 2018-04-16
- 0.1.1 — 2018-04-14
- 0.1.0 — 2018-04-14

## README

# optional-chain-proxy [![travis-ci](https://travis-ci.org/yayoc/optional-chain-proxy.svg?branch=master)](https://travis-ci.org/yayoc/optional-chain-proxy)

Optional chain access implementation in TypeScript.  
Uses [Proxy API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)

## Install

```shell
npm install optional-chain-proxy
```

## Usage

```typescript
import { optional } from "optional-chain-proxy";

type User {
  name?: {
    first: string
  }
}
const user: User = getUser(); // { name: null }
const optionalUser = optional(user);
optionalUser.name.first; // undefined, does not throw an exception.
```

## API

`optional-chain-proxy` exports `optional` function.
`optional` function lets a target object or an array and return the object which does not throw an exception even if accessing to null or undefined values.

### `optional`

```typescript
optional<T>(object: T) :: T
```

## License

[MIT](LICENSE)

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