Skip to content

Commit 7e55f87

Browse files
committed
0.0.29 - [email protected] - set -> update
1 parent 029a218 commit 7e55f87

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

antimatter/antimatter.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ var sequence_crdt = {};
348348

349349
if (fissures) fissures.forEach((f) => (f.t = self.conn_count));
350350

351-
if (versions && (type == "set" || type == "welcome"))
351+
if (versions && (type == "update" || type == "welcome"))
352352
versions = Object.fromEntries(versions.map((v) => [v.version, v]));
353353
if (version) versions = { [version]: true };
354354

@@ -412,7 +412,7 @@ var sequence_crdt = {};
412412
/// {
413413
/// type: 'welcome',
414414
/// versions: [
415-
/// //each version looks like a set message...
415+
/// //each version looks like an update message...
416416
/// ],
417417
/// fissures: [
418418
/// //each fissure looks as it would in a fissure message...
@@ -538,16 +538,16 @@ var sequence_crdt = {};
538538
self.forget_cbs[conn]();
539539
}
540540

541-
/// ## message `set`
541+
/// ## message `update`
542542
/// Sent to alert peers about a change in the document. The change is represented as a version, with a unique id, a set of parent versions (the most recent versions known before adding this version), and an array of patches, where the offsets in the patches do not take into account the application of other patches in the same array.
543543
/// ``` js
544-
/// { type: 'set',
544+
/// { type: 'update',
545545
/// version: 'VERSION_ID',
546546
/// parents: {'PARENT_VERSION_ID': true, ...},
547547
/// patches: [ {range: '.json.path.a.b', content: 42}, ... ],
548548
/// conn: 'CONN_ID' }
549549
/// ```
550-
if (type == "set") {
550+
if (type == "update") {
551551
if (conn == null || !self.T[version]) {
552552
let ps = Object.keys(parents);
553553

@@ -558,19 +558,19 @@ var sequence_crdt = {};
558558

559559
for (let c of Object.keys(self.conns))
560560
if (c != conn)
561-
send({ type: "set", version, parents, patches, ackme, conn: c });
561+
send({ type: "update", version, parents, patches, ackme, conn: c });
562562
}
563563
}
564564

565565
/// ## message `ackme`
566-
/// Sent for pruning purposes, to try and establish whether everyone has seen the most recent versions. Note that a `set` message is treated as a `ackme` message for the version being set.
566+
/// Sent for pruning purposes, to try and establish whether everyone has seen the most recent versions. Note that an `update` message is treated as a `ackme` message for the version in the update.
567567
/// ``` js
568568
/// { type: 'ackme',
569569
/// version: 'ACKME_ID',
570570
/// versions: {'VERSION_ID_A': true, ...},
571571
/// conn: 'CONN_ID' }
572572
/// ```
573-
if (type == "ackme" || type == "set") {
573+
if (type == "ackme" || type == "update") {
574574
if (!Object.keys(versions).every((v) => self.T[v])) return;
575575

576576
if (
@@ -628,7 +628,7 @@ var sequence_crdt = {};
628628
}
629629

630630
/// ## message local `ack`
631-
/// Sent in response to `set`, but not right away; a peer will first send the `set` over all its other connections, and only after they have all responded with a local `ack` – and we didn't see a `fissure` message while waiting – will the peer send a local `ack` over the originating connection.
631+
/// Sent in response to `update`, but not right away; a peer will first send the `update` over all its other connections, and only after they have all responded with a local `ack` – and we didn't see a `fissure` message while waiting – will the peer send a local `ack` over the originating connection.
632632
/// ``` js
633633
/// {type: 'ack', seen: 'local', version: 'VERSION_ID', conn: 'CONN_ID'}
634634
/// ```
@@ -728,7 +728,7 @@ var sequence_crdt = {};
728728

729729
if (
730730
!self.ackme_timeout &&
731-
type != "set" &&
731+
type != "update" &&
732732
type != "ackme" &&
733733
prune(true)
734734
) {
@@ -804,20 +804,20 @@ var sequence_crdt = {};
804804
}
805805
};
806806

807-
/// # antimatter_crdt.set(...patches)
807+
/// # antimatter_crdt.update(...patches)
808808
///
809809
/// Modify this antimatter_crdt object by applying the given patches. Each patch looks like `{range: '.life.meaning', content: 42}`. Calling this method will trigger calling the `send` callback to let our peers know about this change.
810810
///
811811
/// ``` js
812-
/// antimatter_crdt.set({
812+
/// antimatter_crdt.update({
813813
/// range: '.life.meaning',
814814
/// content: 42
815815
/// })
816816
/// ```
817-
self.set = (...patches) => {
817+
self.update = (...patches) => {
818818
var version = `${self.next_seq++}@${self.id}`;
819819
self.receive({
820-
type: "set",
820+
type: "update",
821821
version,
822822
parents: { ...self.current_version },
823823
patches,
@@ -1088,7 +1088,7 @@ var sequence_crdt = {};
10881088

10891089
/// # json_crdt.generate_braid(versions)
10901090
///
1091-
/// Returns an array of `set` messages that each look like this: `{version, parents, patches, sort_keys}`, such that if we pass all these messages to `antimatter_crdt.receive()`, we'll reconstruct the data in this `json_crdt` data-structure, assuming the recipient already has the given `versions` (each version is represented as a key in an object, and each value is `true`).
1091+
/// Returns an array of `update` messages that each look like this: `{version, parents, patches, sort_keys}`, such that if we pass all these messages to `antimatter_crdt.receive()`, we'll reconstruct the data in this `json_crdt` data-structure, assuming the recipient already has the given `versions` (each version is represented as a key in an object, and each value is `true`).
10921092
///
10931093
/// ``` js
10941094
/// json_crdt.generate_braid({
@@ -1107,12 +1107,12 @@ var sequence_crdt = {};
11071107

11081108
return Object.entries(self.version_cache)
11091109
.filter((x) => !is_anc(x[0]))
1110-
.map(([version, set_message]) => {
1110+
.map(([version, update_message]) => {
11111111
return (self.version_cache[version] =
1112-
set_message || generate_set_message(version));
1112+
update_message || generate_update_message(version));
11131113
});
11141114

1115-
function generate_set_message(version) {
1115+
function generate_update_message(version) {
11161116
if (!Object.keys(self.T[version]).length) {
11171117
return {
11181118
version,
@@ -1456,7 +1456,7 @@ var sequence_crdt = {};
14561456
);
14571457
}
14581458
cur = new_cur;
1459-
sequence_crdt.set(prev_S, prev_i, cur, is_anc);
1459+
sequence_crdt.update(prev_S, prev_i, cur, is_anc);
14601460
}
14611461
if (cur.t == "obj") {
14621462
let x = cur.S[key];
@@ -1483,7 +1483,7 @@ var sequence_crdt = {};
14831483
t: "str",
14841484
S: sequence_crdt.create_node(self.root_version, cur),
14851485
};
1486-
sequence_crdt.set(prev_S, prev_i, cur, is_anc);
1486+
sequence_crdt.update(prev_S, prev_i, cur, is_anc);
14871487
} else if (cur.t == "lit") {
14881488
if (!(cur.S instanceof Array)) throw Error("bad");
14891489
cur = {
@@ -1493,7 +1493,7 @@ var sequence_crdt = {};
14931493
cur.S.map((x) => make_lit(x))
14941494
),
14951495
};
1496-
sequence_crdt.set(prev_S, prev_i, cur, is_anc);
1496+
sequence_crdt.update(prev_S, prev_i, cur, is_anc);
14971497
}
14981498
}
14991499
return cur;
@@ -1843,16 +1843,16 @@ var sequence_crdt = {};
18431843
return ret;
18441844
};
18451845

1846-
/// # sequence_crdt.set(root_node, i, v, is_anc)
1846+
/// # sequence_crdt.update(root_node, i, v, is_anc)
18471847
///
18481848
/// Sets the element at the `i`th position (0-based) in the `sequence_crdt` rooted at `root_node` to the value `v`, when only considering versions which result in `true` when passed to `is_anc`.
18491849
///
18501850
/// ``` js
1851-
/// sequence_crdt.set(root_node, 2, 'x', {
1851+
/// sequence_crdt.update(root_node, 2, 'x', {
18521852
/// alice1: true
18531853
/// })
18541854
/// ```
1855-
sequence_crdt.set = (S, i, v, is_anc) => {
1855+
sequence_crdt.update = (S, i, v, is_anc) => {
18561856
var offset = 0;
18571857
sequence_crdt.traverse(S, is_anc ? is_anc : () => true, (node) => {
18581858
if (i - offset < node.elems.length) {

antimatter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@braidjs/antimatter",
3-
"version": "0.0.28",
3+
"version": "0.0.29",
44
"description": "antimatter: a pruning algorithm for CRDTs and other mergeables",
55
"main": "antimatter.js",
66
"scripts": {

0 commit comments

Comments
 (0)