<commit_before># requirejs-config-file

A small api to read and write your requirejs config file

## installation

```
npm install requirejs-config-file
```

## usage

```js
var ConfigFile = require('requirejs-config-file').ConfigFile;
```

<!-- example1 -->
```js
var configFile = new ConfigFile('path/to/some/requirejs-config.js'));

configFile.read(function(err, config) {
  if (err) throw 'Something went really wrong: '+err.toString();

  console.log(config); // is an object with the found config
});
```<commit_msg>add more examples to readme<commit_after># requirejs-config-file

A small api to read and write your requirejs config file

## installation

```
npm install requirejs-config-file
```

## usage

### require the constructor
```js
var ConfigFile = require('requirejs-config-file').ConfigFile;
```

### read
```js
// Read: reading the config
var configFile = new ConfigFile('path/to/some/requirejs-config.js'));

configFile.read(function(err, config) {
  if (err) throw 'Something went really wrong: '+err.toString();

  console.log(config); // is an object with the found config
});
```

### modify (read and write)
```js
// Modify: reading and writing the config
var configFile = new ConfigFile('path/to/some/requirejs-config.js'));

configFile.read(function(err, config) {
  if (err) throw 'Something went really wrong: '+err.toString();

  config.baseUrl = '/new';

  configFile.write(function(err, config) {
    if (err) throw 'Cannot write the config'+err;
  });
});
```

### create
```js
// CreateExample: creating a new config file
var configFile = new ConfigFile('path/to/new-config.js'));

configFile.createIfNotExists();

configFile.write(function(err, config) {
  if (err) throw 'Cannot write the config'+err;
});
```

### create or modify
```js
// CreateAndModifyExample: reading and writing a maybe not existing config file
var configFile = new ConfigFile('path/to/new-config.js'));

configFile.createIfNotExists();

configFile.read(function(err, config) {
  if (err) throw 'Something went really wrong: '+err.toString();

  config.baseUrl = '/new';

  configFile.write(function(err, config) {
    if (err) throw 'Cannot write the config'+err;
  });
});
```
{'fraction_non_alphanumeric': 0.1566925536774783, 'fraction_numerical': 0.00045682960255824577, 'mean_word_length': 4.688311688311688, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2664815', 'n_tokens_mistral': 694, 'n_tokens_neox': 663, 'n_words': 204}