Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iguntur/req-prop
Require property from `cwd`. Get, extend, destroy property using dot-notation
https://github.com/iguntur/req-prop
Last synced: about 11 hours ago
JSON representation
Require property from `cwd`. Get, extend, destroy property using dot-notation
- Host: GitHub
- URL: https://github.com/iguntur/req-prop
- Owner: iguntur
- License: mit
- Created: 2016-12-27T18:30:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-27T23:19:23.000Z (almost 8 years ago)
- Last Synced: 2024-09-23T02:48:19.162Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# req-prop [![Build Status](https://travis-ci.org/iguntur/req-prop.svg?branch=master)](https://travis-ci.org/iguntur/req-prop)
> Easy require property from `cwd`. Get, extend, destroy property using dot-notation
## Install
```
$ npm install --save req-prop
```## Usage
> Imagine the folder structure like this.
```
├── code
│ └── dev-app
│ │ ├── config/setting.js
│ │ ├── lib/database/api/v1/index.js
│ │ ├── index.js
│ │ └── package.json
``````js
// ~/code/dev-app/config/setting.js
module.exports = {
app: {
name: 'unicorn'
}
};
``````js
// ~/code/dev-app/lib/database/api/v1/index.js
const reqProp = require('req-prop');const setting = reqProp('api', './config/setting');
console.log(setting.get('api.app.name'));
``````bash
# ~/code/dev-app
$ node lib/database/api/v1/index.js
# 'unicorn'
```## API
### reqProp(key, moduleId)
#### key
- Type `string`
- Required: `true`#### moduleId
- Type `string`
- Required: `true`Set Module path
### Instance
> Also See [dot-prop](https://www.npmjs.com/package/dot-prop#api) API
#### .extend(key, value)
Extend an item.
#### .extend(object)
Extend multiple items at once.
#### .get(key)
Get an item.
#### .has(key)
Check if an item exists.
#### .destroy(key)
Delete an item.
#### .clear()
Delete all items.
## License
MIT © [Guntur Poetra](http://guntur.starmediateknik.com)