https://github.com/parro-it/require-props
Require a set of modules, and add them as properties to target.
https://github.com/parro-it/require-props
Last synced: 10 months ago
JSON representation
Require a set of modules, and add them as properties to target.
- Host: GitHub
- URL: https://github.com/parro-it/require-props
- Owner: parro-it
- License: mit
- Created: 2015-11-07T10:51:40.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-10T20:53:56.000Z (about 10 years ago)
- Last Synced: 2024-10-12T01:17:53.323Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# require-props
Require a set of modules, and add them as properties to target.
[](https://npmjs.org/package/require-props)
[](https://npmjs.org/package/require-props)
## Installation
```bash
npm install --save require-props
```
## Usage
```javascript
const requireProps = require('require-props')(__dirname);
const target = {name:'target'};
requireProps(target, ['./fixtures/module1', './fixtures/module-2']);
console.dir(target);
// { name: 'target', module1: 1, 'module-2': 'target' }
```
Each required modules must export a function receiving the app instance and returning an object that is then added as a property
on the app instance, named as the modules itself.
## Api
requireProps(target, modules)
* target: object - object where all properties are created
* modules: array - list of modules to requires. They could be module names or relative paths.
## License
The MIT License (MIT)
Copyright (c) 2015 Andrea Parodi