tesla-inventory 3.5.270 → 3.5.271
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 +2 -6
- package/src/index.js +7 -3
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.5.
|
|
5
|
+
"version": "3.5.271",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|
|
@@ -91,7 +91,6 @@
|
|
|
91
91
|
"signal-exit": "latest",
|
|
92
92
|
"simple-git-hooks": "latest",
|
|
93
93
|
"standard": "latest",
|
|
94
|
-
"standard-markdown": "latest",
|
|
95
94
|
"standard-version": "latest"
|
|
96
95
|
},
|
|
97
96
|
"engines": {
|
|
@@ -103,7 +102,7 @@
|
|
|
103
102
|
"scripts": {
|
|
104
103
|
"clean": "rm -rf node_modules",
|
|
105
104
|
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
106
|
-
"lint": "standard
|
|
105
|
+
"lint": "standard",
|
|
107
106
|
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
108
107
|
"prerelease": "npm run contributors",
|
|
109
108
|
"pretest": "npm run lint",
|
|
@@ -136,9 +135,6 @@
|
|
|
136
135
|
"prettier-standard",
|
|
137
136
|
"standard --fix"
|
|
138
137
|
],
|
|
139
|
-
"*.md": [
|
|
140
|
-
"standard-markdown"
|
|
141
|
-
],
|
|
142
138
|
"package.json": [
|
|
143
139
|
"finepack"
|
|
144
140
|
]
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const pRetry = require('p-retry')
|
|
|
6
6
|
|
|
7
7
|
const inventories = require('./inventories')
|
|
8
8
|
|
|
9
|
-
const ITEMS_PER_PAGE =
|
|
9
|
+
const ITEMS_PER_PAGE = 24
|
|
10
10
|
|
|
11
11
|
const uniqBy = (arr, prop) =>
|
|
12
12
|
arr.filter((x, i, self) => i === self.findIndex(y => x[prop] === y[prop]))
|
|
@@ -51,7 +51,7 @@ module.exports =
|
|
|
51
51
|
fetcher(url, fetcherOpts).then(async body => {
|
|
52
52
|
try {
|
|
53
53
|
const data = JSON.parse(body)
|
|
54
|
-
return { items: data.results ?? [] }
|
|
54
|
+
return { items: data.results ?? [], total: Number(data.total_matches_found) }
|
|
55
55
|
} catch (error) {
|
|
56
56
|
error.body = body
|
|
57
57
|
throw error
|
|
@@ -76,7 +76,11 @@ module.exports =
|
|
|
76
76
|
++pageIndex
|
|
77
77
|
items = uniqBy(items.concat(page.items), 'VIN')
|
|
78
78
|
offset = pageIndex * ITEMS_PER_PAGE
|
|
79
|
-
} while (
|
|
79
|
+
} while (
|
|
80
|
+
(pageIndex !== 0 || page.items.length >= ITEMS_PER_PAGE) &&
|
|
81
|
+
page.items.length > 0 &&
|
|
82
|
+
items.length < page.total
|
|
83
|
+
)
|
|
80
84
|
|
|
81
85
|
debug.info({ inventory, ...opts, items: items.length, duration: duration() })
|
|
82
86
|
|