# ac-registry

> ac-registry ===========

Latest version **1.0.0** (published 2017-04-09) · 0 weekly downloads

## Install

```sh
npm install ac-registry
pnpm add ac-registry
yarn add ac-registry
bun add ac-registry
```

## 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.0 |
| Published | 2017-04-09 |
| First published | 2017-04-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Oliver Leics |
| Maintainers | pureppl |

## Links

- npm: https://www.npmjs.com/package/ac-registry
- Repository: https://github.com/oleics/node-ac-registry
- Homepage: https://github.com/oleics/node-ac-registry#readme
- Issues: https://github.com/oleics/node-ac-registry/issues
- npm.io page: https://npm.io/package/ac-registry

## Dependencies (6)

- [cuid](https://npm.io/package/cuid.md) ^1.3.8
- [ac-log](https://npm.io/package/ac-log.md) ^1.0.0
- [ac-merge](https://npm.io/package/ac-merge.md) ^1.0.0
- [is-scalar](https://npm.io/package/is-scalar.md) ^1.0.0
- [pluralize](https://npm.io/package/pluralize.md) ^3.0.0
- [ac-is-array](https://npm.io/package/ac-is-array.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2017-04-09

## README

ac-registry
===========

Install
-------

```bash
npm install ac-registry --save
```

Usage Example
-------------

```js

// A single/global registry is the default.
var registry = require('ac-registy');

// Adds a new type 'foo'
function FooType(props) { this.bar = props.bar; }
registry.setType('foo', FooType);

// Creates an instance of type 'foo'
var id = registry.add({type:'foo', bar: 'baz'});

// Gets the instance with id
var foo = registry.get(id);

foo.type; // -> 'foo'
foo.id === id; // -> true
foo.bar; // -> 'baz'

```

### Relations between types

```js
var registry = require('ac-registy');

function FooType(props) {
  // Mixin the type 'bar'
  registry.mixin.call(this, 'bar');

  // Add all bars
  props.bars.forEach(this.addBar.bind(this));
}
registry.setType('foo', FooType);

function BarType(props) { this.baz = props.baz; }
registry.setType('bar', BarType);

var id = registry.add({
  type:'foo',
  bars: [{
    baz: 'buz'
  }]
});

var foo = registry.get(id);
foo.eachBar(function(bar){
  bar.type; // -> 'bar'
  bar.baz; // -> 'buz'
});

```

See tests for more.

Run Tests
---------

```bash
npm run test
```

MIT License
-----------

Copyright (c) 2016 Oliver Leics <oliver.leics@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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