Skip to content

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

Notifications You must be signed in to change notification settings

TiMESPLiNTER/pimple-js

Repository files navigation

pimple-js

Based on the work of

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published