import { getUrlParam } from "./getUrlParam";
/**
 *  ---
 *  获取 URL 传递指定参数<br/>
 *
 * @param    {string | undefined}  [key=undefined]  参数key键
 * @returns  {string | object}  key键对应的值  默认返回全部的参数值
 * @function  getURLParamByKey
 * @author    libo
 * @static
 * @example example 01 缺省key值
 * --------------------------------------------------------------------------
 *
 *  import { getURLParamByKey } from '@riil-frontend/utils';
 *  getURLParamByKey();
 *
 *
 *  eg: url = http://localhost/riil-biz-frontend/dist/#/module/function?id=123&name=appbir&ts=1571105560850
 *  // result
 *  {
 *    "id": "123",
 *    "name": "appbir",
 *    "ts": "1571105560850"
 *  }
 * @example example 02 指定key
 * --------------------------------------------------------------------------
 * getURLParamByKey('id');
 *
 * // result
 * "123"
 *
 */

export var getURLParamByKey = function getURLParamByKey(key) {
  var URLParam = getUrlParam();
  return key ? URLParam[key] : URLParam;
};