import { StructStore, Item, Transaction // eslint-disable-line } from '../internals.js' import * as encoding from 'lib0/encoding.js' import * as decoding from 'lib0/decoding.js' import * as buffer from 'lib0/buffer.js' import * as error from 'lib0/error.js' export class ContentBinary { /** * @param {Uint8Array} content */ constructor (content) { this.content = content } /** * @return {number} */ getLength () { return 1 } /** * @return {Array} */ getContent () { return [this.content] } /** * @return {boolean} */ isCountable () { return true } /** * @return {ContentBinary} */ copy () { return new ContentBinary(this.content) } /** * @param {number} offset * @return {ContentBinary} */ splice (offset) { throw error.methodUnimplemented() } /** * @param {ContentBinary} right * @return {boolean} */ mergeWith (right) { return false } /** * @param {Transaction} transaction * @param {Item} item */ integrate (transaction, item) {} /** * @param {Transaction} transaction */ delete (transaction) {} /** * @param {StructStore} store */ gc (store) {} /** * @param {encoding.Encoder} encoder * @param {number} offset */ write (encoder, offset) { encoding.writeVarUint8Array(encoder, this.content) } /** * @return {number} */ getRef () { return 3 } } /** * @param {decoding.Decoder} decoder * @return {ContentBinary} */ export const readContentBinary = decoder => new ContentBinary(buffer.copyUint8Array(decoding.readVarUint8Array(decoder)))