"use strict";

var through = require("through");
var fs = require('fs');
var less = require('less');
var path = require("path");

var less_str = '';
var paths = [__dirname]

var options;



var db = require('just-debounce')
var debounced_compile = db(function compile(less_str) {

        var parser = new less.Parser({
            paths: paths,
            syncImport: true
        });

        parser.parse(less_str, function(e, r) { 
            fs.writeFile(options.dest || "./compiled.css", e ? e : r.toCSS(), function(err) {});  
        });    
         
    }, 1000, false);





module.exports = function (opts) {
    options = opts;

    return function (fileName) {

        if (!/\.css$|\.less$/.test(fileName)) {
            return through();
        }

        var buffer = "";

        paths.push( path.dirname(fileName) );

        return through(
            function (chunk) {
                buffer += chunk.toString();
            },
            function () {
                less_str += buffer;
                debounced_compile(less_str)

                this.queue(null);
            }
        );
    }   
};
@@ -838,43 +838,10 @@
 ;%0A%0A 
-       return through(%0A            
+%09%09
 func
@@ -845,16 +845,22 @@
 unction 
+write 
 (chunk) 
@@ -917,19 +917,11 @@
     
-    %7D,%0A    
+%7D%0A%0A
     
@@ -937,17 +937,17 @@
 ion 
+end 
 () %7B%0A
-    
     
@@ -986,20 +986,16 @@
         
- 
-   
 debounce
@@ -1027,20 +1027,16 @@
         
-   
- 
 this.que
@@ -1053,20 +1053,16 @@
         
-    
 %7D%0A      
@@ -1063,16 +1063,41 @@
         
+return through(write, end
 );%0A    %7D

refactor the code to improve readability