Skip to content

Commit

Permalink
Simplified module pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Harrison committed Jan 17, 2013
1 parent 9659f6e commit 8d994c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions jsSelecta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Christopher Harrison (c) 2013
// MIT License

(function(root) {
(function(root, undefined) {
var extend = function(base, child) {
// Shallow copy
for (var x in child) {
Expand Down Expand Up @@ -142,10 +142,10 @@
});

// Enter selecta!
if (typeof module !== 'undefined' && module.exports) {
if (typeof module !== undefined && module.exports) {
// CommonJS Module (e.g., for node.js)
module.exports = selecta;
} else if (typeof define !== 'undefined' && define.amd) {
} else if (typeof define !== undefined && define.amd) {
// AMD Module (e.g., for RequireJS)
define('jsSelecta', [], function() { return selecta; });
} else {
Expand All @@ -156,4 +156,4 @@
root.selecta = selecta;
}
}
})((function() { return this; })()); // i.e., Global object
})(this);
8 changes: 4 additions & 4 deletions tdd/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

(function(root) {
(function(root, undefined) {
var contains = function(a, b) {
var passed = true;

Expand Down Expand Up @@ -72,11 +72,11 @@
};

// Instantiate
if (typeof module !== 'undefined' && module.exports) {
if (typeof module !== undefined && module.exports) {
// CommonJS Module (e.g., for node.js)
var selecta = require('../jsSelecta');
module.exports = test;
} else if (typeof define !== 'undefined' && define.amd) {
} else if (typeof define !== undefined && define.amd) {
// AMD Module (e.g., for RequireJS)
define('test', ['jsSelecta'], function() { return test; });
} else {
Expand All @@ -87,4 +87,4 @@
root.test = test;
}
}
})((function() { return this; } )());
})(this);

0 comments on commit 8d994c4

Please sign in to comment.