linkshare/service-container — pull request #1 by hshiraishi (2013-08-27 16:12:35+00:00)
Title: container should return the same instance is a service is a singleton

Correct me if I'm wrong...if a service is marked as "isSingleton: true", then multiple calls to container.get() should return the same instance, but it is not.

You can try below -

My services.json:
```
{
"parameters": {
"my_singleton_service.class": "./MySingletonService"
},
"services": {
"my_singleton_service": {
"class": "%my_singleton_service.class%",
"isSingleton": true
}
}
}
```

My singleton class (MySingletonService.js):
```
var MySingletonService = function () {
this.buffer = [];
}

MySingletonService.prototype.addSomething = function (something) {
this.buffer.push(something);
}

MySingletonService.prototype.getWhatYouHave = function () {
return this.buffer;
}

module.exports = MySingletonService;
```

My test script (test_service_container.js):
```
var ServiceContainer = require('service-container');
var container = ServiceContainer.buildContainer(__dirname);

var obj1 = container.get('my_singleton_service');
obj1.addSomething('a');

// here obj2 should actually point to the same instance as obj1
var obj2 = container.get('my_singleton_service');
obj2.addSomething('b');

console.log("obj1 has: " + JSON.stringify(obj1.getWhatYouHave()));
console.log("obj2 has: " + JSON.stringify(obj2.getWhatYouHave()));
```

The output is:
```
obj1 has: ["a"]
obj2 has: ["b"]
```

Whereas, I think it should be:
```
obj1 has: ["a","b"]
obj2 has: ["a","b"]
```