<commit_before># mokuai

> Write pure JavaScript modules, without any concern about concatenation order and require calls.

[![Build Status](https://travis-ci.org/JimRobs/mokuai.svg)](https://travis-ci.org/JimRobs/mokuai)

## Description

CommonJS is awesome for external libraries, but not perfect when you want to split you own application in modules.

For example, want to use your awesome `utils` module in every file but keep your global var clean ? You need to
require your `utils` module in every file:

```js
// If you are in the same directory
var utils = require('./utils');
utils.doAnAwesomeJob();
```

```js
// If you're not, it can be unpleasant
var utils = require('./../../../../../utils');
utils.doAnAwesomeJob();
```

What about making `utils` module, and all your application modules, directly accessible from any of them. Well, Mokuai
makes it possible.

```js
// Do not need to require it, just use it
utils.doAnAwesomeJob();
```

Your module does not have a pleasant var name ? No problem, all modules are accessible from the `modules` keyword.

```js
modules['my-awesome-utils-function'].doAnAwesomeJob();
```

### How does it work ?

Mokuai wraps your modules into a special closure.

All modules are saved in a `modules` object, and are refered with a special `getter` which initializes your module when
it is first called, just like a `require` call.

To be easily accessed anywhere, all your modules are declared in a ~~evil~~ powerful **with** statement and it works
like magic.

The only limit is that your modules names have to be unique. Everything else is possible.

### Module declaration

Each module exports its value just like in CommonJS:

With `module.exports`

```js
var utils = {
    doAnAwesomeJob: function(){
        // ... do something awesome
    },
    // ...
};
// ...
module.exports = utils;
```<commit_msg>Remove useless comment on with statement.<commit_after># mokuai

> Write pure JavaScript modules, without any concern about concatenation order and require calls.

[![Build Status](https://travis-ci.org/JimRobs/mokuai.svg)](https://travis-ci.org/JimRobs/mokuai)

## Description

CommonJS is awesome for external libraries, but not perfect when you want to split you own application in modules.

For example, want to use your awesome `utils` module in every file but keep your global var clean ? You need to
require your `utils` module in every file:

```js
// If you are in the same directory
var utils = require('./utils');
utils.doAnAwesomeJob();
```

```js
// If you're not, it can be unpleasant
var utils = require('./../../../../../utils');
utils.doAnAwesomeJob();
```

What about making `utils` module, and all your application modules, directly accessible from any of them. Well, Mokuai
makes it possible.

```js
// Do not need to require it, just use it
utils.doAnAwesomeJob();
```

Your module does not have a pleasant var name ? No problem, all modules are accessible from the `modules` keyword.

```js
modules['my-awesome-utils-function'].doAnAwesomeJob();
```

### How does it work ?

Mokuai wraps your modules into a special closure.

All modules are saved in a `modules` object, and are refered with a special `getter` which initializes your module when
it is first called, just like a `require` call.

To be easily accessed anywhere, all your modules are declared in a **with** statement and it works
like magic.

The only limit is that your modules names have to be unique. Everything else is possible.

### Module declaration

Each module exports its value just like in CommonJS:

With `module.exports`

```js
var utils = {
    doAnAwesomeJob: function(){
        // ... do something awesome
    },
    // ...
};
// ...
module.exports = utils;
```
{'fraction_non_alphanumeric': 0.11108122646584186, 'fraction_numerical': 0.0, 'mean_word_length': 3.836150845253576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '2780675', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1028, 'n_words': 489}