Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const Timer_1 = __importDefault(require("../Timer"));
  7. class Interception {
  8. constructor(url, filterOptions = {}, browser) {
  9. this.respondOverwrites = [];
  10. this.matches = [];
  11. this.url = url;
  12. this.filterOptions = filterOptions;
  13. this.browser = browser;
  14. }
  15. get calls() {
  16. throw new Error('Implement me');
  17. }
  18. waitForResponse({ timeout = this.browser.options.waitforTimeout, interval = this.browser.options.waitforInterval, timeoutMsg, } = {}) {
  19. if (typeof timeout !== 'number') {
  20. timeout = this.browser.options.waitforTimeout;
  21. }
  22. if (typeof interval !== 'number') {
  23. interval = this.browser.options.waitforInterval;
  24. }
  25. const fn = async () => this.calls && (await this.calls).length > 0;
  26. const timer = new Timer_1.default(interval, timeout, fn, true);
  27. return this.browser.call(() => timer.catch((e) => {
  28. if (e.message === 'timeout') {
  29. if (typeof timeoutMsg === 'string') {
  30. throw new Error(timeoutMsg);
  31. }
  32. throw new Error(`waitForResponse timed out after ${timeout}ms`);
  33. }
  34. throw new Error(`waitForResponse failed with the following reason: ${(e && e.message) || e}`);
  35. }));
  36. }
  37. }
  38. exports.default = Interception;