# liim

> Liim: a tiny service container for JavaScript

Latest version **1.0.2** (published 2020-03-15) · BSD-3-Clause license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-03-15 |
| First published | 2019-05-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Becklyn Studios |
| Maintainers | apfelbox, keichinger |
| Keywords | becklyn, dependency-injection, di, library, service-container, tiny |

## Links

- npm: https://www.npmjs.com/package/liim
- Repository: https://github.com/Becklyn/liim
- Issues: https://github.com/Becklyn/liim/issues
- npm.io page: https://npm.io/package/liim

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-03-15
- 1.0.1 — 2019-05-02
- 1.0.0 — 2019-05-02
- 0.0.1 — 2019-05-02

## README

Liim
====

A tiny service container.

One of the goals is for `liim` to be as small and fast as possible. It is not supposed to include all possible features. If you need to enhance it with additional features, you can extend the instance and add the functionality on top.

Right now it is ~380B minifed and ~230B gzipped.


Usage
-----


### Registering Services

Create the service container:

```js
import Liim from "liim";

let liim = new Liim();
```

A service can either be any value or a function which will create the dependency:

```js
liim.set("hello", new MyService);

// create the service lazily
liim.set("ohai", (liim) => {
    return new ServiceWithDependencies(liim.get("a"), liim.get("b"));
});
```

Services with a service factory function will only be created when the service is fetched for the first time. Also they will only be created once, as the instance is reused.


### Fetching Services

You can get services using the `.get()` method:

```js
liim.get<Service>("service-name");
```

This method will throw if the service is missing. If the service is an optional requirement
for your app, you should check on existence with

```js
if (liim.has("service-name"))
{
    // service is defined
}
```

beforehand.

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