npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

war3-data-parser

v1.1.2

Published

War3英雄、单位、技能、物品等完整数据解析库,包含836个单位、799个技能、273个物品等数据,开箱即用。支持Gzip压缩,包体减少96%

Downloads

61

Readme

war3-data-parser

🚀 War3完整数据解析库 - 支持Gzip压缩,包体减少96%,加载速度提升25倍!

包含836个单位、799个技能、273个物品、286个Buff等完整War3数据,开箱即用。

📦 安装

npm install war3-data-parser

包大小: 0.34 MB (压缩后) | 原始数据: 7.58 MB | 压缩率: 95.5%

🎯 快速开始

import { War3DataParser, createParser } from 'war3-data-parser';

// 自动检测并加载压缩数据
const parser = new War3DataParser(undefined, true, true);
parser.load();

// 或使用快捷函数
const parser = createParser(undefined, true, true);

// 查询数据
const hero = parser.query.findUnitById('Edem');
console.log(hero.name); // "恶魔猎手"
console.log(hero.hp);   // 100
console.log(hero.goldcost); // 425

📊 数据统计

| 类型 | 数量 | 示例 | |------|------|------| | 单位 | 836 | 恶魔猎手、山丘之王、剑圣等 | | 技能 | 799 | 法力燃烧、风暴之锤、疾风步等 | | 物品 | 273 | 召唤护身符、先祖权杖等 | | Buff | 286 | 各种增益/减益效果 |

🔧 API 参考

War3DataParser 类

class War3DataParser {
  constructor(dataDir?: string, useCompressed?: boolean, useGzip?: boolean)
  load(): void
  get query(): Query
  getStats(): Record<string, number>
  isLoaded(): boolean
  getDataset(): any
}

Query 类

class Query {
  // 单位查询
  findUnits(options?: QueryOptions): SearchResult<Unit>
  findUnitById(id: string): Unit | undefined
  findUnitsByName(name: string): SearchResult<Unit>
  findUnitsByRace(race: string): SearchResult<Unit>

  // 技能查询
  findAbilities(options?: QueryOptions): SearchResult<Ability>
  findAbilityById(id: string): Ability | undefined
  findAbilitiesByName(name: string): SearchResult<Ability>

  // 物品查询
  findItems(options?: QueryOptions): SearchResult<Item>
  findItemById(id: string): Item | undefined
  findItemsByName(name: string): SearchResult<Item>

  // Buff查询
  findBuffs(options?: QueryOptions): SearchResult<Buff>
  findBuffById(id: string): Buff | undefined

  // 高级搜索
  searchUnitsByKeyword(keyword: string, fields?: string[]): SearchResult<Unit>
  searchItemsByKeyword(keyword: string, fields?: string[]): SearchResult<Item>

  // 关联查询
  getUnitAbilities(unit: Unit): Ability[]
  getItemAbilities(item: Item): Ability[]
}

快捷函数

function createParser(dataDir?: string, useCompressed?: boolean, useGzip?: boolean): War3DataParser
function createCompressedParser(dataDir?: string, useGzip?: boolean): War3DataParser
function getCompressedStats(dataDir: string): Record<string, any>

🚀 使用示例

搜索功能

// 搜索单位
const heroes = parser.query.findUnits({
  filter: { level: 5, race: 'nightelf' },
  limit: 10
});

// 关键词搜索
const items = parser.query.searchItemsByKeyword('召唤');
console.log(items.data); // 召唤类物品列表

// 模糊搜索
const abilities = parser.query.findAbilitiesByName('法力燃烧');

获取单位技能

const demonHunter = parser.query.findUnitById('Edem');
const abilities = parser.query.getUnitAbilities(demonHunter);

abilities.forEach(ability => {
  console.log(`${ability.name} (${ability.hotkey})`);
});

数据格式

{
  "s": "Ecen",        // section
  "i": "Ecen",        // _id
  "n": "半神人",      // name
  "hp": 2675,         // 生命值
  "gc": 425,          // 金币消耗
  "rc": "nightelf",   // 种族
  "lv": 5,            // 等级
  "al": "AInv,SCc1"   // 技能列表
}

自动解压缩: 加载时自动转换为原始字段名

📦 包大小对比

# 安装时
npm install war3-data-parser  # 下载 0.34 MB ✅

# 传输时 (浏览器)
fetch('data_gzip/units_compressed.json.gz')  # 143 KB
# vs 原始
fetch('data/units.json')  # 4.2 MB

节省: 96% 下载量,25x 速度提升

📊 性能基准

| 操作 | 100次查询耗时 | |------|---------------| | 原始JSON | 26ms | | Gzip压缩 | 47ms |

*注: 首次加载需要解压,后续查询性能几乎相同


📦 包大小: 0.34 MB | 💾 压缩率: 95.5% | ⚡ 性能: 25x faster