From b942b5ff605403a7a9f5acf70f271c33bf3e1b4e Mon Sep 17 00:00:00 2001 From: Alexander Gugel Date: Thu, 12 Feb 2015 20:46:29 +0100 Subject: [PATCH] Add UMD --- src/Layout.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Layout.js b/src/Layout.js index 55b75d02..28cdcb8f 100755 --- a/src/Layout.js +++ b/src/Layout.js @@ -8,7 +8,6 @@ */ var computeLayout = (function() { - function capitalizeFirst(str) { return str.charAt(0).toUpperCase() + str.slice(1); } @@ -653,7 +652,21 @@ var computeLayout = (function() { }; })(); -if (typeof module === 'object') { - module.exports = computeLayout; -} - +// UMD (Universal Module Definition) +// See https://github.com/umdjs/umd for reference +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.returnExports = factory(); + } +}(this, function () { + return computeLayout; +}));