# maybee

> Safe chaining of object properties and functions using ES2015 Proxy.

Latest version **0.1.4** (published 2016-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install maybee
pnpm add maybee
yarn add maybee
bun add maybee
```

## 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.4 |
| Published | 2016-02-19 |
| First published | 2016-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Adam Timberlake |
| Maintainers | wildhoney |
| Keywords | proxy, error, type error, defined, undefined, null, chaining, es2015, es6 |

## Links

- npm: https://www.npmjs.com/package/maybee
- Repository: https://github.com/Wildhoney/MayBee
- Homepage: https://github.com/Wildhoney/MayBee#readme
- Issues: https://github.com/Wildhoney/MayBee/issues
- npm.io page: https://npm.io/package/maybee

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 0.1.4 (latest) — 2016-02-19
- 0.1.3 — 2016-02-19
- 0.1.2 — 2016-02-17
- 0.1.1 — 2016-02-17

## README

# MayBee

<img src="media/logo.png" width="250" />

>  Safe chaining of object properties and functions using ES2015 Proxy.

![Travis](http://img.shields.io/travis/Wildhoney/MayBee.svg?style=flat-square)
&nbsp;
![npm](http://img.shields.io/npm/v/maybee.svg?style=flat-square)
&nbsp;
![License MIT](http://img.shields.io/badge/License-MIT-lightgrey.svg?style=flat-square)

* **npm:** `npm install maybee --save`

---

## Getting Started

**Note:** Requires [Proxy support](https://kangax.github.io/compat-table/es6/#test-Proxy).

```javascript
import {safeguard, isUndefined, isNull} from 'maybee';

const person = safeguard({ name: 'Adam', age: null });

console.log(person.name); // Adam
console.log(isNull(person.age)) // true
console.log(isUndefined(person.getNames().firstName)) // true
console.log(isUndefined(person.with.a.long.non.existent.property)) // true
```

See [unit tests](https://github.com/Wildhoney/MayBee/blob/master/test/may-bee.test.js) for further examples &mdash; however considering a primitive isn't returned, then you can continue chaining as required &mdash; this is in anticipation of an eventual value, and therefore primitives are returned when they exist.

## Undefined!

Once `MayBee` finds a primitive value in your object, then all of the `Proxy` witchery is stopped from there on in.

For example, given the `person` above, we can extend infinitely on unknown properties/functions, but as soon as a primitive has been reached, then normal JavaScript rules are abided by:

```javascript
// √
console.log(person.with.an.unknown().property.and.a().function.or.two);

// TypeError: person.name.on is undefined √
console.log(person.name.on.a.known().property);
```

This behaviour makes it easier to stick closely with the JavaScript spec &mdash; otherwise `MayBee` would have to introduce a non-standard function for when you wanted the *value* rather than another `Proxy` &mdash; such as `getValue()` &mdash; ugh!

[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)

## Example

![Screenshot](media/screenshot.png)

Try out the [interactive console example on Heroku](http://maybee-app.herokuapp.com/)!

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