Concatenate and compress JS files
356123
def compress_js(self, paths, templates=None, **kwargs):
        """"""
        js = self.concatenate(paths)
        if templates:
            js = js + self.compile_templates(templates)

        if not settings.DISABLE_WRAPPER:
            js = settings.JS_WRAPPER % js

        compressor = self.js_compressor
        if compressor:
            js = getattr(compressor(verbose=self.verbose), 'compress_js')(js)

        return js
1157315
function (callback, source, dest)
    {
        compressor.compress(
            // Source can either be a file path or source code 
            source,
            // Options
            {
                charset: 'utf8',
                type: 'js',
                nomunge: true,
                'preserve-semi': true
            },
            // Compressor callback
            function (error, data, extra)
            {
                if (error)
                {
                    grunt.warn(error);
                    return callback();
                }

                if (extra)
                    grunt.log.writeln(extra);

                grunt.file.write(dest, data);
                callback();
            }
        );
    }
928097
function processJs(jsFiles) {
      var mergedJs = mergeFiles(jsFiles).join(' ');
      var script = replaceDemoModuleWithCodepenModule(mergedJs);
      return script;
    }
294062
function srcFiles() {
         return removeDuplicates(configFiles().concat(libFiles()).concat(modelFiles()).concat(srcDataFiles()).concat(codeFiles()));
     }
890804
function append(arrlike /* , items... */) {
    return Array.prototype.slice.call(arrlike, 0).concat(Array.prototype.slice.call(arguments, 1));
}
250391
public static function js_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n// Cannot read JS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."\n\n";
                continue;
            }
            $compressed[] = self::js($content);
        }

        return implode(";\n", $compressed);
    }
597134
def compress_css(self, paths, output_filename, variant=None, **kwargs):
        """"""
        css = self.concatenate_and_rewrite(paths, output_filename, variant)
        compressor = self.css_compressor
        if compressor:
            css = getattr(compressor(verbose=self.verbose), 'compress_css')(css)
        if not variant:
            return css
        elif variant == "datauri":
            return self.with_data_uri(css)
        else:
            raise CompressorError("\"%s\" is not a valid variant" % variant)
1345940
function readAndMergeFiles(files, cb) {
    assert.func(cb);
    if ((typeof (files)) === 'string') {
        files = [ files ];
    }
    assert.arrayOfString(files, 'files');
    var objs = [];
    function end() {
        cb(null, merge.apply(this, objs));
    }
    var i = 0;
    function next() {
        var file = files[i];
        if (!file) {
            end();
            return;
        }

        fs.stat(file, function (statErr, stat) {
            if (statErr && statErr.code === 'ENOENT' && i != 0) {
                ++i;
                next();
                return;
            }
            if (statErr) {
                cb(statErr);
                return;
            }

            readJsonFile(file, function (readErr, s) {
                if (readErr) {
                    cb(readErr);
                    return;
                }
                objs.push(s);
                ++i;
                next();
            });
        });
    }
    next();
}
1265869
function workTextFiles() {
        return indexFiles().concat(srcFiles()).concat(allTestFiles()).concat(otherJsFiles()).concat(otherNonJsFiles()).concat(taskFiles()).concat(cssFiles())
            .concat(toolsShellFiles()).concat(commonJsFiles()).concat(htmlTemplateFiles()).concat(pythonFiles()).concat(textDataFiles());
    }
516950
function append(configure) {
  fs.appendFileSync(configure.dist, JSON.stringify(configure.cacheArray).slice(1, -1));
}
1197384
function append(source) {
            if (s === '') return;
            var index = 0,
                expr = /\n/g,
                s,
                match;
            while (match = expr.exec(source)) {
                s = source.substring(index, match.index+1);
                if (s !== '') out.push('  write(\''+escapestr(s)+'\');\n');
                index = match.index+1;
            }
            s = source.substring(index, source.length);
            if (s !== '') out.push('  write(\''+escapestr(s)+'\');\n');
        }
1016257
function compile (extension, content, options, fn) {
    // allow optional options argument
    if (_.isFunction(options)) {
      fn = options;
      options = {};
    }

    var config = _.clone(compile.configuration)
      , args = flags.slice(0)
      , buffer = ''
      , errors = ''
      , compressor;

    if (compile.configuration.type) {
      config.type = extension;
    }

    // generate the --key value options, both the key and the value should added
    // seperately to the `args` array or the child_process will chocke.
    Object.keys(config).filter(function filter (option) {
      return config[option];
    }).forEach(function format (option) {
      var bool = _.isBoolean(config[option]);

      if (!bool || config[option]) {
        args.push('--' + option);
        if (!bool) args.push(config[option]);
      }
    });

    // apply the configuration
    _.extend(config, options);

    // spawn the shit and set the correct encoding
    compressor = spawn(type, args);
    compressor.stdout.setEncoding('utf8');
    compressor.stderr.setEncoding('utf8');

    /**
     * Buffer up the results so we can concat them once the compression is
     * finished.
     *
     * @param {Buffer} chunk
     * @api private
     */

    compressor.stdout.on('data', function data (chunk) {
      buffer += chunk;
    });

    compressor.stderr.on('data', function data (err) {
      errors += err;
    });

    /**
     * The compressor has finished can we now process the data and see if it was
     * a success.
     *
     * @param {Number} code
     * @api private
     */

    compressor.on('close', function close (code) {
      // invalid states
      if (errors.length) return fn(new Error(errors));
      if (code !== 0) return fn(new Error('process exited with code ' + code));
      if (!buffer.length) return fn(new Error('no data returned ' + type + args));

      // correctly processed the data
      fn(null, buffer);
    });

    // write out the content that needs to be minified
    compressor.stdin.end(content);
  }
1215555
private void compress()
  {
    counter = 1;
    for (Iterator e = values().iterator(); e.hasNext(); ) 
    {
      Selector s = (Selector) e.next();
      s.setUniqueId(counter++);
    }
  }
200884
function includeJsFiles() {
        if (cog.getOption('include_only_external')) {
            return extLibFiles().concat(generatedJsFiles());
        }
        if (cog.getOption('compile_typescript')) {
            return extLibFiles().concat(generatedJsFiles());
        }
        return extLibFiles().concat(srcFiles()).concat(generatedJsFiles());
    }
861760
function( files, options, callback ) {
	if ( !Array.isArray( files ) ) {
		files = [files];
	}
	if ( typeof options === 'function' ) {
		callback = options;
		options = null;
	} else if ( typeof options === 'string' ) {
		options = { msg: options };
	}
	options = options || {};
	addExtraOptions( [ 'quiet', 'depth', 'msg' ], options );
	executeSvn( [ 'commit' ].concat( files ), options, callback );
}
1254058
function addCompressionToFile(filePath, compression) {
        var srcFilePath = filePath.replace(rootFolder, "").replace(compression.fileExtension, "");
        var existingFile = files[srcFilePath];
        if (!existingFile) {
            files[srcFilePath] = { compressions: [compression] };
        } else {
            existingFile.compressions.push(compression);
        }
    }
534694
async function(filename, compress, result) {
  const content = JSON.stringify(result);

  const data = compress ? await gzip(content) : content;
  return await writeFile(filename + (compress ? ".gz" : ""), data);
}