event-object.js

Attach events to any object
git clone git://git.finwo.net/lib/event-object.js
Log | Files | Refs | README | LICENSE

commit c853d3ea4fdaab2fc2631326130d98037d44de27
parent d3dcadcccf1753fb950b2b15ef24a1a45f0cbada
Author: finwo <finwo@pm.me>
Date:   Mon,  9 Jan 2017 14:15:16 +0100

Added requirejs support ; added es6 minified version

Diffstat:
M.gitignore | 23++---------------------
Adist/event-object.es6.min.js | 2++
Mdist/event-object.js | 8++++++++
Mdist/event-object.min.js | 4++--
4 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,37 +1,18 @@ -# Logs logs *.log npm-debug.log* - -# Runtime data pids *.pid *.seed - -# Directory for instrumented libs generated by jscoverage/JSCover lib-cov - -# Coverage directory used by tools like istanbul coverage - -# nyc test coverage .nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt - -# node-waf configuration .lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) build/Release - -# Dependency directories node_modules jspm_packages - -# Optional npm cache directory .npm - -# Optional REPL history .node_repl_history +.idea +.zedstate diff --git a/dist/event-object.es6.min.js b/dist/event-object.es6.min.js @@ -0,0 +1,2 @@ +// Handcrafted by finwo @ Mon Jan 9 14:15:00 CET 2017 +((n)=>{var e=(s)=>{var l={},i=(a,c)=>a.map((n)=>s.on(n,c));s=s||{};s.trigger=(n,d)=>{(l[n]||[]).map((c)=>{d=d||!0;d&&c(d)};);return d};s.on=(n,c)=>{n.map?i(n,c):(l[n]=l[n]||[]).push(c);return s;};};n.eventObject=e;"function"==typeof define&&define.amd&&define("event-object",()=>e);})("object"==typeof exports?exports:this); diff --git a/dist/event-object.js b/dist/event-object.js @@ -1,4 +1,5 @@ (function(exports) { + exports.eventObject = function(sourceObject) { var listeners = {}; sourceObject = sourceObject || {}; @@ -23,4 +24,11 @@ return sourceObject; }; }; + + if(typeof define == 'function' && define.amd) { + define('event-object', function() { + return exports.eventObject; + }) + } + })(typeof exports === 'object' ? exports : this); diff --git a/dist/event-object.min.js b/dist/event-object.min.js @@ -1,2 +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); +// Build by finwo @ Mon Jan 9 14:03:06 CET 2017 +!function(n){n.eventObject=function(n){var e={};n=n||{},n.trigger=function(n,t){return t=t||!0,e[n]&&e[n].forEach(function(n){t=t&&n.call(null,t)}),t},n.on=function(t,o){return t.forEach?(t.forEach(function(e){n.on(e,o)}),n):(e[t]=e[t]||[],e[t].push(o),n)}},"function"==typeof define&&define.amd&&define("event-object",function(){return n.eventObject})}("object"==typeof exports?exports:this);