Based on the work of
- M.PARAISO [email protected]
- SerafimArts [email protected]
and the original PHP Pimple container by Fabien Potencier.
import Pimple from '@timesplinter/pimple';
type ServiceMap = {
'foo': string,
'bar': string,
};
const container: Container = new Pimple<ServiceMap>({env: 'dev'});
container.set('foo', () => {
return `baz (${container.get('env')})`;
});
container.set('bar', (container: Pimple<ServiceMap>) => {
return `bar: ${container.get('foo')}`;
});
console.log(container.get('foo')); // 'bar (dev)';
$ npm run transpile
$ npm run test # runs tests
$ npm run coverage # runs coverage