# canister

> A minimalist Dependency Injection container.

Latest version **2.0.3** (published 2016-09-15) · BSD-3-Clause license · 0 weekly downloads

## Install

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

## 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 | 2.0.3 |
| Published | 2016-09-15 |
| First published | 2015-03-21 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | allain |
| Maintainers | allain |
| Keywords | dependency injection |

## Links

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

## Dependencies (2)

- [lie](https://npm.io/package/lie.md) ^3.1.0
- [any-promise](https://npm.io/package/any-promise.md) ^1.3.0

## Recent versions

- 2.0.3 (latest) — 2016-09-15
- 2.0.1 — 2016-09-14
- 1.7.4 — 2016-09-11
- 1.7.3 — 2016-09-11
- 1.7.2 — 2016-09-11
- 1.7.1 — 2016-09-10
- 1.7.0 — 2016-09-09
- 1.6.0 — 2015-08-24
- 1.5.0 — 2015-08-22
- 1.3.4 — 2015-08-22
- 1.3.3 — 2015-08-21
- 1.3.2 — 2015-08-20
- 1.2.0 — 2015-08-18
- 1.1.0 — 2015-04-06
- 1.0.2 — 2015-03-21
- … 2 more at https://npm.io/package/canister/versions

## README

# canister

A minimalist Dependency Injection container.

[![build status](https://secure.travis-ci.org/allain/canister.png)](http://travis-ci.org/allain/canister)

## Installation

This module is installed via npm:

```sh
npm install canister
```

##  Example Usage

```JavaScript
var Canister = require('canister');

// Simple canister
var canister = new Canister(function(name) {
  if (name === 'a') return [1,2];
  if (name === '_') return require('lodash');
}};

// Run synchronous function
canister.run(function(a, _) {
  return _.sum(a);
}, function(err, sum) {
  console.log(sum);
});

// Run Asynchronous function
canister.run(function(a, cb) {
  cb(null, a);
}, function(err, val) {
  console.log(val);
});

// Canister with multiple resolvers with multiple types (hash, and resolver function)
var canister2 = new Canister([{a: 10}, function(name) {
  if (name === 'b') return 'B';
}]);

canister2.run(function(a, b) {
  console.log(a, b);
});
```

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