object-to-firebase

1.1.1 • Public • Published

object-to-firebase Build Status

Recursively transform an object to its Firebase representation

Install

$ npm install object-to-firebase

Usage

var objectToFirebase = require('object-to-firebase')
objectToFirebase({
  foo: {
    bar: null
  }
})
// => null

API

objectToFirebase(object) -> object / null

object

Required
Type: object

Traverses an object, converting values with value-to-firebase. The object is copied into its smallest possible Firebase representation, meaning:

  • Empty objects are removed
  • null and values that convert to null are removed
  • These steps are performed recursively

This means the following object become null:

{
  foo: {
    bar: {
      baz: {}
    }
  }
}

And this:

{
  foo: {
    bar: 'hi',
    baz: {
      qux: null
    }
  }
}

Becomes this:

{
  foo: {
    bar: 'hi'
  }
}

Package Sidebar

Install

npm i object-to-firebase

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • bendrucker