# tinbin

> A simple container, can be used for simplified runtime DI

Latest version **2.2.0** (published 2019-04-20) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2019-04-20 |
| First published | 2018-07-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Bojan Matić |
| Maintainers | moljac024 |

## Links

- npm: https://www.npmjs.com/package/tinbin
- Repository: https://github.com/moljac024/tinbin
- npm.io page: https://npm.io/package/tinbin

## Dependencies (1)

- [lodash.isfunction](https://npm.io/package/lodash.isfunction.md) ^3.0.9

## Recent versions

- 2.2.0 (latest) — 2019-04-20
- 2.1.0 — 2019-04-14
- 2.0.0 — 2018-10-26
- 1.0.3 — 2018-07-03
- 1.0.2 — 2018-07-03
- 1.0.1 — 2018-07-02
- 1.0.0 — 2018-07-02

## README

Very simple data bag.

You can put into and grab stuff from it. It's original use-case was to be a
simple DI Container that can be used for run-time dynamic dependencies. It is a
mutable container (and a thin wrapper around a simple object) so please use it
with care.

### Install

```console
$ npm install tinbin
```

### Usage

```js
import Tinbin from 'tinbin'

const container = Tinbin({
  errorOnMissing: false,
})

container.put("foo", "bar")

container.get("foo") // bar
container.get("baz") // undefined
container.remove("foo")
container.get("foo") // undefined
```

## API

### Tinbin([options])

Returns a container instance.

#### options

Type: `Object`

##### errorOnMissing

Type: `boolean`<br>
Default: `true`

When true, will throw error on requesting a key with no value. Otherwise returns undefined.

#### onChange

Type: `Function`

Function to be invoked when data in container is changed (either put or remove
is called). Function is called with two parameters - (key, value). If key was
removed, value is undefined.

## Instance API

### container.get(key)

Returns the value for key. If key does not
exist in container and it was made with `({errorOnMissing: true})` this function
will throw an error. Otherwise it will return undefined.

#### key

Type: `String`

Key must be a string, as it needs to be valid key for object. In a future
version container might move to using Map instead of object under the hood,
which should allow for arbitrary keys.

### container.put(key, value)

Store value under `key`. Successive get calls will see this value.

#### key

Type: `String`

#### value

Type: `Any`

### container.remove(key)

Remove the key and value associated it with it from the container.

#### key

Type: `String`

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