@digitransit-search-util/digitransit-search-util-is-duplicate 0.0.7 → 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +13 -11
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -22,6 +22,9 @@ import truEq from '@digitransit-search-util/digitransit-search-util-tru-eq';
22
22
  * digitransit-util.isDuplicate(param1, param2);
23
23
  * //=true
24
24
  */
25
+
26
+ const gtfsStopLayers = ['stop', 'station', 'favouriteStop', 'favouriteStation'];
27
+
25
28
  export default function isDuplicate(item1, item2) {
26
29
  const props1 = item1.properties;
27
30
  const props2 = item2.properties;
@@ -35,10 +38,7 @@ export default function isDuplicate(item1, item2) {
35
38
  const name1 = `${o1.name}//${o1.locality}//${d1.name}//${d1.locality}`;
36
39
  const name2 = `${o2.name}//${o2.locality}//${d2.name}//${d2.locality}`;
37
40
 
38
- if (truEq(name1, name2)) {
39
- return true;
40
- }
41
- return false;
41
+ return name1 === name2;
42
42
  }
43
43
  if (item1.type === 'FutureRoute' || item2.type === 'FutureRoute') {
44
44
  return false;
@@ -52,14 +52,16 @@ export default function isDuplicate(item1, item2) {
52
52
  ) {
53
53
  return props1.labelId === props2.labelId;
54
54
  }
55
- if (truEq(props1.gtfsId, props2.gtfsId)) {
56
- return true;
55
+ if (props1.gtfsId && props2.gtfsId) {
56
+ return props1.gtfsId === props2.gtfsId;
57
57
  }
58
- if (props1.gtfsId && props2.gid && props2.gid.includes(props1.gtfsId)) {
59
- return true;
60
- }
61
- if (props2.gtfsId && props1.gid && props1.gid.includes(props2.gtfsId)) {
62
- return true;
58
+ if (
59
+ gtfsStopLayers.includes(props1.layer) &&
60
+ gtfsStopLayers.includes(props2.layer) &&
61
+ props1.gid &&
62
+ props2.gid
63
+ ) {
64
+ return props1.gid === props2.gid;
63
65
  }
64
66
 
65
67
  const p1 = item1 && item1.geometry ? item1.geometry.coordinates : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitransit-search-util/digitransit-search-util-is-duplicate",
3
- "version": "0.0.7",
3
+ "version": "1.0.0",
4
4
  "description": "digitransit-search-util is-duplicate module",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -23,5 +23,5 @@
23
23
  "dependencies": {
24
24
  "@digitransit-search-util/digitransit-search-util-tru-eq": "0.0.2"
25
25
  },
26
- "gitHead": "1fc76130a473e69e5d9c7b5d73bf060219bdccd3"
26
+ "gitHead": "5c78ef7df03c2e12cc7a4be8d3ea3f2d76261d0a"
27
27
  }