@powfix/core-js 0.11.8 → 0.11.10

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.
@@ -28,7 +28,7 @@ export declare class TimeService {
28
28
  getClientTime(defaultValue?: TimeService.TimeStamp): TimeService.TimeStamp;
29
29
  getServerTime(): TimeService.TimeStamp | null;
30
30
  getTime(): number;
31
- private readonly fetchServerNTPResult;
31
+ private fetchServerNTPResult;
32
32
  getStatus(): TimeServiceStatus;
33
33
  start(): void;
34
34
  stop(): void;
@@ -32,17 +32,6 @@ class TimeService {
32
32
  this.on = this.emitter.on.bind(this.emitter);
33
33
  this.off = this.emitter.off.bind(this.emitter);
34
34
  this.emit = this.emitter.emit.bind(this.emitter);
35
- this.fetchServerNTPResult = (t1) => __awaiter(this, void 0, void 0, function* () {
36
- try {
37
- if (typeof this.option.serverTimeProvider === 'function') {
38
- return yield this.option.serverTimeProvider(t1);
39
- }
40
- }
41
- catch (e) {
42
- console.error(e);
43
- }
44
- return null;
45
- });
46
35
  this.option = option;
47
36
  if (option.autoStart) {
48
37
  this.start();
@@ -119,6 +108,19 @@ class TimeService {
119
108
  getTime() {
120
109
  return this.getServerTime() || this.getClientTime();
121
110
  }
111
+ fetchServerNTPResult(t1) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ try {
114
+ if (typeof this.option.serverTimeProvider === 'function') {
115
+ return yield this.option.serverTimeProvider(t1);
116
+ }
117
+ }
118
+ catch (e) {
119
+ console.error(e);
120
+ }
121
+ return null;
122
+ });
123
+ }
122
124
  getStatus() {
123
125
  return this.status;
124
126
  }
@@ -0,0 +1 @@
1
+ export declare function fallbackIfEqual<V, C, F>(value: V, condition: C, fallback: F): V | F;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fallbackIfEqual = void 0;
4
+ function fallbackIfEqual(value, condition, fallback) {
5
+ if (typeof value === typeof condition && value === condition) {
6
+ return fallback;
7
+ }
8
+ return value;
9
+ }
10
+ exports.fallbackIfEqual = fallbackIfEqual;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fallbackIfNull = void 0;
4
+ const fallbackIfEqual_1 = require("./fallbackIfEqual");
4
5
  function fallbackIfNull(value, fallback) {
5
- return value === null ? fallback : value;
6
+ return (0, fallbackIfEqual_1.fallbackIfEqual)(value, null, fallback);
6
7
  }
7
8
  exports.fallbackIfNull = fallbackIfNull;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fallbackIfUndefined = void 0;
4
+ const fallbackIfEqual_1 = require("./fallbackIfEqual");
4
5
  function fallbackIfUndefined(value, fallback) {
5
- return value === undefined ? fallback : value;
6
+ return (0, fallbackIfEqual_1.fallbackIfEqual)(value, undefined, fallback);
6
7
  }
7
8
  exports.fallbackIfUndefined = fallbackIfUndefined;
@@ -1,4 +1,5 @@
1
1
  export * from './between';
2
2
  export * from './sleep';
3
+ export * from './fallbackIfEqual';
3
4
  export * from './fallbackIfNull';
4
5
  export * from './fallbackIfUndefined';
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./between"), exports);
18
18
  __exportStar(require("./sleep"), exports);
19
+ __exportStar(require("./fallbackIfEqual"), exports);
19
20
  __exportStar(require("./fallbackIfNull"), exports);
20
21
  __exportStar(require("./fallbackIfUndefined"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.11.8",
3
+ "version": "0.11.10",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,