tesla-inventory 3.4.13 → 3.4.15

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tesla-inventory",
3
3
  "description": "Retrieve real-time data from Tesla Inventory.",
4
4
  "homepage": "https://github.com/Kikobeats/tesla-inventory",
5
- "version": "3.4.13",
5
+ "version": "3.4.15",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -75,6 +75,7 @@
75
75
  "teslamotors"
76
76
  ],
77
77
  "dependencies": {
78
+ "@kikobeats/time-span": "~1.0.2",
78
79
  "p-retry": "4"
79
80
  },
80
81
  "devDependencies": {
package/src/index.js CHANGED
@@ -1,15 +1,11 @@
1
1
  'use strict'
2
2
 
3
+ const timeSpan = require('@kikobeats/time-span')({ format: n => `${Math.round(n)}ms` })
3
4
  const debug = require('debug-logfmt')('tesla-inventory')
4
5
  const pRetry = require('p-retry')
5
6
 
6
7
  const inventories = require('./inventories')
7
8
 
8
- const timestamp =
9
- (start = process.hrtime.bigint()) =>
10
- () =>
11
- Math.round(Number(process.hrtime.bigint() - start) / 1e6)
12
-
13
9
  const uniqBy = (arr, prop) =>
14
10
  arr.filter((x, i, self) => i === self.findIndex(y => x[prop] === y[prop]))
15
11
 
@@ -28,7 +24,7 @@ module.exports =
28
24
 
29
25
  const { country, ...query } = { ...inventories[inventory], ...opts }
30
26
 
31
- const duration = timestamp()
27
+ const duration = timeSpan()
32
28
 
33
29
  const paginate = async (offset = 0) => {
34
30
  const url = new URL(
@@ -70,7 +66,7 @@ module.exports =
70
66
  offset = items.length
71
67
  } while (page.items.length > 0)
72
68
 
73
- debug.info({ inventory, ...opts, items: items.length, duration: `${duration()}ms` })
69
+ debug.info({ inventory, ...opts, items: items.length, duration: duration() })
74
70
 
75
71
  return items.filter(item => item.Model === opts.model)
76
72
  }
@@ -44,7 +44,7 @@
44
44
  "MT301": 3990,
45
45
  "MT302": 8900,
46
46
  "MT303": 10990,
47
- "MT304": 17990,
47
+ "MT304": 15990,
48
48
  "MT305": 15900,
49
49
  "MT308": 3990,
50
50
  "MT310": 10990,