Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#12 better AMD #13

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**/

( // Module boilerplate to support browser globals, node.js and AMD.
(typeof module !== "undefined" && function (m) { module.exports = m(); }) ||
(typeof define === "function" && function (m) { define('underscoreDeepExtend', m); }) ||
(function (m) { window['underscoreDeepExtend'] = m(); })
)(function () { return function(_) {
(function (global, undefined) {
'use strict';

var factory = function factory(_) {
return function underscoreDeepExtend(obj) {
var parentRE = /#{\s*?_\s*?}/,
slice = Array.prototype.slice;
Expand Down Expand Up @@ -48,4 +46,22 @@ return function underscoreDeepExtend(obj) {
return obj;
};

};});
};

// AMD support
if (typeof define === 'function' && define.amd) {
define(function () {
return factory;
});
// CommonJS/Node.js support
} else if (typeof exports === 'object') {
// Support Node.js specific `module.exports` (which can be a function)
if (typeof module === 'object' && typeof module.exports === 'object') {
exports = module.exports = factory;
}
// But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
exports.underscoreDeepExtend = factory;
} else {
global.underscoreDeepExtend = factory;
}
})(typeof window === 'undefined' ? this : window);