From 538fea377edaf09deaf5fab8a31b1dfc7c96c634 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 30 Nov 2010 10:09:50 -0600 Subject: [PATCH] Export _ object as the entire module --- underscore.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/underscore.js b/underscore.js index 8689aeb42..0f9480d55 100644 --- a/underscore.js +++ b/underscore.js @@ -47,11 +47,16 @@ // Create a safe reference to the Underscore object for use below. var _ = function(obj) { return new wrapper(obj); }; - // Export the Underscore object for **CommonJS**. - if (typeof exports !== 'undefined') exports._ = _; + if (typeof module !== 'undefined') { + // Export the Underscore object for **CommonJS**. + module.exports = _; - // Export Underscore to the global scope. - root._ = _; + // Backwards compat with old requiring api + _._ = _; + } else { + // Export Underscore to the global scope. + root._ = _; + } // Current version. _.VERSION = '1.1.2';