@unikue/ts-lang-utils 1.2.0 → 1.2.2

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.
@@ -0,0 +1 @@
1
+ export declare function compareDate(source?: Date | string | null, target?: Date | string | null, nullGreater?: boolean): number;
@@ -0,0 +1,43 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/DateUtils/compareDate.ts
20
+ var compareDate_exports = {};
21
+ __export(compareDate_exports, {
22
+ compareDate: () => compareDate
23
+ });
24
+ module.exports = __toCommonJS(compareDate_exports);
25
+ var import_toTimestamp = require("./toTimestamp");
26
+ function compareDate(source, target, nullGreater = false) {
27
+ const sourceAlias = (0, import_toTimestamp.toTimestamp)(source);
28
+ const targetAlias = (0, import_toTimestamp.toTimestamp)(target);
29
+ if (sourceAlias === targetAlias) {
30
+ return 0;
31
+ }
32
+ if (sourceAlias === void 0) {
33
+ return nullGreater ? 1 : -1;
34
+ }
35
+ if (targetAlias === void 0) {
36
+ return nullGreater ? -1 : 1;
37
+ }
38
+ return sourceAlias > targetAlias ? 1 : -1;
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ compareDate
43
+ });
@@ -1,6 +1,7 @@
1
1
  export { addDay } from './addDay';
2
2
  export { addMonth } from './addMonth';
3
3
  export { addYear } from './addYear';
4
+ export { compareDate } from './compareDate';
4
5
  export { formatDateTime } from './formatDateTime';
5
6
  export { getCurrentDate } from './getCurrentDate';
6
7
  export { getCurrentDateTime } from './getCurrentDateTime';
@@ -21,3 +22,4 @@ export { isSameYear } from './isSameYear';
21
22
  export { isTomorrow } from './isTomorrow';
22
23
  export { isWeekend } from './isWeekend';
23
24
  export { isYesterday } from './isYesterday';
