chunk_response.js 672 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict'
  2. const assert = require('check-types').assert
  3. const Chunk = require('./chunk')
  4. //
  5. // The ChunkResponse allows for additional data to be sent back with the chunk
  6. // at present there are no extra data to send.
  7. //
  8. function ChunkResponse(chunk) {
  9. assert.instance(chunk, Chunk)
  10. this.chunk = chunk
  11. }
  12. ChunkResponse.prototype.toRaw = function chunkResponseToRaw() {
  13. return {
  14. chunk: this.chunk.toRaw(),
  15. }
  16. }
  17. ChunkResponse.fromRaw = function chunkResponseFromRaw(raw) {
  18. if (!raw) return null
  19. return new ChunkResponse(Chunk.fromRaw(raw.chunk))
  20. }
  21. ChunkResponse.prototype.getChunk = function () {
  22. return this.chunk
  23. }
  24. module.exports = ChunkResponse