{"size": 967, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "pepoviola/clean-cssify", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "pepoviola/clean-cssify", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "pepoviola/clean-cssify", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.175, "max_line_length": 86, "alphanum_fraction": 0.6514994829}
var through = require( 'through' );
var path = require( 'path' );
var CleanCSS = require( 'clean-css' );

module.exports = function( filePath, opts ) {
	'use strict';
	// Holds data written to the wrapper through stream.
	var data = '';

	/**
	* Module creation entry point. Aggregates all data from the incoming through stream
	* (which will represent the contents of a file) then processes the result to replace
	* local image references that meet maximum size requirements with data URIs.
	*/
	if( filePath !== undefined && [ '.css' ].indexOf( path.extname( filePath ) ) === -1 )
		return through();
	else
		return through( write, end );

	/**
	* Implementation of through interface.
	*/
	function write( buf ) {
		data += buf;
	};

	/**
	* Implementation of through interface.
	*/
	function end() {
		try {
			this.queue( new CleanCSS( opts ).minify( data ).styles );
		} catch( err ) {
			this.emit( 'error', new Error( err ) );
		}

		this.queue( null );
	}
};
