Skip to content

Commit

Permalink
Underscore.string tries all available integration methods in order
Browse files Browse the repository at this point in the history
  • Loading branch information
rwz committed Oct 16, 2012
1 parent 4989f17 commit 9df4736
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lib/underscore.string.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,25 +591,23 @@
_s.contains = _s.include;
_s.q = _s.quote;

// Exporting

// CommonJS module is defined
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
// Export module
if (typeof module !== 'undefined' && module.exports)
module.exports = _s;
}
exports._s = _s;

} else if (typeof define === 'function' && define.amd) {
// Register as a named module with AMD.
define('underscore.string', [], function() {
return _s;
});

} else {
// Integrate with Underscore.js if defined
// or create our own underscore object.
root._ = root._ || {};
root._.string = root._.str = _s;
exports._s = _s;
}

// Register as a named module with AMD.
if (typeof define === 'function' && define.amd)
define('underscore.string', [], function(){ return _s; });


// Integrate with Underscore.js if defined
// or create our own underscore object.
root._ = root._ || {};
root._.string = root._.str = _s;
}(this, String);

0 comments on commit 9df4736

Please sign in to comment.