@juice789/tf2items 1.0.36 → 1.0.38

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.
@@ -1,17 +1,14 @@
1
1
  const { call, getContext, delay } = require('redux-saga/effects')
2
2
 
3
3
  const {
4
- groupBy, map, compose, toPairs, uniq, pick, values, mergeRight, indexBy, props, mapObjIndexed, when, complement, has, assoc, unnest, uncurryN
4
+ groupBy, map, compose, uniq, values, mergeRight, indexBy, props, mapObjIndexed, when, complement, has, assoc, unnest, uncurryN, without
5
5
  } = require('ramda')
6
6
 
7
- const getAssetClassQuery = compose(
8
- map(([key, { classid, instanceid }]) => `&classid${key}=${classid}&instanceid${key}=${instanceid}`),
9
- toPairs
10
- )
7
+ const getAssetClassQuery = assetClassIds => assetClassIds.map(([classid, instanceid], index) => `&classid${index}=${classid}&instanceid${index}=${instanceid}`)
11
8
 
12
9
  const getAssetClassIds = compose(
13
10
  uniq,
14
- map(pick(['classid', 'instanceid']))
11
+ map(props(['classid', 'instanceid']))
15
12
  )
16
13
 
17
14
  const transformAssetClasses = compose(
@@ -32,20 +29,17 @@ const mergeAssetClasses = uncurryN(2, (assetClasses) => compose(
32
29
  groupBy(props(['classid', 'instanceid']))
33
30
  ))
34
31
 
35
- function* fetchAppDataInventory(inventory, d = 1000) {
36
-
37
- let p = 0, assetClasses = {}
32
+ function* fetchAppDataInventory(inventory, d = 1000, cache = []) {
33
+ let p = 0, assetClasses = transformAssetClasses(cache)
38
34
  const { getAssetClassInfo } = yield getContext('api')
39
- const ids = getAssetClassIds(inventory)
40
-
35
+ const ids = without(cache.map(props(['classid', 'instanceid'])), getAssetClassIds(inventory))
41
36
  while (ids.length > 0 && p < ids.length) {
42
37
  yield delay(d)
43
- const query = getAssetClassQuery(ids.slice(p, p + 100))
38
+ const query = getAssetClassQuery(ids.slice(p, p + 150))
44
39
  const { result } = yield call(getAssetClassInfo, query)
45
40
  assetClasses = mergeRight(assetClasses, transformAssetClasses(result))
46
- p += 100
41
+ p += 150
47
42
  }
48
-
49
43
  return mergeAssetClasses(assetClasses, inventory)
50
44
  }
51
45
 
package/fromEconItem.js CHANGED
@@ -332,7 +332,7 @@ const props753 = {
332
332
  market_hash_name: prop('market_hash_name'),
333
333
  border: compose(last, defaultTo(''), findTag('Card Border', 'internal_name')),
334
334
  game: compose(nth(1), split('_'), findTag('Game', 'internal_name')),
335
- type: compose(last, findTag('Item Type', 'internal_name')),
335
+ type: ({ tags = [] }) => last(tags.find(tag => tag.category === 'item_class')?.internal_name || 'x'),
336
336
  id,
337
337
  old_id,
338
338
  contextid,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juice789/tf2items",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "description": "tf2 item schema thingys",
5
5
  "main": "app.js",
6
6
  "scripts": {