README
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 exceptionFunction
is illegal and triggers an exceptionDate
andRegExp
arenull
Array
becomes a plain object with numeric keysObject
is:null
if empty (including an emptyArray
)- 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.