commit d3dcadcccf1753fb950b2b15ef24a1a45f0cbada
parent c97bc199a0cab7a82e8b272066349b6ddd7b56bf
Author: finwo <finwo@pm.me>
Date: Mon, 2 Jan 2017 21:01:02 +0100
Project init
Diffstat:
6 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/LICENSE b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2017 Robin Bron
+Copyright (c) 2017 Finwo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/Makefile b/Makefile
@@ -0,0 +1,2 @@
+uglifyjs:
+ { echo "// Build by" $$(whoami) "@" $$(date) ; uglifyjs -c -m -- dist/event-object.js ; } > dist/event-object.min.js
diff --git a/bower.json b/bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "event-object",
+ "description": "Attach events to any object",
+ "main": "dist/event-object.js",
+ "authors": [
+ "Robin Bron <robin@finwo.nl>"
+ ],
+ "license": "MIT",
+ "homepage": "https://github.com/finwo/event-object.git",
+ "ignore": [
+ "**/.*",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ]
+}
diff --git a/dist/event-object.js b/dist/event-object.js
@@ -0,0 +1,26 @@
+(function(exports) {
+ exports.eventObject = function(sourceObject) {
+ var listeners = {};
+ sourceObject = sourceObject || {};
+ sourceObject.trigger = function(name, data) {
+ data = data || true;
+ if( listeners[name] ) {
+ listeners[name].forEach(function(callback) {
+ data = data && callback.call(null, data);
+ });
+ }
+ return data;
+ };
+ sourceObject.on = function(name, callback) {
+ if(name.forEach) {
+ name.forEach(function(currentName) {
+ sourceObject.on(currentName, callback);
+ });
+ return sourceObject;
+ }
+ listeners[name] = listeners[name] || [];
+ listeners[name].push(callback);
+ return sourceObject;
+ };
+ };
+})(typeof exports === 'object' ? exports : this);
diff --git a/dist/event-object.min.js b/dist/event-object.min.js
@@ -0,0 +1,2 @@
+// Build by chronos @ Mon Jan 2 20:58:24 CET 2017
+!function(n){n.eventObject=function(n){var t={};n=n||{},n.trigger=function(n,o){return o=o||!0,t[n]&&t[n].forEach(function(n){o=o&&n.call(null,o)}),o},n.on=function(o,c){return o.forEach?(o.forEach(function(t){n.on(t,c)}),n):(t[o]=t[o]||[],t[o].push(c),n)}}}("object"==typeof exports?exports:this);
diff --git a/package.json b/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "event-object",
+ "version": "0.0.1",
+ "description": "Attach events to any object",
+ "main": "dist/event-object.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/finwo/node-event-object.git"
+ },
+ "author": "Robin Bron <robin@finwo.nl>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/finwo/node-event-object/issues"
+ },
+ "homepage": "https://github.com/finwo/node-event-object#readme"
+}