Skip to content
/ conr Public

small and loose dependency injection library

License

Notifications You must be signed in to change notification settings

sovrin/conr

Repository files navigation

conr

npm version types size coverage vulnerabilities dependencies License

small and loose dependency injection library

Installation

$ npm i conr

Usage

import conr from 'conr';

type Container = {
    foo: string;
    bar: string;
    name: (name: string) => string;
}

const instance = conr<Container>();
instance.init({
    foo: 'Hello',
    bar: 'World',
    name: () => ``
});

instance.set('name', (name) => `My name is ${name}.`);

instance.resolve((foo, bar) => {
    console.log(foo, bar); // Hello, World
});

instance.resolve(async function ({foo, name}) {
    console.log(foo, name('John Doe')); // Hello, My name is John Doe.
    console.log(this) // {fizz: "buzz"}
}, {fizz: "buzz"})

Licence

MIT License, see LICENSE

About

small and loose dependency injection library

Resources

License

Stars

Watchers

Forks

Packages

No packages published