2023-01-13 12:42:29 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const assert = require('check-types').assert
|
|
|
|
const Chunk = require('./chunk')
|
|
|
|
|
2023-08-22 14:48:04 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
}
|
2023-01-13 12:42:29 +00:00
|
|
|
|
2023-08-22 14:48:04 +00:00
|
|
|
toRaw() {
|
|
|
|
return {
|
|
|
|
chunk: this.chunk.toRaw(),
|
|
|
|
}
|
2023-01-13 12:42:29 +00:00
|
|
|
}
|
|
|
|
|
2023-08-22 14:48:04 +00:00
|
|
|
static fromRaw(raw) {
|
|
|
|
if (!raw) return null
|
2023-01-13 12:42:29 +00:00
|
|
|
|
2023-08-22 14:48:04 +00:00
|
|
|
return new ChunkResponse(Chunk.fromRaw(raw.chunk))
|
|
|
|
}
|
2023-01-13 12:42:29 +00:00
|
|
|
|
2023-08-22 14:48:04 +00:00
|
|
|
getChunk() {
|
|
|
|
return this.chunk
|
|
|
|
}
|
2023-01-13 12:42:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ChunkResponse
|