automerge/rust/edit-trace/baseline.js
Alex Good dd3c6d1303
Move rust workspace into ./rust
After some discussion with PVH I realise that the repo structure in the
last reorg was very rust-centric. In an attempt to put each language on
a level footing move the rust code and project files into ./rust
2022-10-16 19:55:51 +01:00

23 lines
595 B
JavaScript

// Apply the paper editing trace to a regular JavaScript array (using .splice, one char at a time)
const { edits, finalText } = require('./editing-trace')
const start = new Date()
let chars = []
for (let i = 0; i < edits.length; i++) {
let edit = edits[i]
if (i % 10000 === 0) {
console.log(`Processed ${i} edits in ${new Date() - start} ms`)
}
chars.splice(...edit)
}
let _save = JSON.stringify(chars)
const time = new Date() - start
console.log(`Done in ${time} ms`)
if (chars.join('') !== finalText) {
throw new RangeError('ERROR: final text did not match expectation')
}