25
+ export { toTimestamp } from './toTimestamp';
@@ -22,6 +22,7 @@ __export(DateUtils_exports, {
22
22
  addDay: () => import_addDay.addDay,
23
23
  addMonth: () => import_addMonth.addMonth,
24
24
  addYear: () => import_addYear.addYear,
25
+ compareDate: () => import_compareDate.compareDate,
25
26
  formatDateTime: () => import_formatDateTime.formatDateTime,
26
27
  getCurrentDate: () => import_getCurrentDate.getCurrentDate,
27
28
  getCurrentDateTime: () => import_getCurrentDateTime.getCurrentDateTime,
@@ -41,12 +42,14 @@ __export(DateUtils_exports, {
41
42
  isSameYear: () => import_isSameYear.isSameYear,
42
43
  isTomorrow: () => import_isTomorrow.isTomorrow,
43
44
  isWeekend: () => import_isWeekend.isWeekend,
44
- isYesterday: () => import_isYesterday.isYesterday
45
+ isYesterday: () => import_isYesterday.isYesterday,
46
+ toTimestamp: () => import_toTimestamp.toTimestamp
45
47
  });
46
48
  module.exports = __toCommonJS(DateUtils_exports);
47
49
  var import_addDay = require("./addDay");
48
50
  var import_addMonth = require("./addMonth");
49
51
  var import_addYear = require("./addYear");
52
+ var import_compareDate = require("./compareDate");
50
53
  var import_formatDateTime = require("./formatDateTime");
51
54
  var import_getCurrentDate = require("./getCurrentDate");
52
55
  var import_getCurrentDateTime = require("./getCurrentDateTime");
@@ -67,11 +70,13 @@ var import_isSameYear = require("./isSameYear");
67
70
  var import_isTomorrow = require("./isTomorrow");
68
71
  var import_isWeekend = require("./isWeekend");
69
72
  var import_isYesterday = require("./isYesterday");
73
+ var import_toTimestamp = require("./toTimestamp");
70
74
  // Annotate the CommonJS export names for ESM import in node:
71
75
  0 && (module.exports = {
72
76
  addDay,
73
77
  addMonth,
74
78
  addYear,
79
+ compareDate,
75
80
  formatDateTime,
76
81
  getCurrentDate,
77
82
  getCurrentDateTime,
@@ -91,5 +96,6 @@ var import_isYesterday = require("./isYesterday");
91
96
  isSameYear,
92
97
  isTomorrow,
93
98
  isWeekend,
94
- isYesterday
99
+ isYesterday,
100
+ toTimestamp
95
101
  });
@@ -0,0 +1 @@
1
+ export declare function toTimestamp(value?: Date | string | null): number | undefined;
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/DateUtils/toTimestamp.ts
20
+ var toTimestamp_exports = {};
21
+ __export(toTimestamp_exports, {
22
+ toTimestamp: () => toTimestamp
23
+ });
24
+ module.exports = __toCommonJS(toTimestamp_exports);
25
+ function toTimestamp(value) {
26
+ if (!value) {
27
+ return void 0;
28
+ }
29
+ const timestamp = typeof value === "string" ? new Date(value).getTime() : value.getTime();
30
+ return Number.isNaN(timestamp) ? void 0 : timestamp;
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ toTimestamp
35
+ });
@@ -0,0 +1 @@
1
+ export declare function compareDate(source?: Date | string | null, target?: Date | string | null, nullGreater?: boolean): number;
@@ -0,0 +1,16 @@
1
+ import { toTimestamp } from "./toTimestamp";
2
+ export function compareDate(source, target) {
3
+ var nullGreater = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
4
+ var sourceAlias = toTimestamp(source);
5
+ var targetAlias = toTimestamp(target);
6
+ if (sourceAlias === targetAlias) {
7
+ return 0;
8
+ }
9
+ if (sourceAlias === undefined) {
10
+ return nullGreater ? 1 : -1;
11
+ }
12
+ if (targetAlias === undefined) {
13
+ return nullGreater ? -1 : 1;
14
+ }
15
+ return sourceAlias > targetAlias ? 1 : -1;
16
+ }
@@ -1,6 +1,7 @@
1
1
  export { addDay } from './addDay';
2
2
  export { addMonth } from './addMonth';
3
3
  export { addYear } from './addYear';
4
+ export { compareDate } from './compareDate';
4
5
  export { formatDateTime } from './formatDateTime';
5
6
  export { getCurrentDate } from './getCurrentDate';
6
7
  export { getCurrentDateTime } from './getCurrentDateTime';
@@ -21,3 +22,4 @@ export { isSameYear } from './isSameYear';
21
22
  export { isTomorrow } from './isTomorrow';
22
23
  export { isWeekend } from './isWeekend';
23
24
  export { isYesterday } from './isYesterday';
25
+ export { toTimestamp } from './toTimestamp';
@@ -1,6 +1,7 @@
1
1
  export { addDay } from "./addDay";
2
2
  export { addMonth } from "./addMonth";
3
3
  export { addYear } from "./addYear";
4
+ export { compareDate } from "./compareDate";
4
5
  export { formatDateTime } from "./formatDateTime";
5
6
  export { getCurrentDate } from "./getCurrentDate";
6
7
  export { getCurrentDateTime } from "./getCurrentDateTime";
@@ -20,4 +21,5 @@ export { isSameMonth } from "./isSameMonth";
20
21
  export { isSameYear } from "./isSameYear";
21
22
  export { isTomorrow } from "./isTomorrow";
22
23
  export { isWeekend } from "./isWeekend";
23
- export { isYesterday } from "./isYesterday";
24
+ export { isYesterday } from "./isYesterday";
25
+ export { toTimestamp } from "./toTimestamp";
@@ -0,0 +1 @@
1
+ export declare function toTimestamp(value?: Date | string | null): number | undefined;
@@ -0,0 +1,7 @@
1
+ export function toTimestamp(value) {
2
+ if (!value) {
3
+ return undefined;
4
+ }
5
+ var timestamp = typeof value === 'string' ? new Date(value).getTime() : value.getTime();
6
+ return Number.isNaN(timestamp) ? undefined : timestamp;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikue/ts-lang-utils",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "title": "TsLangUtils",
5
5
  "description": "Common lang utilities for typescript",
6
6
  "homepage": "https://unikueltd.github.io/ts-lang-utils",
@@ -46,6 +46,7 @@
46
46
  "docs:build": "typedoc --out ./docs-dist",
47
47
  "docs:publish": "gh-pages -d ./docs-dist",
48
48
  "lint": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
49
+ "lint:fix": "eslint --fix \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
49
50
  "test": "jest",
50
51
  "test:coverage": "del-cli ./coverage && jest --coverage --coverageDirectory ./coverage"
51
52
  },
@@ -63,7 +64,7 @@
63
64
  "@types/lodash": "^4.17.24",
64
65
  "@unikue/babel-plugin-remove-comment": "^1.2.0",
65
66
  "@unikue/typedoc-plugin-raw-content": "^1.1.0",
66
- "@unikue/typedoc-theme-dumi": "^1.1.0",
67
+ "@unikue/typedoc-theme-dumi": "^1.1.1",
67
68
  "del-cli": "^7.0.0",
68
69
  "eslint": "^10.3.0",
69
70
  "eslint-plugin-jest": "^29.15.2",
@@ -76,7 +77,7 @@
76
77
  "typescript-eslint": "^8.59.1"
77
78
  },
78
79
  "peerDependencies": {
79
- "typescript": ">=4"
80
+ "typescript": ">=4.0.0"
80
81
  },
81
82
  "repository": {
82
83
  "type": "git",