import enquireJs from "enquire.js";

export function enquireScreen(call) {
  const handler = {
    match() {
      call && call(true);
    },
    unmatch() {
      call && call(false);
    },
  };
  enquireJs.register("only screen and (max-width: 767.99px)", handler);
}

// 生成范围内的随机数
export function generateRandom(min, max) {
  return Math.floor(Math.random() * (max - min)) + min;
}

// 字符串转对象
export function getObjByString(str) {
  // eslint-disable-next-line
  return str ? new Function(`return${str}`)() : {};
}
