Skip to content

bendrucker/value-to-firebase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

value-to-firebase Build Status Greenkeeper badge

Convert a JS value into its Firebase representation

Install

$ npm install value-to-firebase

Usage

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 where applicable
    • Invalid and triggers an exception if any key is invalid
    • 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.

About

Convert a JS value into its Firebase representation

Resources

License

Stars

Watchers

Forks

Packages

No packages published