View gist:ba9dd30f8852ca9d455c363c65154075
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/temp $ mkdir a | |
~/temp $ cd a | |
~/temp/a $ git init | |
Initialized empty Git repository in /home/seph/temp/a/.git/ | |
~/temp/a:master ✓ $ cat > foo | |
asdf | |
~/temp/a:master ✓ $ git add foo | |
~/temp/a:master ✗ $ git commit -m 'initial import' | |
[master (root-commit) 7fe725a] initial import |
View main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
use std::fmt::{Debug, Formatter}; | |
use std::hash::Hash; | |
// Wrapper around u16. Using the lowest significant 9 bits to store a 3x3 state. | |
#[derive(Copy, Clone, Eq, PartialEq, Default, Hash)] | |
struct Bits(u16); | |
fn main() { | |
let mut map = HashMap::new(); |
View bench.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read in a patch file and check that the patches all apply correctly. | |
// Run with node --expose-gc (file) using input files from here: | |
// https://github.com/josephg/crdt-benchmarks | |
const fs = require('fs') | |
const assert = require('assert') | |
const zlib = require('zlib') | |
const v8 = require('v8') | |
const Rope = require('jumprope') |
View shelf.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Item = null | string | number | boolean | Item[] | {[k: string]: Item}; | |
// Must match the shape of the data | |
type Version = number | [number, Version[]] | [number, {[k: string]: Version}]; | |
type Path = (string | number)[] | |
interface Doc { | |
data: Item, | |
versions: Version, |
View madscience.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
mod tests{ | |
// *** Mad science *** | |
#[test] | |
fn positional_updates_1() { | |
// This variant leans on ins_del_runs to just use a single stream of insert and delete positions. | |
#[derive(Debug, Eq, PartialEq, Clone, Copy)] | |
struct Run3 { | |
diff: i32, // From previous item |
View test_composition.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const genOp = require('./genOp') | |
// const genOp = require('./genOp2') | |
const {type} = require('ot-text-unicode') | |
// const {type} = require('ot-text-tp2') | |
const assert = require('assert') | |
const genOps = (start, n = 3) => { | |
let ops = [] | |
let state = start |
View bench-automerge.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run with node --expose-gc bench.js ../automerge-paper.json.gz | |
// automerge-paper.json.gz from https://github.com/josephg/crdt-benchmarks | |
// Read in a patch file and check that the patches all apply correctly. | |
const fs = require('fs') | |
const assert = require('assert') | |
const zlib = require('zlib') | |
const automerge = require('automerge') | |
const v8 = require('v8') |
View out.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CACHE = { | |
_root: { | |
text: { | |
elems: [ | |
{ | |
elemId: '2@3cb54fecd444446cbe579bd128017c42', | |
pred: [ '2@3cb54fecd444446cbe579bd128017c42' ], | |
value: 'a' | |
}, | |
{ |
View automerge output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
seq: 4, | |
maxOp: 4, | |
requests: [], | |
clock: { '09828cbcb7e14699b37ad87ffe64b448': 4 }, | |
deps: [], | |
backendState: { | |
state: Map { | |
size: 2, | |
_root: ArrayMapNode { |
View automerge-and-yjs-minimal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from 'assert' | |
import seed from 'seed-random' | |
type Id = [agent: string, seq: number] | |
type Version = Record<string, number> // Last seen seq for each agent. | |
type Algorithm = { | |
integrate: <T>(doc: Doc<T>, newItem: Item<T>) => void | |
ignoreTests?: string[] | |
}// & Record<string, any> |
NewerOlder