TestWatcher.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. function _defineProperty(obj, key, value) {
  17. if (key in obj) {
  18. Object.defineProperty(obj, key, {
  19. value: value,
  20. enumerable: true,
  21. configurable: true,
  22. writable: true
  23. });
  24. } else {
  25. obj[key] = value;
  26. }
  27. return obj;
  28. }
  29. class TestWatcher extends _emittery().default {
  30. constructor({isWatchMode}) {
  31. super();
  32. _defineProperty(this, 'state', void 0);
  33. _defineProperty(this, '_isWatchMode', void 0);
  34. this.state = {
  35. interrupted: false
  36. };
  37. this._isWatchMode = isWatchMode;
  38. }
  39. async setState(state) {
  40. Object.assign(this.state, state);
  41. await this.emit('change', this.state);
  42. }
  43. isInterrupted() {
  44. return this.state.interrupted;
  45. }
  46. isWatchMode() {
  47. return this._isWatchMode;
  48. }
  49. }
  50. exports.default = TestWatcher;