@timesplinter/pimple
v2.0.0
Published
A simple dependency-injection container written in TypeScript based on PHP's Pimple
Downloads
9
Readme
pimple-js
Based on the work of
- M.PARAISO [email protected]
- SerafimArts [email protected]
and the original PHP Pimple container by Fabien Potencier.
Usage
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)';
Transpiling
$ npm run transpile
Tests
$ npm run test # runs tests
$ npm run coverage # runs coverage