From 3d78784a5e84f8b7ffa7155f9fc51afc6533ebc4 Mon Sep 17 00:00:00 2001 From: Nik Rowell Date: Sat, 29 Apr 2017 10:28:53 -0700 Subject: [PATCH 1/2] updated to use UMD format --- perlin.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/perlin.js b/perlin.js index 3ab0f48..3d8e94c 100644 --- a/perlin.js +++ b/perlin.js @@ -14,8 +14,13 @@ * */ -(function(global){ - var module = global.noise = {}; +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.noise = factory()); +}(this, (function () { 'use strict'; + + var module = {}; function Grad(x, y, z) { this.x = x; this.y = y; this.z = z; @@ -307,4 +312,6 @@ v); }; -})(this); + return module; + +}))); \ No newline at end of file From 2f2138c8c1e762d82bf1aadd26b6f836fbba8e45 Mon Sep 17 00:00:00 2001 From: Nik Rowell Date: Thu, 4 May 2017 14:45:54 -0700 Subject: [PATCH 2/2] updated umd wrapper --- perlin.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/perlin.js b/perlin.js index 3d8e94c..c0176c5 100644 --- a/perlin.js +++ b/perlin.js @@ -14,11 +14,17 @@ * */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.noise = factory()); -}(this, (function () { 'use strict'; +(function(global, factory) { + + if(typeof exports === 'object') { + module.exports = factory(global); + } else if(typeof define === 'function' && define.amd) { + define(function() { return factory(global); }); + } else { + global.noise = factory(global); + } + +}(typeof window !== 'undefined' ? window : this, function(global) { 'use strict'; var module = {}; @@ -314,4 +320,4 @@ return module; -}))); \ No newline at end of file +})); \ No newline at end of file