code: function waitFor(name, condition) {
    var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100;
    var maxCount = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1000;
  
    if (isFunction(name)) {
      maxCount = time;
      time = isNumeric(condition) ? condition : 100;
      condition = name;
      name = null;
    }
  
    if (!store.waitFor) store.waitFor = {};
    var waits = store.waitFor;
  
    if (name && isset(waits[name])) {
      glb().clearInterval(waits[name]);
      delete waits[name];
    }
  
    return new Promise(function (resolve, reject) {
      var count = 0;
  
      function judge(interval) {
        if (count <= maxCount) {
          if (condition()) {
            stop(interval, name);
            resolve();
          }
        } else {
          stop(interval, name);
          reject(new Error('waitFor: Limit is reached'));
        }
  
        count++;
      }
  
      function stop(interval, name) {
        if (interval) {
          if (name && isset(waits[name])) {
            glb().clearInterval(waits[name]);
            delete waits[name];
          } else {
            glb().clearInterval(interval);
          }
        }
      }
  
      var interval = glb().setInterval(function () {
        judge(interval);
      }, time);
  
      if (name) {
        waits[name] = interval;
      }
  
      judge();
    });
  }
docs: overload waitFor(condition, time = 100, maxCount = 1000))