firebase-export-value

1.1.1 • Public • Published

firebase-export-value Build Status

Create Firebase export objects like Firebase's snapshot.exportVal

Installing

npm install firebase-export-value

Usage

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.

Package Sidebar

Install

npm i firebase-export-value

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • bendrucker