fix encoding and rb tree tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import '../../node_modules/utf8/utf8.js'
|
||||
import utf8 from 'utf-8'
|
||||
|
||||
export default class BinaryDecoder {
|
||||
constructor (buffer) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../node_modules/utf8/utf8.js'
|
||||
import utf8 from 'utf-8'
|
||||
|
||||
const bits7 = 0b1111111
|
||||
const bits8 = 0b11111111
|
||||
|
||||
@@ -65,7 +65,7 @@ export function readDeleteSet (y, decoder) {
|
||||
}
|
||||
var pos = 0
|
||||
var d = dv[pos]
|
||||
y.ds.iterate(this, [user, 0], [user, Number.MAX_VALUE], function (n) {
|
||||
y.ds.iterate([user, 0], [user, Number.MAX_VALUE], function (n) {
|
||||
// cases:
|
||||
// 1. d deletes something to the right of n
|
||||
// => go to next n (break)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getStruct } from '../Util/StructReferences.js'
|
||||
import { getStruct } from '../Util/structReferences.js'
|
||||
import BinaryDecoder from '../Binary/Decoder.js'
|
||||
|
||||
class MissingEntry {
|
||||
|
||||
@@ -14,7 +14,7 @@ export function writeStateSet (encoder) {
|
||||
let lenPosition = encoder.pos
|
||||
let len = 0
|
||||
encoder.writeUint32(0)
|
||||
this.ss.iterate(this, null, null, function (n) {
|
||||
this.ss.iterate(null, null, function (n) {
|
||||
encoder.writeVarUint(n.id[0])
|
||||
encoder.writeVarUint(n.clock)
|
||||
len++
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { getStruct } from '../Util/StructReferences.js'
|
||||
import { getStruct } from '../Util/structReferences.js'
|
||||
|
||||
export function stringifyUpdate (decoder, strBuilder) {
|
||||
while (decoder.length !== decoder.pos) {
|
||||
|
||||
@@ -10,7 +10,7 @@ export default class ID {
|
||||
return new ID(this.user, this.clock)
|
||||
}
|
||||
equals (id) {
|
||||
return id !== null && id.user === this.user && id.clock === this.user
|
||||
return id !== null && id.user === this.user && id.clock === this.clock
|
||||
}
|
||||
lessThan (id) {
|
||||
return this.user < id.user || (this.user === id.user && this.clock < id.clock)
|
||||
|
||||
@@ -232,11 +232,11 @@ export default class Tree {
|
||||
findNode (id) {
|
||||
var o = this.root
|
||||
if (o === null) {
|
||||
return false
|
||||
return null
|
||||
} else {
|
||||
while (true) {
|
||||
if (o === null) {
|
||||
return false
|
||||
return null
|
||||
}
|
||||
if (id.lessThan(o.val.id)) {
|
||||
o = o.left
|
||||
@@ -249,9 +249,6 @@ export default class Tree {
|
||||
}
|
||||
}
|
||||
delete (id) {
|
||||
if (id == null || id.constructor !== Array) {
|
||||
throw new Error('id is expected to be an Array!')
|
||||
}
|
||||
var d = this.findNode(id)
|
||||
if (d == null) {
|
||||
// throw new Error('Element does not exist!')
|
||||
|
||||
12
src/Y.js
12
src/Y.js
@@ -1,11 +1,3 @@
|
||||
|
||||
// import debug from 'debug'
|
||||
export function debug (namespace) {
|
||||
return function log (message) {
|
||||
console.log(namespace, message)
|
||||
}
|
||||
}
|
||||
|
||||
import DeleteStore from './Store/DeleteStore.js'
|
||||
import OperationStore from './Store/OperationStore.js'
|
||||
import StateStore from './Store/StateStore.js'
|
||||
@@ -21,6 +13,8 @@ import YMap from './Type/YMap.js'
|
||||
import YText from './Type/YText.js'
|
||||
import YXml from './Type/YXml.js'
|
||||
|
||||
import debug from 'debug'
|
||||
|
||||
export default class Y {
|
||||
constructor (opts) {
|
||||
this.userID = generateUserID()
|
||||
@@ -101,6 +95,8 @@ Y.Map = YMap
|
||||
Y.Text = YText
|
||||
Y.Xml = YXml
|
||||
|
||||
export { default as debug } from 'debug'
|
||||
|
||||
Y.debug = debug
|
||||
debug.formatters.Y = messageToString
|
||||
debug.formatters.y = messageToRoomname
|
||||
|
||||
Reference in New Issue
Block a user