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