How to use the automerge.getMissingDeps function in automerge

To help you get started, we’ve selected a few automerge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bkniffler / debe / src / delta / merge.ts View on Github external
}
      let docOld = undefined;
      const isUpdate = map[id + ''] && map[id + ''].merge;
      if (isUpdate) {
        docOld = Automerge.load(map[id + ''].merge);
        updated.push(id);
      } else {
        docOld = Automerge.init();
      }
      const docInt =
        typeof changes === 'string' ? Automerge.load(changes) : undefined;

      const docNew = docInt
        ? Automerge.merge(docOld, docInt)
        : Automerge.applyChanges(docOld, changes);
      if (Object.keys(Automerge.getMissingDeps(docNew)).length) {
        unsuccessful.push(id);
        return;
      }

      /* if (!history.length) {
      return {
        ...snapshot,
        actor: undefined,
        id,
        merge: Automerge.save(docNew)
      };
    }*/
      const history = Automerge.getHistory(docNew);
      const { change, snapshot } = history[history.length - 1];
      return {
        ...snapshot,
github automerge / hypermerge / HyperMerge.js View on Github external
_loadMissingBlocks (hex) {
    const docId = this.hexToId(hex)

    if (docId !== hex) return

    const deps = Automerge.getMissingDeps(this.find(docId))

    return Promise.all(Object.keys(deps).map(actor => {
      const last = deps[actor] + 1 // last is exclusive

      return this._loadBlocks(docId, actor, last)
    }))
  }
github inkandswitch / pushpin / src / hypermerge / index.js View on Github external
_loadMissingDependencyBlocks(docId) {
    log('_loadMissingDependencyBlocks', docId)

    const doc = this.find(docId)
    const deps = Automerge.getMissingDeps(doc)
    return Promise.all(Object.keys(deps).map((actorId) => {
      const last = deps[actorId] + 1 // last is exclusive
      return this._loadBlocksWithDependencies(docId, actorId, last)
    }))
  }
github automerge / hypermerge / index.js View on Github external
_loadMissingBlocks (actorId) {
    const docId = this.actorToId(actorId)

    if (docId !== actorId) return

    const deps = Automerge.getMissingDeps(this.find(docId))

    return Promise.all(Object.keys(deps).map(actor => {
      const last = deps[actor] + 1 // last is exclusive

      return this._loadBlocks(docId, actor, last)
    }))
  }
github automerge / hypermerge / index.js View on Github external
isMissingDeps (docId) {
    const deps = Automerge.getMissingDeps(this.find(docId))
    return !!Object.keys(deps).length
  }
github automerge / hypermerge / HyperMerge.js View on Github external
isMissingDeps (docId) {
    const deps = Automerge.getMissingDeps(this.find(docId))
    return !!Object.keys(deps).length
  }