@cr_docs_t/dts 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Fugue/FugueList.d.ts +1 -1
- package/dist/Fugue/FugueList.d.ts.map +1 -1
- package/dist/Fugue/FugueTest.js +2 -1
- package/dist/TotalOrder/StringTotalOrder.d.ts +9 -0
- package/dist/TotalOrder/StringTotalOrder.d.ts.map +1 -0
- package/dist/TotalOrder/StringTotalOrder.js +35 -0
- package/dist/TotalOrder/UniquelyDenseTotalOrder.d.ts +26 -0
- package/dist/TotalOrder/UniquelyDenseTotalOrder.d.ts.map +1 -0
- package/dist/TotalOrder/UniquelyDenseTotalOrder.js +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FugueList.d.ts","sourceRoot":"","sources":["../../src/Fugue/FugueList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"FugueList.d.ts","sourceRoot":"","sources":["../../src/Fugue/FugueList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,uBAAuB,MAAM,uCAAuC,CAAC;AAE5E;;GAEG;AACH,cAAM,SAAS,CAAC,CAAC;IACb,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAM;IACzB,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACvC,eAAe,SAAK;gBAER,UAAU,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAIlD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IA+BnC;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM;IASpB,OAAO,IAAI,MAAM;CAepB;AAED,eAAe,SAAS,CAAC"}
|
package/dist/Fugue/FugueTest.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import FugueList from "./FugueList";
|
|
2
|
-
import { randomString
|
|
2
|
+
import { randomString } from "../utils/index";
|
|
3
|
+
import StringTotalOrder from "../TotalOrder/StringTotalOrder";
|
|
3
4
|
const test1 = new FugueList(new StringTotalOrder(randomString(5)));
|
|
4
5
|
const test2 = new FugueList(new StringTotalOrder(randomString(5)));
|
|
5
6
|
const word1 = "SHADOW WIZARD MONEY GANG";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import UniquelyDenseTotalOrder from "./UniquelyDenseTotalOrder";
|
|
2
|
+
export default class StringTotalOrder implements UniquelyDenseTotalOrder<string> {
|
|
3
|
+
readonly replicaID: string;
|
|
4
|
+
private counter;
|
|
5
|
+
compare(a: string, b: string): number;
|
|
6
|
+
constructor(replicaID: string);
|
|
7
|
+
createBetween(a?: string, b?: string): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=StringTotalOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StringTotalOrder.d.ts","sourceRoot":"","sources":["../../src/TotalOrder/StringTotalOrder.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,uBAAuB,CAAC,MAAM,CAAC;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAK;IAEpB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;gBAIzB,SAAS,EAAE,MAAM;IAI7B,aAAa,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CA6BhD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default class StringTotalOrder {
|
|
2
|
+
compare(a, b) {
|
|
3
|
+
return a.localeCompare(b);
|
|
4
|
+
}
|
|
5
|
+
constructor(replicaID) {
|
|
6
|
+
this.counter = 0;
|
|
7
|
+
this.replicaID = replicaID;
|
|
8
|
+
}
|
|
9
|
+
createBetween(a, b) {
|
|
10
|
+
// Create a wholly unique string using a causal dot, i.e. (replicaID, counter)
|
|
11
|
+
const uniqueStr = `${this.replicaID}${this.counter++}`;
|
|
12
|
+
// If node is the first ever position in the document
|
|
13
|
+
if (!a && !b) {
|
|
14
|
+
return uniqueStr + "R";
|
|
15
|
+
}
|
|
16
|
+
// If node is the first position at that index
|
|
17
|
+
if (!a) {
|
|
18
|
+
return b + uniqueStr + "R";
|
|
19
|
+
}
|
|
20
|
+
// If node is the last position at that index
|
|
21
|
+
if (!b) {
|
|
22
|
+
return a + uniqueStr + "R";
|
|
23
|
+
}
|
|
24
|
+
const isAPrefixOfB = b.substring(0, a.length).localeCompare(a);
|
|
25
|
+
// If a is not a prefix of b append a globally unique new string to a and return that +R
|
|
26
|
+
if (!isAPrefixOfB) {
|
|
27
|
+
return a + uniqueStr + "R";
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// If a is a prefix of b replace the R at the end of b with L.
|
|
31
|
+
// Then append a globally unique string to it and return it +R.
|
|
32
|
+
return b.slice(0, -1) + "L" + uniqueStr + "R";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper interface for sorting and creating unique immutable positions,
|
|
3
|
+
* suitable for use in a List CRDT. Taken from mattweidner.com/2022/10/21/basic-list-crdt.html
|
|
4
|
+
*
|
|
5
|
+
* @type P The type of positions. Treated as immutable.
|
|
6
|
+
*/
|
|
7
|
+
export default interface UniquelyDenseTotalOrder<P> {
|
|
8
|
+
/**
|
|
9
|
+
* Usual compare function for sorts: returns negative if a < b in
|
|
10
|
+
* their sort order, positive if a > b.
|
|
11
|
+
*/
|
|
12
|
+
compare(a: P, b: P): number;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a globally unique new position c such that a < c < b.
|
|
15
|
+
*
|
|
16
|
+
* "Globally unique" means that the created position must be distinct
|
|
17
|
+
* from all other created positions, including ones created concurrently
|
|
18
|
+
* by other users.
|
|
19
|
+
*
|
|
20
|
+
* When a is undefined, it is treated as the start of the list, i.e.,
|
|
21
|
+
* this returns c such that c < b. Likewise, undefined b is treated
|
|
22
|
+
* as the end of the list.
|
|
23
|
+
*/
|
|
24
|
+
createBetween(a?: P, b?: P): P;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=UniquelyDenseTotalOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniquelyDenseTotalOrder.d.ts","sourceRoot":"","sources":["../../src/TotalOrder/UniquelyDenseTotalOrder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,uBAAuB,CAAC,CAAC;IAC9C;;;OAGG;IACH,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;IAE5B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import FugueList from "./Fugue/FugueList";
|
|
2
2
|
import CausalTree from "./CausalTree/CausalTree";
|
|
3
|
-
|
|
3
|
+
import UniquelyDenseTotalOrder from "./TotalOrder/UniquelyDenseTotalOrder";
|
|
4
|
+
import StringTotalOrder from "./TotalOrder/StringTotalOrder";
|
|
5
|
+
export { FugueList, CausalTree, UniquelyDenseTotalOrder, StringTotalOrder, };
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,UAAU,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAEH,SAAS,EACT,UAAU,EAEV,uBAAuB,EACvB,gBAAgB,GAEnB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import FugueList from "./Fugue/FugueList";
|
|
2
2
|
import CausalTree from "./CausalTree/CausalTree";
|
|
3
|
-
|
|
3
|
+
import StringTotalOrder from "./TotalOrder/StringTotalOrder";
|
|
4
|
+
export {
|
|
5
|
+
// Data Types
|
|
6
|
+
FugueList, CausalTree, StringTotalOrder,
|
|
7
|
+
// Utilities
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM,CAIxD"}
|