<commit_before>hilary.js
========

Hilary is an easy to use JavaScript Inversion of Control (IoC) container written for Node.js and the browser.  Hilary's aim is to deliver low-ceremony dependency injection (DI), to aid in decoupling JavaScript modules and testing.  It's named after <NAME>, who designed building blocks that later became known as Legos.

You can find documentation and examples on our [wiki](https://github.com/Acatar/hilaryjs/wiki). Below is just a quick-start.

> Hilary 2.0 is not backwards compatible with previous versions of Hilary. We don't intend to release a backwards compatibility extension because v1 was in the wild for such a short time. If you already built a lot around v1, open an issue, and we will help you with compatibility/upgrades.

Creating your First Node App with Hilary
========
Install Hilary:

```
npm install hilary
```

In your startup file, require Hilary, create a new scope, and compose your app.

```JavaScript
// startup.js
"use strict";

var compose,
    start;

compose = function (scope) {
    scope.register({
        name: 'http',
        factory: function () {
            var isWin = /^win/.test(process.platform);
            
            if (isWin) {
                // take advantage of the httpsys performance enhancements
                return require('httpsys').http();
            } else {
                // otherwise, stick with the standard http module
                return require('http');
            }
        }
    });
    scope.register(require('./www.js'));
};

start = function () {
    var Hilary = require('hilary'),
        scope = Hilary.scope('app');
    
    compose(scope);
    scope.resolve('server');
};

start();

```

```JavaScript
// www.js
module.exports.name = 'server';
module.exports.dependencies = ['http'];
module.exports.factory = function (http) {
    "use strict";
    
    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('Hello World\n');
    }).listen(1337, '127.0.0.1');

    console.log('Server running at http://127.0.0.1:1337/');
    
    return http;
};
```

Creating your First Browser App with Hilary
========
Install Hilary (or you can download the source):

```
bower install hilary
```

Add a script reference to Hilary before you load your modules:

```HTML
<script src="hilary.min.js"></script>
```

Then register modules on a named scope, and finally compose your app:

```JavaScript
// myRouteEngine.js
Hilary.scope('spa').register({
    name: 'myRouteEngine',
    dependencies: ['myFactory'],
    factory: function (myFactory) {
        "use strict";

        // [CODE]
    }
});
```

```JavaScript
// bootstrapper.js
(function (spa) {
    "use strict";
    
    var compose;
    
    compose = function () {
        spa.register({
            name: 'myFactory',
            factory: function () {
                "use strict";

                // [CODE]
            }
        });
    };
    
    // start
    (function () {
        compose();
        spa.resolve('myRouteEngine');
    }());
    
}(Hilary.scope('spa')));
```<commit_msg>Adds comments and removes dependency declarations<commit_after>hilary.js
========

Hilary is an easy to use JavaScript Inversion of Control (IoC) container written for Node.js and the browser.  Hilary's aim is to deliver low-ceremony dependency injection (DI), to aid in decoupling JavaScript modules and testing.  It's named after Hilary Page, who designed building blocks that later became known as Legos.

You can find documentation and examples on our [wiki](https://github.com/Acatar/hilaryjs/wiki). Below is just a quick-start.

> Hilary 2.0 is not backwards compatible with previous versions of Hilary. We don't intend to release a backwards compatibility extension because v1 was in the wild for such a short time. If you already built a lot around v1, open an issue, and we will help you with compatibility/upgrades.

Creating your First Node App with Hilary
========
Install Hilary:

```
npm install hilary
```

In your startup file, require Hilary, create a new scope, and compose your app.

```JavaScript
// startup.js
"use strict";

var compose,
    start;

// Compose the dependency graph
// and register things like singletons
compose = function (scope) {
    var isWin = /^win/.test(process.platform),
        http;
            
    if (isWin) {
        // take advantage of the httpsys performance enhancements
        http =  require('httpsys').http();
    } else {
        // otherwise, stick with the standard http module
        http = require('http');
    }
    
    // register the http singleton
    scope.register({
        name: 'http',
        factory: function () {
            return http;        
        }
    });
    
    // register the exports from www.js
    scope.register(require('./www.js'));
};

start = function () {
    // create a scope for our application lifetime
    var Hilary = require('hilary'),
        scope = Hilary.scope('app');
    
    // compose the application lifetime
    compose(scope);
    
    // Usually, resolving module(s) will result in 
    // your application starting up
    scope.resolve('server');
};

// Start the app
start();

```

```JavaScript
// www.js
module.exports.name = 'server';
module.exports.factory = function (http) {
    "use strict";
    
    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('Hello World\n');
    }).listen(1337, '127.0.0.1');

    console.log('Server running at http://127.0.0.1:1337/');
    
    return http;
};
```

Creating your First Browser App with Hilary
========
Install Hilary (or you can download the source):

```
bower install hilary
```

Add a script reference to Hilary before you load your modules:

```HTML
<script src="hilary.min.js"></script>
```

Then register modules on a named scope, and finally compose your app:

```JavaScript
// myRouteEngine.js
Hilary.scope('spa').register({
    // other modules can depend on this one by name
    name: 'myRouteEngine',
    // Hilary will try to resolve myFactory by looking for registrations by that name
    factory: function (myFactory) {
        "use strict";

        console.log(myFactory);
    }
});
```

```JavaScript
// bootstrapper.js
(function (spa) {
    "use strict";
    
    var compose;
    
    // Compose the dependency graph
    // and register things like singletons
    compose = function () {
        var singleton = 'hello world!';
        
        spa.register({
            // other modules can depend on this one by name
            name: 'myFactory',
            // Parameterless factories are executed when being 
            // resolved. The result of this function will be passed 
            // to any factories that depend on myFactory.
            factory: function () {
                "use strict";

                return singleton;
            }
        });
    };
    
    // start
    (function () {
        // Compose the application
        compose();
        
        // Usually, resolving module(s) will result in 
        // your application starting up
        spa.resolve('myRouteEngine');
    }());
    
}(Hilary.scope('spa')));
```
{'fraction_non_alphanumeric': 0.1214759535655058, 'fraction_numerical': 0.007462686567164179, 'mean_word_length': 2.496135265700483, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2508098', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1988, 'n_words': 719}