# radford

> A service container and dependency manager for your application

Latest version **0.0.6** (published 2016-03-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install radford
pnpm add radford
yarn add radford
bun add radford
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2016-03-25 |
| First published | 2016-03-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Shawn Dellysse |
| Maintainers | sdellysse |
| Keywords | service, dependency-injection, container |

## Links

- npm: https://www.npmjs.com/package/radford
- Repository: https://github.com/shawndellysse/radford
- Homepage: https://github.com/shawndellysse/radford#readme
- Issues: https://github.com/shawndellysse/radford/issues
- npm.io page: https://npm.io/package/radford

## Dependencies (1)

- [clone](https://npm.io/package/clone.md) 1.0.2

## Recent versions

- 0.0.6 (latest) — 2016-03-25
- 0.0.5 — 2016-03-25
- 0.0.4 — 2016-03-25
- 0.0.3 — 2016-03-25
- 0.0.2 — 2016-03-10
- 0.0.1 — 2016-03-02

## README

# Radford: a service container and dependency injector for your application

### Installation ###

```javascript
npm install radford
```

### Description ###

Radford is a lightweight service container for managing initialization and
dependencies inside your app. Each service can request other services, and
service can take optional arguments. This allows the components of your
application to stay uncoupled from one another and Radford will build the
service graph for you.

### Usage ###

```javascript
import Radford from "radford";
import { native: pgnative } from "pg";
import wrap from "pg.promised";

const cache = {};
const radford = new Radford({
    definitions: {
        db: {
            dependencies: [
                ["logger", {
                    name: "db",
                }],
            ],

            create: ({ logger }, {}) => {
                if (!cache.db) {
                    cache.db = wrap(pgnative);
                }

                return cache.db;
            },
        },

        logger: {
            create: ({}, { name }) {
                cache.logger = cache.logger || {};

                if (!cache.logger[name]) {
                    cache.logger[name] = function (...messages) {
                        console.log(`[${ name.toUpperCase() }]`, ...messages);
                    };
                }

                return cache.logger[name];
            },
        },
    },
});

const { db } = radford.invoke("db");

db.query() //...
```

---
_Source: https://npm.io/package/radford · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
