@powfix/core-js 0.9.26 → 0.9.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,10 +3,6 @@ export declare enum TimeServiceStatus {
3
3
  STOPPED = 0,
4
4
  RUNNING = 1
5
5
  }
6
- export declare enum TimeServiceEvent {
7
- SYNCED = "SYNCED",
8
- SYNC_INTERVAL_CHANGED = "SYNC_INTERVAL_CHANGED"
9
- }
10
6
  export declare class TimeService {
11
7
  private static readonly DEFAULT_SYNC_INTERVAL;
12
8
  protected status: TimeServiceStatus;
@@ -14,8 +10,8 @@ export declare class TimeService {
14
10
  private option;
15
11
  private syncedAt?;
16
12
  private emitter;
17
- readonly on: <T extends string | symbol>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter3<string | symbol, any>;
18
- readonly off: <T extends string | symbol>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter3<string | symbol, any>;
13
+ readonly on: <T extends TimeService.Event>(event: T, fn: (...args: any[]) => void, context?: any) => EventEmitter3<TimeService.Event, any>;
14
+ readonly off: <T extends TimeService.Event>(event: T, fn?: ((...args: any[]) => void) | undefined, context?: any, once?: boolean | undefined) => EventEmitter3<TimeService.Event, any>;
19
15
  private readonly emit;
20
16
  static calculateNTPResultOffset(ntpResult: TimeService.NTPResult): TimeService.Offset;
21
17
  constructor(option: TimeService.Option);
@@ -50,6 +46,7 @@ export declare namespace TimeService {
50
46
  t3: TimeStamp;
51
47
  t4: TimeStamp;
52
48
  }
49
+ type Event = 'SYNCED' | 'SYNC_INTERVAL_CHANGED';
53
50
  interface ServerNTPResult extends Pick<NTPResult, 't2' | 't3'> {
54
51
  }
55
52
  type ClientTimeProvider = () => TimeStamp;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.TimeService = exports.TimeServiceEvent = exports.TimeServiceStatus = void 0;
15
+ exports.TimeService = exports.TimeServiceStatus = void 0;
16
16
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
17
17
  const LOG_TAG = 'TimeService';
18
18
  var TimeServiceStatus;
@@ -20,11 +20,6 @@ var TimeServiceStatus;
20
20
  TimeServiceStatus[TimeServiceStatus["STOPPED"] = 0] = "STOPPED";
21
21
  TimeServiceStatus[TimeServiceStatus["RUNNING"] = 1] = "RUNNING";
22
22
  })(TimeServiceStatus || (exports.TimeServiceStatus = TimeServiceStatus = {}));
23
- var TimeServiceEvent;
24
- (function (TimeServiceEvent) {
25
- TimeServiceEvent["SYNCED"] = "SYNCED";
26
- TimeServiceEvent["SYNC_INTERVAL_CHANGED"] = "SYNC_INTERVAL_CHANGED";
27
- })(TimeServiceEvent || (exports.TimeServiceEvent = TimeServiceEvent = {}));
28
23
  class TimeService {
29
24
  static calculateNTPResultOffset(ntpResult) {
30
25
  const { t1, t2, t3, t4 } = ntpResult;
@@ -53,6 +48,7 @@ class TimeService {
53
48
  this.start();
54
49
  }
55
50
  // Binding
51
+ this.emit = this.emit.bind(this);
56
52
  this.start = this.start.bind(this);
57
53
  this.stop = this.stop.bind(this);
58
54
  this.sync = this.sync.bind(this);
@@ -83,7 +79,7 @@ class TimeService {
83
79
  setSyncedAt(syncedAt) {
84
80
  this.syncedAt = syncedAt;
85
81
  // Emit
86
- this.emit(TimeServiceEvent.SYNCED, syncedAt);
82
+ this.emit('SYNCED', syncedAt);
87
83
  return syncedAt;
88
84
  }
89
85
  getSyncInterval() {
@@ -100,7 +96,7 @@ class TimeService {
100
96
  setSyncInterval(interval) {
101
97
  this.option.syncInterval = interval;
102
98
  // Emit
103
- this.emit(TimeServiceEvent.SYNC_INTERVAL_CHANGED, interval);
99
+ this.emit('SYNC_INTERVAL_CHANGED', interval);
104
100
  if (this.status === TimeServiceStatus.RUNNING) {
105
101
  if (this.syncHandler !== undefined) {
106
102
  this.stopSync();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.9.26",
3
+ "version": "0.9.28",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,
@@ -19,7 +19,7 @@
19
19
  "browser": "dist/browser.js",
20
20
  "scripts": {
21
21
  "clean": "rm -rf dist",
22
- "build": "yarn clean && tsc -p . && git add dist"
22
+ "build": "yarn clean; tsc -p ."
23
23
  },
24
24
  "files": [
25
25
  "dist"