@powfix/core-js 0.13.9 → 0.13.11

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.
@@ -1,6 +1,6 @@
1
1
  import { MomentInput, RelativeTimeSpec } from "moment";
2
2
  export declare class DateUtils {
3
- static relativeDate: (input: MomentInput, from?: MomentInput) => string;
3
+ static relativeDate: (input: MomentInput, base?: MomentInput) => string;
4
4
  static setLocale: (language: DateUtils.Locale) => void;
5
5
  private static getRelativeTimeSpec;
6
6
  }
@@ -8,14 +8,14 @@ const moment_1 = __importDefault(require("moment"));
8
8
  class DateUtils {
9
9
  }
10
10
  exports.DateUtils = DateUtils;
11
- DateUtils.relativeDate = (input, from = Date.now()) => {
11
+ DateUtils.relativeDate = (input, base = Date.now()) => {
12
12
  // Create new moment instance to apply new locale
13
13
  const datetime = moment_1.default.isMoment(input) ? (0, moment_1.default)(input.toDate()) : (0, moment_1.default)(input);
14
14
  if (!datetime.isValid()) {
15
15
  console.error('core-js:DateUtils.relativeDate() datetime is invalid', datetime);
16
16
  return '<INVALID DATE>';
17
17
  }
18
- return datetime.from(from);
18
+ return datetime.from(base);
19
19
  };
20
20
  DateUtils.setLocale = (language) => {
21
21
  const relativeTime = DateUtils.getRelativeTimeSpec(language);
@@ -0,0 +1 @@
1
+ export declare function circularDistance(value: number, target: number, min: number, max: number): number;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.circularDistance = void 0;
4
+ function circularDistance(value, target, min, max) {
5
+ const range = max - min;
6
+ const from = value - min;
7
+ const to = target - min;
8
+ if (to >= from) {
9
+ return to - from;
10
+ }
11
+ else {
12
+ return range - from + to;
13
+ }
14
+ }
15
+ exports.circularDistance = circularDistance;
@@ -1,4 +1,5 @@
1
1
  export * from './between';
2
+ export * from './circularDistance';
2
3
  export * from './sleep';
3
4
  export * from './fallbackIfEqual';
4
5
  export * from './fallbackIfNull';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./between"), exports);
18
+ __exportStar(require("./circularDistance"), exports);
18
19
  __exportStar(require("./sleep"), exports);
19
20
  __exportStar(require("./fallbackIfEqual"), exports);
20
21
  __exportStar(require("./fallbackIfNull"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.13.9",
3
+ "version": "0.13.11",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,