overleaf/libraries/overleaf-editor-core/lib/chunk_response.js
Eric Mc Sween d54bcc4aa9 Merge pull request #14418 from overleaf/em-history-lib-es6-classes
Move overleaf-editor-core code to ES6 classes

GitOrigin-RevId: f9b50579aec0cef9d9e6aefcfcb3e380fae4b6f4
2023-08-23 08:05:34 +00:00

33 lines
589 B
JavaScript

'use strict'
const assert = require('check-types').assert
const Chunk = require('./chunk')
/**
* The ChunkResponse allows for additional data to be sent back with the chunk
* at present there are no extra data to send.
*/
class ChunkResponse {
constructor(chunk) {
assert.instance(chunk, Chunk)
this.chunk = chunk
}
toRaw() {
return {
chunk: this.chunk.toRaw(),
}
}
static fromRaw(raw) {
if (!raw) return null
return new ChunkResponse(Chunk.fromRaw(raw.chunk))
}
getChunk() {
return this.chunk
}
}
module.exports = ChunkResponse