
<!-- markdownlint-disable line-length -->

# depend on me

> General purpose dependency container

<!-- MarkdownTOC levels="1,2,3" autolink="true" indent="  " -->

- [Install](#install)
- [Use](#use)
- [Develop](#develop)
- [Changelog](#changelog)
  - [0.2.0 - 15 October 2018](#020---15-october-2018)

<!-- /MarkdownTOC -->

## Install

```bash
npm i --save-exact @leeruniek/depend-on-me
```

## Use

```js
// plugins/thing.plugin.js
module.exports = {
  create: () =>
    new Promise(resolve => {
      setTimeout(() => {
        resolve({
          foo: "bar",
        })
      }, 50)
    }),
}

// plugins/something.plugin.js
module.exports = {
  depend: ["Thing"],

  // First "Thing" resolves to { foo: "bar" } and then continue with create
  create: Thing => ({
    lorem: `ipsum ${Thing.foo}`,
  }),
}

// index.js
const path = require("path")
const depend = require("@leeruniek/depend-on-me")

depend-on-me({
  folders: path.join(__dirname, "plugins"),
}).then(({ Thing, Something }) => {
  // {
  //   Thing: { foo: 'bar' },
  //   Something: { lorem: 'ipsum bar' }
  // }
})
```

## Develop

```bash
git clone git@github.com:leeruniek/depend-on-me.git && \
  cd depend-on-me && \
  npm run setup

# run tests (any `*.test.js`) once
npm test

# watch `src` folder for changes and run test automatically
npm run tdd
```

## Changelog

History of all changes in [CHANGELOG.md](/CHANGELOG.md)

### 0.2.0 - 15 October 2018

#### Change

- Update packages, use prettier for formating
- Changed `files` param to also accept an array of either string or regular expressions. Duplicate files are deleted.
- Rename `root` param to `folders`. Accept more than one folder where to scan for files.
