<commit_before>## Information

<table>
<tr>
<td>Package</td><td>macrojs</td>
</tr>
<tr>
<td>Description</td>
<td>Macros for nodejs</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.4</td>
</tr>
</table>

## Usage

### Defining macros

You only need to define your macros and use register() once when your app starts

```coffee-script
macros = require 'macro'
macro.add 'debug', (node) ->
  out = "console.log('Debug at line #{node.line}')\r\n"
  out += "console.trace()"
  return out

macro.add 'topload', (path, node) -> "require('../#{path}')"
macro.add 'lrequire', (path, node) -> "require('./#{path}')"
macro.add 'add', (numone, numtwo, node) -> String numone + numtwo
```

will replace

```javascript
var appcfg = topload('config');
var dbcfg = lrequire('db_config');
var sum = add(1, 3);
debug();
```

with

```javascript
var appcfg = require("../config");
var dbcfg = require("./db_config");
var sum = 4;
console.log("Debug at line 3");
console.trace();
```

### Raw input

Pass in a string of JS, get out a string of transformed JS.

```coffee-script
macros = require 'macro'
fs = require 'fs'
# Define your macros here

input = fs.readFileSync "coolinput.js"
output = macros.run input
fs.writefileSync output, "coolinput.out.js"
```

### Registering files

All files loaded with require() will be passed through the macro transformer before being loaded.

```coffee-script
macros = require 'macro'
macros.register()
# Define your macros here
```
## Examples<commit_msg>fix code examples<commit_after>## Information

<table>
<tr>
<td>Package</td><td>macrojs</td>
</tr>
<tr>
<td>Description</td>
<td>Macros for nodejs</td>
</tr>
<tr>
<td>Node Version</td>
<td>>= 0.4</td>
</tr>
</table>

## Usage

### Defining macros

You only need to define your macros and use register() once when your app starts

```coffee-script
macro = require 'macro'
macro.add 'debug', (node) ->
  out = "console.log('Debug at line #{node.line}')\r\n"
  out += "console.trace()"
  return out

macro.add 'topload', (path, node) -> "require('../#{path}')"
macro.add 'lrequire', (path, node) -> "require('./#{path}')"
macro.add 'add', (numone, numtwo, node) -> String numone + numtwo
```

will replace

```javascript
var appcfg = topload('config');
var dbcfg = lrequire('db_config');
var sum = add(1, 3);
debug();
```

with

```javascript
var appcfg = require("../config");
var dbcfg = require("./db_config");
var sum = 4;
console.log("Debug at line 3");
console.trace();
```

### Raw input

Pass in a string of JS, get out a string of transformed JS.

```coffee-script
macro = require 'macro'
fs = require 'fs'
# Define your macros here

input = fs.readFileSync "coolinput.js"
output = macro.run input
fs.writefileSync output, "coolinput.out.js"
```

### Registering files

All files loaded with require() will be passed through the macro transformer before being loaded.

```coffee-script
macro = require 'macro'
macro.register()
# Define your macros here
```
## Examples
{'fraction_non_alphanumeric': 0.18379111563241776, 'fraction_numerical': 0.004069175991861648, 'mean_word_length': 4.555555555555555, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 53, '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': '4274889', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1006, 'n_words': 327}