dist/demo.js
/**
     * Transform the properties of this type to binary and write it to an
     * BinaryEncoder.
     *
     * This is called when this Item is sent to a remote peer.
     *
     * @param {AbstractUpdateEncoder} encoder The encoder to write data to.
     * @param {number} offset
     */
Transform the properties of this type to binary and write it to an
BinaryEncoder.

This is called when this Item is sent to a remote peer.

@param {AbstractUpdateEncoder} encoder The encoder to write data to.
@param {number} offset
Transform the properties of this type to binary and write it to an BinaryEncoder . This is called when this Item is sent to a remote peer . @param { AbstractUpdateEncoder } encoder The encoder to write data to . @param { number } offset
write (encoder, offset) {
      const origin = offset > 0 ? createID(this.id.client, this.id.clock + offset - 1) : this.origin;
      const rightOrigin = this.rightOrigin;
      const parentSub = this.parentSub;
      const info = (this.content.getRef() & BITS5) |
        (origin === null ? 0 : BIT8) | 
        (rightOrigin === null ? 0 : BIT7) | 
        (parentSub === null ? 0 : BIT6); 
      encoder.writeInfo(info);
      if (origin !== null) {
        encoder.writeLeftID(origin);
      }
      if (rightOrigin !== null) {
        encoder.writeRightID(rightOrigin);
      }
      if (origin === null && rightOrigin === null) {
        const parent =  (this.parent);
        const parentItem = parent._item;
        if (parentItem === null) {
          const ykey = findRootTypeKey(parent);
          encoder.writeParentInfo(true); 
          encoder.writeString(ykey);
        } else {
          encoder.writeParentInfo(false); 
          encoder.writeLeftID(parentItem.id);
        }
        if (parentSub !== null) {
          encoder.writeString(parentSub);
        }
      }
      this.content.write(encoder, offset);
    }
write ( encoder , offset ) { const origin = offset > 0 ? createID ( this . id . client , this . id . clock + offset - 1 ) : this . origin ; const rightOrigin = this . rightOrigin ; const parentSub = this . parentSub ; const info = ( this . content . getRef ( ) & BITS5 ) | ( origin === null ? 0 : BIT8 ) | ( rightOrigin === null ? 0 : BIT7 ) | ( parentSub === null ? 0 : BIT6 ) ; encoder . writeInfo ( info ) ; if ( origin !== null ) { encoder . writeLeftID ( origin ) ; } if ( rightOrigin !== null ) { encoder . writeRightID ( rightOrigin ) ; } if ( origin === null && rightOrigin === null ) { const parent = ( this . parent ) ; const parentItem = parent . _item ; if ( parentItem === null ) { const ykey = findRootTypeKey ( parent ) ; encoder . writeParentInfo ( true ) ; encoder . writeString ( ykey ) ; } else { encoder . writeParentInfo ( false ) ; encoder . writeLeftID ( parentItem . id ) ; } if ( parentSub !== null ) { encoder . writeString ( parentSub ) ; } } this . content . write ( encoder , offset ) ; }
Transform the properties of this type to binary and write it to an
 BinaryEncoder.
Transform the properties of this type to binary and write it to an BinaryEncoder .
// origin is defined // right origin is defined // parentSub is non-null /** @type {AbstractType<any>} */ // parent type on y._map // find the correct key // write parentYKey // write parent id