# value-to-firebase

> Convert a JS value into its Firebase representation

Latest version **1.1.4** (published 2015-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install value-to-firebase
pnpm add value-to-firebase
yarn add value-to-firebase
bun add value-to-firebase
```

## 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.1.4 |
| Published | 2015-06-18 |
| First published | 2015-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | firebase, value, data |

## Links

- npm: https://www.npmjs.com/package/value-to-firebase
- Repository: https://github.com/bendrucker/value-to-firebase
- Homepage: https://github.com/bendrucker/value-to-firebase#readme
- Issues: https://github.com/bendrucker/value-to-firebase/issues
- npm.io page: https://npm.io/package/value-to-firebase

## Dependencies (3)

- [xtend](https://npm.io/package/xtend.md) ~4.0.0
- [firebase-server-value](https://npm.io/package/firebase-server-value.md) ~1.0.0
- [firebase-validate-key](https://npm.io/package/firebase-validate-key.md) ~2.0.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2015-06-18
- 1.1.3 — 2015-06-18
- 1.1.2 — 2015-05-15
- 1.1.1 — 2015-05-15
- 1.1.0 — 2015-05-15
- 1.0.1 — 2015-04-29
- 1.0.0 — 2015-04-29

## README

# value-to-firebase [![Build Status](https://travis-ci.org/bendrucker/value-to-firebase.svg?branch=master)](https://travis-ci.org/bendrucker/value-to-firebase)

> Convert a JS value into its Firebase representation

## Install

```sh
$ npm install value-to-firebase
```

## Usage

```js
var valueToFirebase = require('value-to-firebase')
valueToFirebase({}) // => null
valueToFirebase(undefined) // throw!
```

## API

#### `valueToFirebase(value)` -> `any`

##### value

*Required*  
Type: `any`

* `undefined` is illegal and triggers an exception
* `Function` is illegal and triggers an exception
* `Date` and `RegExp` are `null`
* `Array` becomes a plain object with numeric keys
* `Object` is:
  * `null` if empty (including an empty `Array`)
  * Parsed as a `ServerValue` by [firebase-server-value](https://github.com/bendrucker/firebase-server-value) where applicable
  * Invalid and triggers an exception if any key is [invalid](https://github.com/bendrucker/firebase-validate-key)
  * Returned as-is otherwise

Other values (e.g. `String` and `Number`) are returned as-is. 

Objects are *not* recursively transformed—only top level keys are evaluated. If you want to recursively transform an object using `valueToFirebase`, use [object-to-firebase](https://github.com/bendrucker/object-to-firebase).

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