Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
TiMESPLiNTER committed Jan 31, 2024
1 parent c63728a commit f97d300
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ and the original PHP Pimple container by Fabien Potencier.

## Usage

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

const container: Container = new Pimple({env: 'dev'});
type ServiceMap = {
'foo': string,
'bar': string,
};

container.set('foo', (container: Pimple) => {
return `bar (${container.get('env')})`;
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)';
Expand Down

0 comments on commit f97d300

Please sign in to comment.