Skip to content

Commit

Permalink
Merge pull request #8 from toddself/master
Browse files Browse the repository at this point in the history
Fixing main field so that browserify can work on package.
  • Loading branch information
daniellmb committed Nov 19, 2013
2 parents 3e6028a + 9d6e2c2 commit 6b82b71
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion minpubsub.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 19 additions & 4 deletions minpubsub.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
*/

(function(d){
var MinPubSub = {};

// the topic/subscription hash
var cache = d.c_ || {}; //check for "c_" cache for unit testing

d.publish = function(/* String */ topic, /* Array? */ args){
MinPubSub.publish = function(/* String */ topic, /* Array? */ args){
// summary:
// Publish some data on a named topic.
// topic: String
Expand All @@ -33,7 +34,7 @@
}
};

d.subscribe = function(/* String */ topic, /* Function */ callback){
MinPubSub.subscribe = function(/* String */ topic, /* Function */ callback){
// summary:
// Register a callback on a named topic.
// topic: String
Expand All @@ -56,7 +57,7 @@
return [topic, callback]; // Array
};

d.unsubscribe = function(/* Array */ handle, /* Function? */ callback){
MinPubSub.unsubscribe = function(/* Array */ handle, /* Function? */ callback){
// summary:
// Disconnect a subscribed function for a topic.
// handle: Array
Expand All @@ -76,4 +77,18 @@
}
};

})(this);
// UMD definition to allow for CommonJS, AMD and legacy window
if (typeof module === 'object' && typeof module.exports === 'object') {
// CommonJS, just export
module.exports = exports = MinPubSub;
} else if (typeof define === 'function' && define.amd) {
// AMD support
define(function () { return MinPubSub; });
} else if (typeof window === 'object') {
// If no AMD and we are in the browser, attach to window
window.publish = MinPubSub.publish;
window.subscribe = MinPubSub.subscribe;
window.unsubscribe = MinPubSub.unsubscribe;
}

})(window);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"author": "Daniel Lamb <daniellmb.com>",
"dependencies": {},
"main": "index",
"main": "minpubsub.src.js",
"engines": {
"node": "*"
},
Expand Down

0 comments on commit 6b82b71

Please sign in to comment.