added oneToMany option to _.invert()

This commit is contained in:
Scott Shepherd
2013-12-05 09:12:38 -05:00
parent c2972fcaa0
commit efb1a2c8e0
2 changed files with 19 additions and 3 deletions

View File

@@ -3306,6 +3306,12 @@
var object = { '0': 'a', '1': 'b', 'length': 2 };
deepEqual(_.invert(object), { 'a': '0', 'b': '1', '2': 'length' });
});
test('should accept the one-to-many flag', 1, function() {
var object = { '0': 'a', '1': 'b', '2': 'a' };
deepEqual(_.invert(object, true), { 'a': ['0', '2'], 'b': ['1'] });
});
}());
/*--------------------------------------------------------------------------*/