<commit_before>#Inverted

Inverted is Javascript Inversion of Control container. 

It manages dependency injection and dependency management, automatically loading scripts which cannot be resolved. Its aim is to make large Javascript applications easier to manage and higher quality, encouraging code modularisation, separations of concerns and good unit testing pratices.

Inverted is just 2.39KB minified and GZipped.

The core of a Javascript application that uses Inverted is the application configuration. Application configuratin is written in Javascript and wires the application together. It mainly consists of proto definitions. Protos are prototypal objects designed to be constructed using the _new_ keyword. In classical terms, Javascript classes and like _beans_ in Spring IOC for Java.

```javascript
var applicationConfig = {
	protos: {
		"protoId" : {
			proto: "namespace.Constructor",
			//other config
		},
		"anotherProtoId" : {
			proto: "namespace.Constructor",
			//other config
		}
	}
}
```

Inverted defines one global function _AppContext_. Which can be called using the application configuration as an argument to create an Application Context object.

```javascript
var appContext = AppContext(applicationConfig)
```

Protos defined in the application configuration can then be retrieved using the _getProto_ function passing _n_ proto definition id's and a callback with _n_ arguments, one for each instance of a proto instantiated:

```javascript
appContext.getProto("myProto", function(myProto) {
	myProto.doStuff();
});
appContext.getProto("myProto", "myProto2", "myProtoN", function(myProto, myProto2, myProtoN) {
	myProto.doStuff();
	myProto2.doStuff();
	myProtoN.doStuff();
});
```

Only one AppContext per application should be created per application. It is not a singleton.

This file explains the core concepts of Inverted by example. Most examples show the application code consisting of the proto implementations, the application configuration and example usage of the Inverted container.

###Road map

* Inverted is currently only built to run in the browser. Node support also needed.
* ...


##Examples

###Instantiation
A simple example of using the Inverted container to construct an instance of an  object. In this simple example the result is the eqivalent of using the new keyword. i.e. 

```javascript
var myObj = new MyObj();
myObj.callMe();
```

But no explicit type is referenced when actually getting the instance using the container.

```javascript
<commit_msg>Edited README.md via GitHub<commit_after>#Inverted

Inverted is Javascript Inversion of Control container. 

It manages dependency injection and dependency management, automatically loading scripts which cannot be resolved. Its aim is to make large Javascript applications easier to manage and higher quality, encouraging code modularisation, separations of concerns and good unit testing pratices.

Inverted is just 2.39KB minified and GZipped.

The core of a Javascript application that uses Inverted is the application configuration. Application configuratin is written in Javascript and wires the application together. It mainly consists of proto definitions. Protos are prototypal objects designed to be constructed using the _new_ keyword. In classical terms, Javascript classes and like _beans_ in Spring IOC for Java.

```javascript
var applicationConfig = {
	protos: {
		"protoId" : {
			proto: "namespace.Constructor",
			//other config
		},
		"anotherProtoId" : {
			proto: "namespace.Constructor",
			//other config
		}
	}
}
```

Inverted defines one global function _AppContext_. Which can be called using the application configuration as an argument to create an Application Context object.

```javascript
var appContext = AppContext(applicationConfig)
```

Protos defined in the application configuration can then be retrieved using the _getProto_ function passing _n_ proto definition id's and a callback with _n_ arguments, one for each instance of a proto instantiated:

```javascript
appContext.getProto("myProto", function(myProto) {
	myProto.doStuff();
});
appContext.getProto("myProto", "myProto2", "myProtoN", function(myProto, myProto2, myProtoN) {
	myProto.doStuff();
	myProto2.doStuff();
	myProtoN.doStuff();
});
```

Only one AppContext per application should be created per application. It is not a singleton.

This file explains the core concepts of Inverted by example. Most examples show the application code consisting of the proto implementations, the application configuration and example usage of the Inverted container.

###Road map

* Inverted is currently only built to run in the browser. Node support also needed.
* Add 'static' scope, for injecting objects which are not instances
* 


##Examples

###Instantiation
A simple example of using the Inverted container to construct an instance of an  object. In this simple example the result is the eqivalent of using the new keyword. i.e. 

```javascript
var myObj = new MyObj();
myObj.callMe();
```

But no explicit type is referenced when actually getting the instance using the container.

```javascript

{'fraction_non_alphanumeric': 0.06417530815887301, 'fraction_numerical': 0.002347877127763647, 'mean_word_length': 4.964994165694282, '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': '5638434', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1239, 'n_words': 637}