Set granularity

@param {string|object} granularity Granularity as string or type
@param {...*} args Arguments depending on granularity type
@returns {string|object}
160132
function granularity(granularity) {
  if (utils.isObject(granularity)) {
    return granularity
  }
  else if (typeof granularity === 'string' && ~GRANULARITIES.indexOf(granularity)) {
    return granularity
  }

  if (!formatters.hasOwnProperty(granularity)) {
    throw new FieldError('Bad granularity type: ' + granularity)
  }

  var args = utils.args(arguments, 1)
    , spec = {
      type: granularity
    }

  formatters[granularity].apply(spec, args)

  return spec
}
1330060
function requireValidOptionalObject (arg) {
    // if arg is undefined then return empty object
    if (arg === undefined) {
        return {}
    }
    // throw error if arg is not an object
    if (!arg || typeof arg !== 'object' || Array.isArray(arg)) {
        throw new Error('argument error: argument must be an object')
    }
    // return validated object
    return arg
}
663140
function joinMsgArgs(msgArgs) {
         if (!msgArgs) {
             return '';
         }
         return msgArgs.map((arg) => {
            if (arg === null) {
                return 'null';
            } else if (typeof arg === 'undefined') {
                return 'undefined';
            } else if (typeof arg === 'string') {
                 return arg;
             } else if (typeof arg === 'object') {
                 try {
                     return JSON.stringify(arg);
                 } catch (ex) {
                     return arg.toString();
                 }
             } else { // boolean, symbol, number, function
                 return arg.toString();
             }
         }).join(' ');
     }
458512
function assertArguments(options, argnames) {
  if (!argnames) return;
  if (!options) throw new TypeError('missing arguments: ' + argnames);
  argnames.forEach(function (argname) {
    if (!options.hasOwnProperty(argname)) {
      throw new TypeError('missing argument: ' + argname);
    }
  });
}
688921
function castArgument(arg) {
    "use strict";
    if (arg.match(/^-?\d+$/)) {
        return parseInt(arg, 10);
    } else if (arg.match(/^-?\d+\.\d+$/)) {
        return parseFloat(arg);
    } else if (arg.match(/^(true|false)$/i)) {
        return arg.trim().toLowerCase() === "true" ? true : false;
    } else {
        return arg;
    }
}
451197
function packRestArguments(pattern, args) {
      if(pattern.all) {
        return [args];
      } else if(pattern.rest) {
        var firstArgs = _.head(args, pattern.args.length);
        var restArgs = _.tail(args, pattern.args.length);
        firstArgs.push(restArgs);
        return firstArgs;
      } else {
        return args;
      }
    }
775726
function parseArguments$3(args) {
        var first = args[0];
        var second = args[1];

        return typeof first === 'string' ? { namespace: first, mappings: second } : { namespace: null, mappings: first };
    }
556918
function(...a_args) {

		// ref args length and 0th arg
		let n_args = a_args.length;
		let z_arg0 = a_args[0];

		// no arguments OR single argument is a boolean (fetch)
		if(n_args === 0 || (n_args === 1 && 'boolean' === typeof z_arg0)) {

			// no soft/hard options
			if('function' === typeof h_handler.fetch) {
				return h_handler.fetch();
			}
			// fetch soft
			else if(!n_args || false === z_arg0) {
				return h_handler.fetch.soft();
			}
			// fetch hard
			else {
				return h_handler.fetch.hard();
			}
		}
		// add
		else {
			h_handler.add(...a_args);
		}

		// update self reference to this
		self = this;

		// chain
		return this;
	}
886070
function ( obj, arg ) {
		var key     = obj.textContent !== undefined ? "textContent" : "innerText",
		    payload = {},
		    set     = false;

		if ( typeof arg !== "undefined" ) {
			set          = true;
			payload[key] = arg;
		}

		return set ? element.update( obj, payload ) : obj[key];
	}
458311
function ( arg, obj ) {
		if ( $[arg] !== undefined || !obj instanceof Object ) {
			throw new Error( label.error.invalidArguments );
		}
		
		$[arg] = obj;

		return $[arg];
	}
386831
function initAssets (args) {
    // default to empty strings
    this.css = ''
    this.js = ''
    // if client has css use it
    if (defined(args.css)) {
        // require css to be a string
        this.assert(typeof args.css === 'string', 117)
        // set component css
        this.css = args.css
    }
    // if client has js set use it
    if (defined(args.js)) {
        // require js to be string
        this.assert(typeof args.js === 'string', 114)
        // set component js
        this.js = args.js
    }
}
824838
function jsify(arg) {
        if (_.isArray(arg)) {
            return _.map(arg, jsify);
        }
        else if (!_.isObject(arg)) {
            return arg;
        }
        else if (Tinkerpop.isLongValue(arg)) {
            // Represent longValue_t as string
            return arg.longValue;
        }
        else if (isType(arg, 'java.util.List')) {
            return _jsifyCollection(arg);
        }
        else if (isType(arg, 'java.util.Map')) {
            return _jsifyMap(arg);
        }
        else if (isType(arg, 'java.util.Map$Entry')) {
            return _jsifyMapEntry(arg);
        }
        else if (isType(arg, 'org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet')) {
            // BulkSet is used to hold groupCount result, so it is given special treatment.
            return _jsifyBulkSet(arg);
        }
        else if (isType(arg, 'java.util.Set')) {
            return _jsifyCollection(arg);
        }
        else if (isType(arg, 'org.apache.tinkerpop.gremlin.process.traversal.Path')) {
            return _jsifyPath(arg);
        }
        else {
            return arg;
        }
    }
1281419
function getArgParam(argName, fullArgName) {
  /* eslint-disable no-restricted-syntax */
  for (const arg of [argName, fullArgName]) {
    if (restArgs.includes(arg)) {
      return restArgs[restArgs.indexOf(argName) + 1];
    }
  }
  /* eslint-enable no-restricted-syntax */
  return undefined;
}
1362923
function castArgument(arg) {
		if (isNumber(arg)) {
			return parseFloat(arg);
		}

		if (helpers.isFraction(arg)) {
			arg = arg.split('/');

			return arg[0] / arg[1];
		}

		if (arg === 'false' || arg === 'true') {
			return arg === 'true';
		}

		return arg.length ? arg : undefined;
	}
1352201
def argument_kind(args):
    # type: (List[Argument]) -> Optional[str]
    
    kinds = set(arg.kind for arg in args)
    if len(kinds) != 1:
        return None
    return kinds.pop()
1007911
function _normalizeArguments(args) {
    var data = args[0];

    if(Utils.isString(data) || typeof data === 'number' || typeof data === 'boolean'){

      // Update single property using string.
      args[0] = [{
        value: data
      }];

    }else if(Utils.isObject(data)) {

      if (Utils.isDefined(data.value)) {

        // Update single property using object notation.
        args[0] = [data];

      } else {

        // Update multiple properties, creating an object for
        // each key-value pair.
        args[0] = [];
        for (var key in data) {
          args[0].push({
            key: key,
            value: data[key]
          });
        }
      }
    }

    return args;
  }
270391
function isObject (arg) {
    return arg === Object(arg) && Object.prototype.toString.call(arg) !== '[object Array]'
  }