{"size": 1278, "ext": "js", "max_stars_repo_path": "lib/commands/setOrientation.js", "max_stars_repo_name": "ngokevin/webdriverio-master", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/commands/setOrientation.js", "max_issues_repo_name": "ngokevin/webdriverio-master", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/commands/setOrientation.js", "max_forks_repo_name": "ngokevin/webdriverio-master", "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": 22.4210526316, "max_line_length": 127, "alphanum_fraction": 0.5923317684}
/**
 *
 * Set the current browser orientation.
 *
 * <example>
    :setOrientation.js
    client
        .setOrientation('landscape')
        .getOrientation(function(err, orientation) {
            console.log(orientation); // outputs: "landscape"
        })
        .end();
 * </example>
 *
 * @param {String} orientation the new browser orientation (`landscape/portrait`)
 * @callbackParameter error
 *
 * @uses protocol/orientation
 * @type mobile
 *
 */

var async = require('async'),
    ErrorHandler = require('../utils/ErrorHandler.js');

module.exports = function setOrientation (orientation) {

    /*!
     * make sure that callback contains chainit callback
     */
    var callback = arguments[arguments.length - 1];

    /*!
     * parameter check
     */
    if(typeof orientation !== 'string') {
        return callback(new ErrorHandler.CommandError('number or type of arguments don\'t agree with setOrientation command'));
    }

    var self = this,
        response = {};

    async.waterfall([
        function(cb) {
            self.orientation(orientation.toUpperCase(), cb);
        },
        function(res, cb) {
            response.orientation = res;
            cb();
        }
    ], function(err) {

        callback(err,null,response);

    });

};