vorto.js
function vorto() {
    var length = arguments.length;
    var format, options, callback;

    if (typeof arguments[length-1] !== 'function') {
        throw new Error('The last argument must be a callback function: function(err, version){...}');
    } else {
        callback = arguments[length-1];
    }

    if (length === 1) {
        format = '%h';
        options = DEFAULTS;

    } else if (length === 2) {
        if (typeof arguments[0] === 'string') {
            format = arguments[0];
            options = DEFAULTS;
        } else if (typeof arguments[0] === 'object'){
            format = '%h';
            options = createOptions(arguments[0], DEFAULTS);
        } else {
            throw new Error('First argument must be a \'string\' or an \'object\'');
        }

    } else if (length === 3) {
        if (typeof arguments[0] !== 'string') {
            throw new Error('First argument must be a string');
        }

        if (typeof arguments[1] !== 'object') {
            throw new Error('Second argument must be an object');
        }

        format = arguments[0];
        options = createOptions(arguments[1], DEFAULTS);
    }

    if (format.indexOf('%j')>-1) {
        var j = packageVersion(options.repo);

        git(format, options, function(err, version) {
            if (err) {
                callback(err, null);
            } else {
                callback(null, version.replace('%j', j));
            }
        });

    } else {
        git(format, options, callback);
    }
}
function vorto() {
    var length = arguments.length;
    var format, options, callback;

    if (typeof arguments[length-1] !== 'function') {
        throw new Error('The last argument must be a callback function: function(err, version){...}');
    } else {
        callback = arguments[length-1];
    }

    if (length === 1) {
        format = '%h';
        options = DEFAULTS;

    } else if (length === 2) {
        if (typeof arguments[0] === 'string') {
            format = arguments[0];
            options = DEFAULTS;
        } else if (typeof arguments[0] === 'object'){
            format = '%h';
            options = createOptions(arguments[0], DEFAULTS);
        } else {
            throw new Error('First argument must be a \'string\' or an \'object\'');
        }

    } else if (length === 3) {
        if (typeof arguments[0] !== 'string') {
            throw new Error('First argument must be a string');
        }

        if (typeof arguments[1] !== 'object') {
            throw new Error('Second argument must be an object');
        }

        format = arguments[0];
        options = createOptions(arguments[1], DEFAULTS);
    }

    if (format.indexOf('%j')>-1) {
        var j = packageVersion(options.repo);

        git(format, options, function(err, version) {
            if (err) {
                callback(err, null);
            } else {
                callback(null, version.replace('%j', j));
            }
        });

    } else {
        git(format, options, callback);
    }
}
function vorto ( ) { var length = arguments . length ; var format , options , callback ; if ( typeof arguments [ length - 1 ] !== 'function' ) { throw new Error ( 'The last argument must be a callback function: function(err, version){...}' ) ; } else { callback = arguments [ length - 1 ] ; } if ( length === 1 ) { format = '%h' ; options = DEFAULTS ; } else if ( length === 2 ) { if ( typeof arguments [ 0 ] === 'string' ) { format = arguments [ 0 ] ; options = DEFAULTS ; } else if ( typeof arguments [ 0 ] === 'object' ) { format = '%h' ; options = createOptions ( arguments [ 0 ] , DEFAULTS ) ; } else { throw new Error ( 'First argument must be a \'string\' or an \'object\'' ) ; } } else if ( length === 3 ) { if ( typeof arguments [ 0 ] !== 'string' ) { throw new Error ( 'First argument must be a string' ) ; } if ( typeof arguments [ 1 ] !== 'object' ) { throw new Error ( 'Second argument must be an object' ) ; } format = arguments [ 0 ] ; options = createOptions ( arguments [ 1 ] , DEFAULTS ) ; } if ( format . indexOf ( '%j' ) > - 1 ) { var j = packageVersion ( options . repo ) ; git ( format , options , function ( err , version ) { if ( err ) { callback ( err , null ) ; } else { callback ( null , version . replace ( '%j' , j ) ) ; } } ) ; } else { git ( format , options , callback ) ; } }
Init function that might take 3 parameters. It checks the input parameters and will throw errors if they're not
valid or wrongly ordered.

The callback is always required.
vorto([format][, options], callback);
Init function that might take 3 parameters . It checks the input parameters and will throw errors if they re not valid or wrongly ordered .