Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/timesplinter/pimple-js

A simple DIC written in TypeScript based on PHP's Pimple
https://github.com/timesplinter/pimple-js

Last synced: 29 days ago
JSON representation

A simple DIC written in TypeScript based on PHP's Pimple

Awesome Lists containing this project

README

        

# pimple-js

Based on the work of

* M.PARAISO
* SerafimArts

and the original PHP Pimple container by Fabien Potencier.

## Usage

```ts
import Pimple from '@timesplinter/pimple';

type ServiceMap = {
'foo': string,
'bar': string,
};

const container: Container = new Pimple({env: 'dev'});

container.set('foo', () => {
return `baz (${container.get('env')})`;
});

container.set('bar', (container: Pimple) => {
return `bar: ${container.get('foo')}`;
});

console.log(container.get('foo')); // 'bar (dev)';
```

## Transpiling
```bash
$ npm run transpile
```

## Tests
```bash
$ npm run test # runs tests
$ npm run coverage # runs coverage
```