Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AMD, CommonJS and as Bower component. #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
npm-debug.log
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2.0 (2016-07-26)

- Enable support for AMD, CommonJS and as browser script.

# 1.1.1 (2016-06-22)

- add more context to errors if they are not instanceof Error
Expand Down
9 changes: 9 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ npm install events
var EventEmitter = require('events').EventEmitter
```

## Browser ##

```html
<script src="/path/to/events.js"></script>
<script>
var myEmitter = new events.EventEmitter();
</script>
```

## Usage ##

See the [node.js event emitter docs](http://nodejs.org/api/events.html)
25 changes: 25 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "events",
"description": "Node's event emitter for the browser.",
"main": "./events.js",
"authors": [
"Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)",
"Escaux Product Development <product@escaux.com> (http://escaux.com)"
],
"license": "MIT",
"keywords": [
"events",
"eventEmitter",
"eventDispatcher",
"listeners"
],
"homepage": "https://github.com/Escaux/events",
"ignore": [
"**/.*",
"package.json",
"npm-debug.log",
"node_modules",
"bower_components",
"tests"
]
}
17 changes: 17 additions & 0 deletions events.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

((function (root, factory) {
var name = 'events';
if (typeof define === 'function' && define.amd) {
define(name, [], function () {
return factory({});
});
} else if (typeof module === 'object' && module.exports) {
factory(module);
} else {
root[name] = factory({});
}
})(this, function (module) {

function EventEmitter() {
this._events = this._events || {};
this._maxListeners = this._maxListeners || undefined;
Expand Down Expand Up @@ -300,3 +313,7 @@ function isObject(arg) {
function isUndefined(arg) {
return arg === void 0;
}

return EventEmitter;

}));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "events",
"id": "events",
"version": "1.1.1",
"version": "1.2.0",
"description": "Node's event emitter for all engines.",
"keywords": [
"events",
Expand Down