TestWatcher.js 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _emittery() {
  7. const data = _interopRequireDefault(require('emittery'));
  8. _emittery = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _interopRequireDefault(obj) {
  14. return obj && obj.__esModule ? obj : {default: obj};
  15. }
  16. /**
  17. * Copyright (c) Meta Platforms, Inc. and affiliates.
  18. *
  19. * This source code is licensed under the MIT license found in the
  20. * LICENSE file in the root directory of this source tree.
  21. */
  22. class TestWatcher extends _emittery().default {
  23. state;
  24. _isWatchMode;
  25. constructor({isWatchMode}) {
  26. super();
  27. this.state = {
  28. interrupted: false
  29. };
  30. this._isWatchMode = isWatchMode;
  31. }
  32. async setState(state) {
  33. Object.assign(this.state, state);
  34. await this.emit('change', this.state);
  35. }
  36. isInterrupted() {
  37. return this.state.interrupted;
  38. }
  39. isWatchMode() {
  40. return this._isWatchMode;
  41. }
  42. }
  43. exports.default = TestWatcher;