1.1.1 • Published 10 years ago
firebase-export-value v1.1.1
firebase-export-value 
Create Firebase export objects like Firebase's
snapshot.exportVal
Installing
npm install firebase-export-valueUsage
var exportValue = require('firebase-export-value')
var priority = 0
var data = {
foo: 'bar',
baz: 'qux'
}
function child (key) {
return [data[key], ++priority]
}
exportValue(data, priority, child)Result:
{
'.priority': 0
foo: {
'.priority': 1,
'.value': 'bar'
},
baz: {
'.priority': 2,
'.value': 'qux'
}
}API
exportValue(data, priority, child) -> any
data
Required
Type: any
The data to transform. Can be a value or an object.
priority
Type: any
Default: null
child
Type: function
Required for data objects. Called with key, value, and object for each key/value pair in the data object and should return an array containing the same arguments passed to exportValue but for the given key in data.
child is used to traverse the object, generating data, priority, and child at each object Node and passing it to exportVal until all nodes are primitive values.