lib/modes.js
function (rawFile, algorithms, opts) {
        return _imageOptim(rawFile, algorithms, function (prev, next) {
            return prev.then(function (res) {
                return res || next(rawFile, _initCompressedFile(rawFile.name, opts._tmpDir))
                    .then(function (compressed) {
                        return _isSmallerAfterCompression(rawFile, compressed, opts);
                    });
                });
            }, new Q(false))
            .then(function (isSmaller) {
                return {
                    name: rawFile.name,
                    isOptimized: !isSmaller,
                    exitCode: 0
                };
            })
            .fail(function (err) {
                return _handleError(err, rawFile);
            });
    }
function (rawFile, algorithms, opts) {
        return _imageOptim(rawFile, algorithms, function (prev, next) {
            return prev.then(function (res) {
                return res || next(rawFile, _initCompressedFile(rawFile.name, opts._tmpDir))
                    .then(function (compressed) {
                        return _isSmallerAfterCompression(rawFile, compressed, opts);
                    });
                });
            }, new Q(false))
            .then(function (isSmaller) {
                return {
                    name: rawFile.name,
                    isOptimized: !isSmaller,
                    exitCode: 0
                };
            })
            .fail(function (err) {
                return _handleError(err, rawFile);
            });
    }
function ( rawFile , algorithms , opts ) { return _imageOptim ( rawFile , algorithms , function ( prev , next ) { return prev . then ( function ( res ) { return res || next ( rawFile , _initCompressedFile ( rawFile . name , opts . _tmpDir ) ) . then ( function ( compressed ) { return _isSmallerAfterCompression ( rawFile , compressed , opts ) ; } ) ; } ) ; } , new Q ( false ) ) . then ( function ( isSmaller ) { return { name : rawFile . name , isOptimized : ! isSmaller , exitCode : 0 } ; } ) . fail ( function ( err ) { return _handleError ( err , rawFile ) ; } ) ; }
Checks whether the given file can be optimized further and return the information about the check
@examples
1. { name: 'file.ext', isOptimized: true, exitCode: 0 }
2. { name: 'file.ext', isOptimized: false, exitCode: 0 }
3. { name: 'file.ext', exitCode: 1 }
4. { name: 'file.ext', exitCode: 2 }
@param {File} rawFile
@param {Function[]} algorithms
@param {Object}   [opts] -> lib/defaults.js
@param {Number}   [opts.tolerance=0]
@param {String[]} [opts.reporters=[]]
@param {String}   [opts._tmpDir=md5]
@returns {Promise * Object}
Checks whether the given file can be optimized further and return the information about the check