Skip to content

Instantly share code, notes, and snippets.

@narfman0
Created February 19, 2016 18:48
Show Gist options
  • Select an option

  • Save narfman0/b1a7dbf882326a82da2c to your computer and use it in GitHub Desktop.

Select an option

Save narfman0/b1a7dbf882326a82da2c to your computer and use it in GitHub Desktop.
pubsubcutioner 1.1.2
!function(n,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():n.Pubsubcutioner=e()}(this,function(){function n(){function n(n){var t=[];for(var r in e)new RegExp("^"+r+"$").test(n)&&(t=t.concat(e[r]));return t}var e={},t={};return t.publish=function(e,t){var r,o=n(e);for(r in o)if(o.hasOwnProperty(r))try{o[r](e,t)}catch(i){"undefined"!=typeof console&&console.log(i.stack)}return!0},t.subscribe=function(n,t){return"function"!=typeof t?!1:(e.hasOwnProperty(n)||(e[n]=[]),e[n]=e[n].concat(t),!0)},t.clearAllSubscriptions=function(){e={}},t.clearSubscriptions=function(n){var t;for(t in e)e.hasOwnProperty(t)&&0===t.indexOf(n)&&delete e[t]},t.unsubscribe=function(n){var t,r,o,i="string"==typeof n&&e.hasOwnProperty(n),u="function"==typeof n,f=!1;if(i)return void delete e[n];for(t in e)if(e.hasOwnProperty(t)&&(r=e[t],u))for(o in r)r.hasOwnProperty(o)&&r[o]===n&&(delete r[o],f=!0);return f},"undefined"!=typeof window&&(window.pubsubcutioner=t),t}return n()});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment