Changeset - 7796bc3e46b1
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-05-29 18:50:48
drewp@bigasterisk.com
cleanup
1 file changed with 2 insertions and 24 deletions:
0 comments (0 inline, 0 general)
light9/web/patch.ts
Show inline comments
 
import * as async from "async";
 
import debug from "debug";
 
import * as N3 from "n3";
 
import { NamedNode, Parser, Quad, Writer } from "n3";
 
import { isEqualWith } from "lodash";
 

	
 
export interface QuadPattern {
 
  subject: N3.Quad_Subject | null;
 
  predicate: N3.Quad_Predicate | null;
 
  object: N3.Quad_Object | null; // literals allowed? needs review. probably 'yes'.
 
  graph: N3.Quad_Graph | null;
 
@@ -128,24 +127,26 @@ export class Patch {
 
        }
 
      }
 
    }
 

	
 
    return this._allSubjsCache;
 
  }
 

	
 
  allPreds(): Set<NamedNode> {
 
    const ret = new Set<NamedNode>();
 
    for (let qq of [this.adds, this.dels]) {
 
      for (let q of Array.from(qq)) {
 
        if (q.predicate.termType == "Variable") throw "unsupported";
 
        ret.add(q.predicate);
 
      }
 
    }
 
    return ret;
 
  }
 
}
 

	
 
// The schema of the json sent from graph server.
 
export interface SyncgraphPatchMessage {
 
  patch: { adds: string; deletes: string };
 
}
 

	
 
export function patchToDeleteEntireGraph(g: N3.Store) {
 
  return new Patch(g.getQuads(null, null, null, null), []);
 
@@ -177,29 +178,6 @@ export function parseJsonPatch(input: Sy
 
    });
 
  };
 

	
 
  // todo: is it faster to run them in series? might be
 
  async.parallel([parseAdds, parseDels], (err: any) => cb(new Patch(dels, adds)));
 
}
 

	
 
// /** @deprecated replace with  p=p.update(p2) */
 
// export function patchUpdate(p1: Patch, p2: Patch): void {
 
//   throw "";
 
// }
 

	
 
// /** @deprecated replace with  p.summary() */
 
// export function patchSizeSummary(patch: Patch) {
 
//   throw "";
 
// }
 

	
 
// /** @deprecated moved to Patch.toJsonPatch */
 
// export function toJsonPatch(jsPatch: Patch, cb: (jsonString: string) => void): void {
 
//   throw "";
 
// }
 
// /** @deprecated moved to Patch.containsAnyPreds */
 
// export function patchContainsPreds(patch: Patch, preds: NamedNode[]): boolean {
 
//   throw "";
 
// }
 
// /** @deprecated moved to Patch.allSubjs */
 
// export function allPatchSubjs(patch: Patch): Set<string> {
 
//   throw "";
 
// }
0 comments (0 inline, 0 general)