all YArray.tests type fixes
This commit is contained in:
@@ -25,6 +25,9 @@ export class ItemJSON extends AbstractItem {
|
||||
*/
|
||||
constructor (id, left, right, parent, parentSub, content) {
|
||||
super(id, left, right, parent, parentSub)
|
||||
/**
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
this.content = content
|
||||
}
|
||||
/**
|
||||
@@ -56,6 +59,17 @@ export class ItemJSON extends AbstractItem {
|
||||
right.content = this.content.splice(diff)
|
||||
return right
|
||||
}
|
||||
/**
|
||||
* @param {ItemJSON} right
|
||||
* @return {boolean}
|
||||
*/
|
||||
mergeWith (right) {
|
||||
if (right.origin === this && this.right === right) {
|
||||
this.content = this.content.concat(right.content)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
/**
|
||||
* @param {encoding.Encoder} encoder
|
||||
* @param {number} offset
|
||||
@@ -63,8 +77,8 @@ export class ItemJSON extends AbstractItem {
|
||||
write (encoder, offset) {
|
||||
super.write(encoder, offset, structJSONRefNumber)
|
||||
const len = this.content.length
|
||||
encoding.writeVarUint(encoder, len)
|
||||
for (let i = 0; i < len; i++) {
|
||||
encoding.writeVarUint(encoder, len - offset)
|
||||
for (let i = offset; i < len; i++) {
|
||||
const c = this.content[i]
|
||||
encoding.writeVarString(encoder, c === undefined ? 'undefined' : JSON.stringify(c))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user