From 127e8be80e2bf94b50fcccaf8faf8e687272e88a Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Wed, 30 Sep 2015 23:15:58 -0700 Subject: [PATCH] Add UMD wrapper for module loaders --- resemble.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/resemble.js b/resemble.js index 0e8843e..5cb5f5c 100644 --- a/resemble.js +++ b/resemble.js @@ -3,7 +3,15 @@ James Cryer / Huddle 2014 URL: https://github.com/Huddle/Resemble.js */ -(function(_this){ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + define([], factory); + } else if (typeof module === 'object' && module.exports) { + module.exports = factory(); + } else { + root.resemble = factory(); + } +}(this, function () { 'use strict'; var pixelTransparency = 1; @@ -63,7 +71,7 @@ URL: https://github.com/Huddle/Resemble.js var document = typeof window != "undefined" ? window.document : {}; var documentDomainRegex = new RegExp('^https?://' + document.domain); - _this['resemble'] = function( fileData ){ + var resemble = function( fileData ){ var data = {}; var images = []; @@ -633,7 +641,7 @@ URL: https://github.com/Huddle/Resemble.js }; - _this['resemble'].outputSettings = function(options){ + resemble.outputSettings = function(options){ var key; var undefined; @@ -656,4 +664,5 @@ URL: https://github.com/Huddle/Resemble.js return this; }; -}(this)); + return resemble; +}));