Skip to content

Commit

Permalink
Merge pull request #2 from wmbenedetto/features/nodejs-support
Browse files Browse the repository at this point in the history
Updated to work in NodeJS context
  • Loading branch information
Warren Benedetto authored Feb 21, 2017
2 parents c10de05 + 213f837 commit 1ac8daf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions src/DropletJS.Sequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ if (typeof MINIFIED === 'undefined'){
MINIFIED = false;
}

var root = (typeof window === 'undefined') ? global : window;

/**
* ____ __ __ _______
* / __ \_________ ____ / /__ / /_ / / ___/
Expand Down Expand Up @@ -33,7 +35,7 @@ if (typeof MINIFIED === 'undefined'){
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
(function(window,undefined){
(function(root,undefined){

if (!MINIFIED){

Expand All @@ -46,7 +48,7 @@ if (typeof MINIFIED === 'undefined'){
};

var logLevel = 'OFF';
var console = window.console || {};
var console = root.console || {};

console.log = (typeof console.log === 'function') ? console.log : function() {};
console.info = (typeof console.info === 'function') ? console.info : console.log;
Expand Down Expand Up @@ -457,8 +459,14 @@ if (typeof MINIFIED === 'undefined'){
}
};


/* If in NodeJS context, module will exist */
if (typeof module !== 'undefined'){

module.exports = Sequencer;
}
/* If RequireJS define() is present, use it to export Sequencer */
if (typeof define === "function") {
else if (typeof define === "function") {

define(function() {
return Sequencer;
Expand All @@ -467,8 +475,8 @@ if (typeof MINIFIED === 'undefined'){
/* Otherwise, add Sequencer to global namespace as DropletJS.Sequencer */
else {

window.DropletJS = (typeof window.DropletJS === 'object' && window.DropletJS !== 'null') ? window.DropletJS : {};
window.DropletJS.Sequencer = Sequencer;
root.DropletJS = (typeof root.DropletJS === 'object' && root.DropletJS !== 'null') ? root.DropletJS : {};
root.DropletJS.Sequencer = Sequencer;
}

}(window));
}(root));
2 changes: 1 addition & 1 deletion src/DropletJS.Sequencer.min.js

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

0 comments on commit 1ac8daf

Please sign in to comment.