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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wow-dbcfile-node

v1.0.3

Published

Node.js module for working with World of Warcraft DBC files

Downloads

16

Readme

WoWDBC-Node 🎮

WoWDBC-Node is a high-performance Node.js package for reading and manipulating World of Warcraft DBC (Database Client) files. 🚀

📋 Table of Contents

🌟 Features

  • Fast reading and writing of DBC files
  • CRUD operations for DBC records
  • Node.js-friendly interface with field name access
  • Efficient C++ addon for optimal performance

💻 Installation

Install the package using npm:

npm install wowdbc-node

Or using yarn:

yarn add wowdbc-node

📚 Usage

Here's a quick example of how to use WoWDBC-Node:

import { WoWDBCFile } from 'wow-dbcfile-node';

// Correct field definitions for the Item.dbc file
const fieldDefinitions = {
  id: 'uint32',
  class: 'uint32',
  subclass: 'uint32',
  sound_override_subclass: 'int32',
  material: 'uint32',
  displayid: 'uint32',
  inventory_type: 'uint32',
  sheath_type: 'uint32'
};

// Open the Item.dbc file
const dbc = new WoWDBCFile('path/to/your/Item.dbc', fieldDefinitions);
dbc.read();

// Find a specific item (e.g., Warglaive of Azzinoth, ID: 32837)
const warglaive = dbc.findBy('id', 32837)[0];
console.log("Warglaive of Azzinoth:", warglaive);

// Update a single field of the Warglaive
dbc.updateRecord(warglaive.id, 'sheath_type', 3);  // Assuming 3 represents a different sheath type

// Update multiple fields of the Warglaive
dbc.updateRecordMulti(warglaive.id, { material: 5, inventory_type: 17 });  // Assuming 5 is a different material and 17 is Two-Hand

// Create a new empty item record
const newItemIndex = dbc.createRecord();
console.log("New empty item index:", newItemIndex);

// Create a new item record with initial values
const initialValues = {
  id: 99999,
  class: 2,  // Weapon
  subclass: 7,  // Warglaives
  sound_override_subclass: -1,  // No override
  material: warglaive.material,
  displayid: warglaive.displayid,
  inventory_type: 17,  // Two-Hand
  sheath_type: 3
};
const newItemIndexWithValues = dbc.createRecordWithValues(initialValues);
console.log("New custom item index:", newItemIndexWithValues);

// Read the newly created item
const newItem = dbc.getRecord(newItemIndexWithValues);
console.log("Newly created item:", newItem);

// Write changes back to the same file (update)
dbc.write();

// Write to a new file
dbc.writeTo('path/to/your/NewItem.dbc');

// Reading header information
const header = dbc.header;
console.log("Total items:", header.record_count);
console.log("Fields per item:", header.field_count);

// Finding all two-handed weapons
const twoHandedWeapons = dbc.findBy('inventory_type', 17);  // 17 represents Two-Hand weapons

console.log('Two-handed weapons:');
twoHandedWeapons.forEach(item => {
  const { value, index } = item;
  console.log(`Item ID: ${value.id}, Class: ${value.class}, Subclass: ${value.subclass}, Display ID: ${value.displayid}`);
});

📚 API

WoWDBCFile class

Constructor: new WoWDBCFile(filename, fieldDefinitions)

  • filename: Path to the DBC file
  • fieldDefinitions: Object defining the structure of the DBC file

Methods

  • read(): Read the DBC file
  • write(): Write changes back to the original file
  • writeTo(filename): Write to a new file
  • createRecord(): Create a new empty record
  • createRecordWithValues(values): Create a new record with initial values
  • updateRecord(index, field, value): Update a single field of a record
  • updateRecordMulti(index, updates): Update multiple fields of a record
  • getRecord(index): Get a record by its index
  • findBy(field, value): Find records by field value
  • getHeader(): Get the DBC file header information

🛠️ Development

To set up the project for development:

  1. Clone the repository:

    git clone https://github.com/yourusername/wowdbc-node.git
    cd wowdbc-node
  2. Install dependencies:

    npm install
  3. Build the Node.js addon:

    npm run build

🧪 Testing

To run the tests:

npm test

The tests use Mocha as the test runner and Chai for assertions.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.

🙏 Acknowledgements

  • Inspired by the World of Warcraft modding community
  • All contributors who have helped with code, bug reports, and suggestions

Happy coding, and may your adventures in Azeroth be bug-free! 🐉✨