<fim-prefix><fim-middle>r_helper = {}
    , fs = require("fs")
    , child_process = require("child_process")
    , os = require("os")
    , path = require("path");

if(process.platform=="win32"){
    printer_helper = requir<fix-suffix>e('../build/Release/node_printer.node');
}

module.exports.printDirect = printDirect

/*
print raw data. This function is intend to be asynchronous

parameters:
	parameters - Object, parameters objects with the following structure:
		data - String, mandatory, data to printer
		printer - String, mandatory, mane of the printer
		docname - String, optional, name of document showed in printer status
		type - String, optional, only for wind32, data type, one of the RAW, TEXT
		success - Function, optional, callback function
		error - Function, optional, callback function if exists any error
	
	or
	
	data - String, mandatory, data to printer
	printer - String, mandatory, mane of the printer
	docname - String, optional, name of document showed in printer status
	type - String, optional, data type, one of the RAW, TEXT
	success - Function, optional, callback function
	error - Function, optional, callback function if exists any error
*/
function printDirect(parameters){
	var data = parameters
		, printer
		, docname
		, type
		, success
		, error;
	
	if(arguments.length==1){
		//TODO: check parameters type
		//if (typeof parameters )
		data = parameters.data;
		printer = parameters.printer;
		docname = parameters.docname;
		type = parameters.type;
		success = parameters.success;
		error = parameters.error;
	}else{
		printer = arguments[1];
		type = arguments[2];
		docname = arguments[3];
		success = arguments[4];
		error = arguments[5];
	}
	
	if(!success){
		success = function(){};
	}<|endoftext|>