Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yamadapc/node-bootstrap-events
Bootstraps events based on the directory tree and found modules' exported methods.
https://github.com/yamadapc/node-bootstrap-events
Last synced: 15 days ago
JSON representation
Bootstraps events based on the directory tree and found modules' exported methods.
- Host: GitHub
- URL: https://github.com/yamadapc/node-bootstrap-events
- Owner: yamadapc
- License: mit
- Created: 2014-07-10T05:03:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-12T13:58:17.000Z (almost 9 years ago)
- Last Synced: 2024-12-24T11:58:00.372Z (17 days ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
bootstrap-events
================
[![Build Status](https://travis-ci.org/yamadapc/node-bootstrap-events.svg?branch=master)](https://travis-ci.org/yamadapc/node-bootstrap-events)
[![devDependency Status](https://david-dm.org/yamadapc/node-bootstrap-events/dev-status.svg)](https://david-dm.org/yamadapc/node-bootstrap-events#info=devDependencies)
[![Coverage Status](https://coveralls.io/repos/yamadapc/node-bootstrap-events/badge.png)](https://coveralls.io/r/yamadapc/node-bootstrap-events)- - -
__NOTE:__ _This is still experimental code._
Bootstraps events based on the directory tree and found modules' exported
methods.## Installing
You can install this module through:
```
npm install --save bootstrap-events
```## Usage
```javascript
var path = require('path');
var events = require('events');
var bootstrapEvents = require('bootstrap-events');var emitter = new events.EventEmitter();
var path = path.join(__dirname, 'root');
bootstrapEvents(emitter, path)
```See the [example](example) directory for more information.
## Public API
### `bootstrapEvents(emitter, targetDir)`
Bootstraps a directories modules methods recursivelly into an event emitter.
#### Params:
* **EventEmitter** *emitter* The EventEmitter to attach listeners to
* **String** *targetDir* The directory to start the search in
* **Object** *[options]* An options object
* **Function|Mixed|RegExp|Array** *[options.ignore]* A file ignore pattern
* **Boolean** *[options.moduleWildcards=true]* Whether to set functions#### Return:
* **EventEmitter** The `emitter` parameter
## Private API
### `_bootstrapObject(emitter, baseEventName, obj)`
Bootstraps an object `obj`'s methods recursivelly to the EventEmitter
`emitter` based on a base event name `baseEventName`.#### Params:
* **EventEmitter** *emitter* The event emitter to attach listeners to
* **String** *baseEventName* The base event name
* **Object** *obj* An object to scan for handlers#### Return:
* **EventEmitter** The `emitter` parameter
### `_walk(dir)`
Recursively walks a directory and returns paths to all found files.
#### Params:
* **String** *dir* The directory to walk
#### Return:
* **Array.** paths All the found files' paths
### `_matches(pred, value)`
Checks if a file matches a predicate, value, regexp or Array of any of the
preceding.#### Params:
* **Function|Mixed|RegExp|Array** *pred*
* **Mixed** *value*#### Return:
* **Boolean** matches
## License
This code is licensed under the MIT license. See the [LICENSE](LICENSE) file for
more information.## Donations
Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y