Joeri Exelmans vor 3 Jahren
Ursprung
Commit
b0614e208f

+ 2 - 0
README.md

@@ -6,3 +6,5 @@ Defines:
  * A "DeltaRegistry" that assigns content-based IDs to deltas, and reuses them.
  * A mutable "GraphState" class, for executing deltas.
  * A "Version" class, for graph embedding, branching and merging.
+
+Currently depends on these NodeJS polyfills for browser: 'buffer', 'crypto' and 'stream'. This is only to compute hashes by means of synchronous function call (Web Crypto API only supports async).

+ 2 - 2
src/onion/delta.test.ts

@@ -1,8 +1,8 @@
 import {Delta, TargetNode, TargetValue} from "./delta";
 import {DeltaRegistry} from "./delta_registry";
 
-import {mockUuid,} from "../util/test_helpers";
-import {assert,} from "../util/assert";
+import {mockUuid,} from "./util/test_helpers";
+import {assert,} from "./util/assert";
 
 
 describe("Primitive Delta", () => {

+ 1 - 1
src/onion/delta.ts

@@ -1,6 +1,6 @@
 import {Buffer} from "buffer";
 import {PrimitiveValue, UUID} from "./types";
-import { buffersXOR } from "../util/buffer_xor";
+import { buffersXOR } from "./util/buffer_xor";
 
 type ConflictType = "U/U" | "R/U" | "R*/U" | "U/D" | "D/D";
 

+ 1 - 1
src/onion/delta_registry.ts

@@ -2,7 +2,7 @@ import {Delta, Transaction, findTxDependencies, NodeCreation, NodeDeletion, Edge
 import {PrimitiveValue, UUID} from "./types";
 import {createHash} from "crypto";
 import {Buffer} from "buffer";
-import {buffersXOR} from "../util/buffer_xor";
+import {buffersXOR} from "./util/buffer_xor";
 
 function string2Hash(data: string): Buffer {
   return createHash('sha256')

+ 2 - 2
src/onion/graph_state.test.ts

@@ -1,8 +1,8 @@
 import {GraphState, GraphStateListener, INodeState, IValueState} from "./graph_state";
-import {mockUuid} from "../util/test_helpers";
+import {mockUuid} from "./util/test_helpers";
 import {DeltaRegistry} from "./delta_registry";
 import {findTxDependencies, TargetValue} from "./delta";
-import {assert} from "../util/assert";
+import {assert} from "./util/assert";
 
 class MyGraphStateListener implements GraphStateListener {
   createNode(ns: INodeState) {

src/util/assert.ts → src/onion/util/assert.ts


src/util/buffer_xor.ts → src/onion/util/buffer_xor.ts


src/util/dfs.test.ts → src/onion/util/dfs.test.ts


src/util/dfs.ts → src/onion/util/dfs.ts


src/util/permutations.ts → src/onion/util/permutations.ts


src/util/test_helpers.ts → src/onion/util/test_helpers.ts


+ 2 - 2
src/onion/version.test.ts

@@ -21,12 +21,12 @@ import {DeltaRegistry} from "./delta_registry";
 
 import {
   mockUuid,
-} from "../util/test_helpers";
+} from "./util/test_helpers";
 
 import {
   assert,
   assertThrows,
-} from "../util/assert";
+} from "./util/assert";
 
 describe("Version", () => {
 

+ 3 - 3
src/onion/version.ts

@@ -1,8 +1,8 @@
 import {inspect} from "util"; // NodeJS library
 import { Buffer } from "buffer"; // NodeJS library
-import {findDFS} from "../util/dfs";
-import {permutations} from "../util/permutations";
-import {bufferXOR} from "../util/buffer_xor";
+import {findDFS} from "./util/dfs";
+import {permutations} from "./util/permutations";
+import {bufferXOR} from "./util/buffer_xor";
 import {PrimitiveDelta, Transaction} from "./delta";
 
 // import * as _ from "lodash";

+ 0 - 19
src/util/partial_ordering.ts

@@ -1,19 +0,0 @@
-
-export function visitPartialOrdering<T>(elements: T[], smallerThan: (T) => T[], visitCallback: (T) => void) {
-  const visitable = new Set(elements);
-  const remaining = new Set(elements);
-  while (remaining.size > 0) {
-    let found = false;
-    for (const elem of remaining) {
-      if (smallerThan(elem).every(e => !visitable.has(e) || !remaining.has(e))) {
-        visitCallback(elem);
-        remaining.delete(elem);
-        found = true;
-        break;
-      }
-    }
-    if (!found) {
-      throw new Error("Could not find a smallest element - not a partial ordering?");
-    }
-  }
-}