ConvertWorker.js 648 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var GenericWorker = require('./GenericWorker');
  3. var utils = require('../utils');
  4. /**
  5. * A worker which convert chunks to a specified type.
  6. * @constructor
  7. * @param {String} destType the destination type.
  8. */
  9. function ConvertWorker(destType) {
  10. GenericWorker.call(this, "ConvertWorker to " + destType);
  11. this.destType = destType;
  12. }
  13. utils.inherits(ConvertWorker, GenericWorker);
  14. /**
  15. * @see GenericWorker.processChunk
  16. */
  17. ConvertWorker.prototype.processChunk = function (chunk) {
  18. this.push({
  19. data : utils.transformTo(this.destType, chunk.data),
  20. meta : chunk.meta
  21. });
  22. };
  23. module.exports = ConvertWorker;