Add toObject to _.pairs.

This commit is contained in:
jdalton
2015-05-16 22:46:43 -07:00
parent f4d72dba06
commit c2b1d61dd1
2 changed files with 8 additions and 0 deletions

View File

@@ -10000,6 +10000,8 @@
* // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
*/
function pairs(object) {
object = toObject(object);
var index = -1,
props = keys(object),
length = props.length,

View File

@@ -11813,6 +11813,12 @@
var object = { '0': 'a', '1': 'b', 'length': 2 };
deepEqual(_.pairs(object), [['0', 'a'], ['1', 'b'], ['length', 2]]);
});
test('should work with strings', 2, function() {
_.each(['xo', Object('xo')], function(string) {
deepEqual(_.pairs(string), [['0', 'x'], ['1', 'o']]);
});
});
}());
/*--------------------------------------------------------------------------*/