<commit_before>node-wad
========

Manipulate rock raiders WAD files from nodejs<commit_msg>readme updates<commit_after># node-wad

Manipulate rock raiders WAD files with ease.

## Command line utility

### Installation

```sh
npm install -g wad
```

### Extracting

```sh
wad -x LegoRR0.wad -o LegoRR0
```

### Compressing

```sh
wad -c LegoRR1 -o LegoRR1.wad
```

## Node.js library

### Installation

```sh
npm install wad
```

### Usage

```javascript
var WAD = require('wad');
```

### Getting an instance

#### `WAD.load(path, cb)`

Load an WAD archive into an `WAD` instance.

- `path`: Path to a WAD archive
- `cb`: Callback that gets called with `err` and `wad`

#### `new WAD()`

Create a new, empty, `WAD` instance.

### Using an instance

#### `.add(path, data)`

Adds an object to the archive.

- `path`: The internal path (e.g. `Languages/ObjectiveText.txt`)
- `data`: Description on how to acquire the data

The `data` parameter currently only accepts this syntax:

```javascript
{
  type: 'file',
  path: 'mods/Lego.cfg'
}
```

#### `.forEach(fn)`

Runs `fn` on every object in the archive.

- `fn`: Function that gets called for every object

The objects that gets passed to `fn` currently has the following attributes:

- `.path`: The internal path
- `.data(cb)`: Fetch the data as a buffer

#### `.save(path, cb)`

Saves the archive to a WAD file.

- `path`: The output path
- `cb`: Callbacks that gets called with `err` and `bytesWritten`

`bytesWritten` is the final size of the archive.
{'fraction_non_alphanumeric': 0.1519575315195753, 'fraction_numerical': 0.0026542800265428003, 'mean_word_length': 3.9281045751633985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5720097', 'n_tokens_mistral': 553, 'n_tokens_neox': 523, 'n_words': 196}