Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@posva/vuefire-core

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@posva/vuefire-core - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

src/rtdb.js

6

package.json
{
"name": "@posva/vuefire-core",
"version": "1.0.3",
"version": "1.1.0",
"description": "Shared code for vue + Firebase apps used by vuefire and vuexfire",

@@ -35,3 +35,3 @@ "author": "Eduardo San Martin Morote <posva13@gmail.com>",

"devDependencies": {
"@posva/vuefire-test-helpers": "^1.0.2",
"@posva/vuefire-test-helpers": "^1.0.3",
"@types/jest": "^23.3.10",

@@ -51,3 +51,3 @@ "babel-preset-env": "^1.7.0",

},
"gitHead": "91e733c8023e21a262429e08ca8ad8b1d055edc2"
"gitHead": "9699b0993f67e91d759bab925ea89611dbb05839"
}

@@ -1,3 +0,11 @@

import { createSnapshot, extractRefs, callOnceWithArg, walkGet, walkSet } from './utils'
import {
createSnapshot,
extractRefs,
callOnceWithArg,
walkGet,
walkSet
} from './utils'
export * from './rtdb'
function unsubscribeAll (subs) {

@@ -12,5 +20,10 @@ for (const sub in subs) {

// updateDataFromDocumentSnapshot which may call subscribeToRefs as well
function subscribeToRefs ({ subs, refs, target, path, data, depth, ops, resolve }, options) {
function subscribeToRefs (
{ subs, refs, target, path, depth, ops, resolve },
options
) {
const refKeys = Object.keys(refs)
const missingKeys = Object.keys(subs).filter(refKey => refKeys.indexOf(refKey) < 0)
const missingKeys = Object.keys(subs).filter(
refKey => refKeys.indexOf(refKey) < 0
)
// unbind keys that are no longer there

@@ -89,3 +102,2 @@ missingKeys.forEach(refKey => {

{
data,
refs,

@@ -141,3 +153,4 @@ subs,

// (https://firebase.google.com/docs/firestore/query-data/listen#view_changes_between_snapshots)
const docChanges = typeof ref.docChanges === 'function' ? ref.docChanges() : ref.docChanges
const docChanges =
typeof ref.docChanges === 'function' ? ref.docChanges() : ref.docChanges

@@ -200,3 +213,6 @@ if (!isResolved && docChanges.length) {

function subscribeToDocument ({ ref, target, path, depth, resolve, ops }, options) {
function subscribeToDocument (
{ ref, target, path, depth, resolve, ops },
options
) {
const subs = Object.create(null)

@@ -241,3 +257,6 @@ const unbind = ref.onSnapshot(doc => {

*/
export function bindDocument ({ vm, key, document, resolve, reject, ops }, options) {
export function bindDocument (
{ vm, key, document, resolve, reject, ops },
options
) {
// TODO warning check if key exists?

@@ -244,0 +263,0 @@ // const boundRefs = Object.create(null)

@@ -130,1 +130,41 @@ /**

}
// Following utils are for RTDB
/**
* Convert firebase RTDB snapshot into a bindable data record.
*
* @param {firebase.database.DataSnapshot} snapshot
* @return {object}
*/
export function createRecordFromRTDBSnapshot (snapshot) {
const value = snapshot.val()
let res
if (isObject(value)) {
res = value
} else {
res = {}
Object.defineProperty(res, '.value', {
value
})
}
Object.defineProperty(res, '.key', {
value: snapshot.key
})
return res
}
/**
* Find the index for an object with given key.
*
* @param {array} array
* @param {string} key
* @return {number}
*/
export function indexForKey (array, key) {
for (let i = 0; i < array.length; i++) {
if (array[i]['.key'] === key) return i
}
return -1
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc