0.0.5 • Published 6 years ago

gw2-itemstats v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

gw2-itemstats

version license Travis Coverage

This module loads itemstats combinations with real attribute values from the API by parsing all available items and matching them to /v2/itemstats.

Installation

Install this module with your favorite package manager, e.g. npm install gw2-itemstats.

Usage

import { getItemstats } from 'gw2-itemstats';

const language = 'en';

// get itemstats
const itemstats = getItemstats(language);

// get itemstats for rare level 78 weapons
const itemstatsRare78Weapons = getItemstats(language, {
    filter: (item) => item.rarity === 'Rare' && item.level === 78 && item.type === 'Weapon'
});

Result

Array of itemstats objects following this structure:

{
    id: 161,
    name: 'Berserker\'s',
    attributes: {
        CritDamage: 101,
        Power: 141,
        Precision: 101
    },
    level: 80,
    rarity: 'Ascended',
    type: 'Armor',
    subtype: 'Coat'
}

Options

OptionTypeDescription
useCacheboolUse the cache to lookup items and itemstats.Default: true.
apiObjectObject containing the functions items and itemstats, both returning promises containing all items and itemstats that should be considered for resulting list.Default: Uses gw2api-client to load all items and itemstats
cacheMapObject used as cache following the Map interface.Default: new Map()
filterfunctionCallback used to filter the items. The first parameter is the item as it is returned from the API.This is done after caching, to reuse the cache for different filters. Manually applying a filter in the api-option can reduce the cache size.Default: (item) => true

License

gw2-itemstats is licensed under the MIT License.