@twin.org/entity 0.0.1-next.11 → 0.0.1-next.12

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.
@@ -572,7 +572,9 @@ class EntitySorter {
572
572
  */
573
573
  static compare(entity1, entity2, prop, type, direction = SortDirection.Ascending) {
574
574
  let res = 0;
575
- if (!core.Is.empty(entity1[prop]) && !core.Is.empty(entity2[prop])) {
575
+ const hasProp1 = !core.Is.empty(entity1[prop]);
576
+ const hasProp2 = !core.Is.empty(entity2[prop]);
577
+ if (hasProp1 && hasProp2) {
576
578
  if (type === "number" || type === "integer") {
577
579
  res = entity1[prop] - entity2[prop];
578
580
  }
@@ -593,6 +595,12 @@ class EntitySorter {
593
595
  res = entity1[prop].localeCompare(entity2[prop]);
594
596
  }
595
597
  }
598
+ else if (hasProp1) {
599
+ res = -1;
600
+ }
601
+ else {
602
+ res = 1;
603
+ }
596
604
  return direction === SortDirection.Ascending ? res : res * -1;
597
605
  }
598
606
  }
@@ -570,7 +570,9 @@ class EntitySorter {
570
570
  */
571
571
  static compare(entity1, entity2, prop, type, direction = SortDirection.Ascending) {
572
572
  let res = 0;
573
- if (!Is.empty(entity1[prop]) && !Is.empty(entity2[prop])) {
573
+ const hasProp1 = !Is.empty(entity1[prop]);
574
+ const hasProp2 = !Is.empty(entity2[prop]);
575
+ if (hasProp1 && hasProp2) {
574
576
  if (type === "number" || type === "integer") {
575
577
  res = entity1[prop] - entity2[prop];
576
578
  }
@@ -591,6 +593,12 @@ class EntitySorter {
591
593
  res = entity1[prop].localeCompare(entity2[prop]);
592
594
  }
593
595
  }
596
+ else if (hasProp1) {
597
+ res = -1;
598
+ }
599
+ else {
600
+ res = 1;
601
+ }
594
602
  return direction === SortDirection.Ascending ? res : res * -1;
595
603
  }
596
604
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/entity - Changelog
2
2
 
3
- ## 0.0.1-next.11
3
+ ## 0.0.1-next.12
4
4
 
5
5
  - Initial Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity",
3
- "version": "0.0.1-next.11",
3
+ "version": "0.0.1-next.12",
4
4
  "description": "Helpers for defining and working with entities",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/core": "0.0.1-next.11",
17
+ "@twin.org/core": "0.0.1-next.12",
18
18
  "@twin.org/nameof": "next",
19
19
  "reflect-metadata": "0.2.2"
20
20
  },