tf2-item-format
Version:
Format's TF2 items like backpack.tf does
24 lines • 711 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = getDefindex;
function getDefindex(econ) {
if (!econ.item.actions)
return -1;
const wikiLink = econ.item.actions.find(isWikiLink);
if (!wikiLink)
return -1;
return parseDefindex(wikiLink);
}
function isWikiLink(action) {
return action.name === 'Item Wiki Page...';
}
function parseDefindex(action) {
let [, strId] = action.link.match(/^http:\/\/wiki\.teamfortress\.com\/scripts\/itemredirect\.php\?id=(\d+)/) || [];
if (!strId)
return -1;
const id = parseInt(strId);
if (isNaN(id))
return -1;
return id;
}
//# sourceMappingURL=getDefindex.js.map