diff --git a/lib/underscore.string.js b/lib/underscore.string.js index 5ce1e3f7..224f05e3 100644 --- a/lib/underscore.string.js +++ b/lib/underscore.string.js @@ -550,11 +550,15 @@ else return str; }, - exports: function() { + exports: function(options) { var result = {}; + var opts = options || {}; + var regex = opts.strict ? + /^(?:include|contains|reverse|join)$/ : + /^(?:include|contains|reverse)$/; for (var prop in this) { - if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse)$/)) continue; + if (!this.hasOwnProperty(prop) || prop.match(regex)) continue; result[prop] = this[prop]; } diff --git a/test/strings.js b/test/strings.js index e57ec224..71d2276a 100644 --- a/test/strings.js +++ b/test/strings.js @@ -5,6 +5,11 @@ $(document).ready(function() { module('String extensions'); + test('Strings: exports', function() { + equal(_.has(_.str.exports(), 'join'), true); + equal(_.has(_.str.exports({ strict: true }), 'join'), false); + }); + test('Strings: naturalSort', function() { var arr = ['foo2', 'foo1', 'foo10', 'foo30', 'foo100', 'foo10bar'], sorted = ['foo1', 'foo2', 'foo10', 'foo10bar', 'foo30', 'foo100'];