lib/modes.js
function (rawFile, algorithms, opts) {
        return _imageOptim(rawFile, algorithms, function (prev, next) {
            return prev.then(function (res) {
                return next(rawFile, _initCompressedFile(rawFile.name, opts._tmpDir))
                    .then(function (compressed) {
                        return _minFile(res, compressed);
                    });
                });
            }, new Q(rawFile))
            .then(function (minFile) {
                return {
                    name: rawFile.name,
                    savedBytes: _getSavedBytes(rawFile, minFile),
                    exitCode: exit.SUCCESS
                };
            })
            .fail(function (err) {
                return _handleError(err, rawFile);
            });
    }
function (rawFile, algorithms, opts) {
        return _imageOptim(rawFile, algorithms, function (prev, next) {
            return prev.then(function (res) {
                return next(rawFile, _initCompressedFile(rawFile.name, opts._tmpDir))
                    .then(function (compressed) {
                        return _minFile(res, compressed);
                    });
                });
            }, new Q(rawFile))
            .then(function (minFile) {
                return {
                    name: rawFile.name,
                    savedBytes: _getSavedBytes(rawFile, minFile),
                    exitCode: exit.SUCCESS
                };
            })
            .fail(function (err) {
                return _handleError(err, rawFile);
            });
    }
function ( rawFile , algorithms , opts ) { return _imageOptim ( rawFile , algorithms , function ( prev , next ) { return prev . then ( function ( res ) { return next ( rawFile , _initCompressedFile ( rawFile . name , opts . _tmpDir ) ) . then ( function ( compressed ) { return _minFile ( res , compressed ) ; } ) ; } ) ; } , new Q ( rawFile ) ) . then ( function ( minFile ) { return { name : rawFile . name , savedBytes : _getSavedBytes ( rawFile , minFile ) , exitCode : exit . SUCCESS } ; } ) . fail ( function ( err ) { return _handleError ( err , rawFile ) ; } ) ; }
This callback is provided as a first argument for reduce function
@callback reduceCallback
@param {Promise * File|Boolean} prev
@param {Promise * File|Boolean} next
 
Optimizes the given file and returns the information about the compression
@examples
1. { name: 'file.ext', savedBytes: 12345, exitCode: 0 }
2. { name: 'file.ext', exitCode: 1 }
3. { 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}
This callback is provided as a first argument for reduce function