You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					27 lines
				
				648 B
			
		
		
			
		
	
	
					27 lines
				
				648 B
			| 
								 
											3 years ago
										 
									 | 
							
								"use strict";
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var GenericWorker = require("./GenericWorker");
							 | 
						||
| 
								 | 
							
								var utils = require("../utils");
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * A worker which convert chunks to a specified type.
							 | 
						||
| 
								 | 
							
								 * @constructor
							 | 
						||
| 
								 | 
							
								 * @param {String} destType the destination type.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								function ConvertWorker(destType) {
							 | 
						||
| 
								 | 
							
								    GenericWorker.call(this, "ConvertWorker to " + destType);
							 | 
						||
| 
								 | 
							
								    this.destType = destType;
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								utils.inherits(ConvertWorker, GenericWorker);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @see GenericWorker.processChunk
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								ConvertWorker.prototype.processChunk = function (chunk) {
							 | 
						||
| 
								 | 
							
								    this.push({
							 | 
						||
| 
								 | 
							
								        data : utils.transformTo(this.destType, chunk.data),
							 | 
						||
| 
								 | 
							
								        meta : chunk.meta
							 | 
						||
| 
								 | 
							
								    });
							 | 
						||
| 
								 | 
							
								};
							 | 
						||
| 
								 | 
							
								module.exports = ConvertWorker;
							 |