code: function waitUntil(check, onComplete, delay, timeout) {
          if (check()) {
              onComplete();
              return;
          }
  
          if (!delay) delay = 100;
          var timeoutPointer = void 0;
          var intervalPointer = setInterval(function () {
              if (!check()) return;
              clearInterval(intervalPointer);
              if (timeoutPointer) clearTimeout(timeoutPointer);
              onComplete();
          }, delay);
          if (timeout) timeoutPointer = setTimeout(function () {
              clearInterval(intervalPointer);
          }, timeout);
      }
docs: Wait until
  wait until all the validations
  are passed
  
  @param {function} check
  @param {function} onComplete
  @param {numeric} delay
  @param {numeric} timeout