@furkot/directions 3.0.0 → 3.0.1

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.
@@ -119,8 +119,8 @@ function getStatus(st, response) {
119
119
  if (!(st || response)) {
120
120
  return;
121
121
  }
122
- response = response || {};
123
- response.status = response.status || st;
122
+ response ??= {};
123
+ response.status ||= st;
124
124
  // 401 Unauthorized, 429 Too Many Requests
125
125
  if (st === 401 || st === 429) {
126
126
  // we exceeded the limit
@@ -44,7 +44,7 @@ export default function init(options) {
44
44
  throw ERROR;
45
45
  }
46
46
 
47
- query.path = query.path || pathType.none;
47
+ query.path ||= pathType.none;
48
48
  let req = options.prepareRequest(query);
49
49
  if (!req) {
50
50
  return;
@@ -130,7 +130,7 @@ export default function init(options) {
130
130
  req.avoids = ['Limited Access'];
131
131
  }
132
132
  if (query.avoidTolls) {
133
- req.avoids = req.avoids || [];
133
+ req.avoids ??= [];
134
134
  req.avoids.push('Toll Road');
135
135
  }
136
136
  if (query.begin) {
@@ -190,8 +190,8 @@ export default function init(options) {
190
190
  function avoidFeature(result, flag) {
191
191
  const { query, req } = result;
192
192
  if (query[flag]) {
193
- req.options = req.options || {};
194
- req.options.avoid_features = req.options.avoid_features || [];
193
+ req.options ??= {};
194
+ req.options.avoid_features ??= [];
195
195
  req.options.avoid_features.push(avoidFeatures[flag]);
196
196
  }
197
197
  return result;
@@ -49,13 +49,12 @@ export function isFuture(time) {
49
49
  }
50
50
 
51
51
  // like normal join but with optional filter fn
52
- export function join(arr, conn, fn) {
53
- fn = fn || (it => it);
52
+ export function join(arr, conn, fn = it => it) {
54
53
  return arr.filter(fn).join(conn);
55
54
  }
56
55
 
57
56
  export function last(arr) {
58
- return arr[arr.length - 1];
57
+ return arr.at(-1);
59
58
  }
60
59
 
61
60
  export function split2object(str, conn, obj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@furkot/directions",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Directions service for Furkot",
5
5
  "author": {
6
6
  "name": "Damian Krzeminski",