mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Add toObject to _.pairs.
This commit is contained in:
@@ -10000,6 +10000,8 @@
|
|||||||
* // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
|
* // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
function pairs(object) {
|
function pairs(object) {
|
||||||
|
object = toObject(object);
|
||||||
|
|
||||||
var index = -1,
|
var index = -1,
|
||||||
props = keys(object),
|
props = keys(object),
|
||||||
length = props.length,
|
length = props.length,
|
||||||
|
|||||||
@@ -11813,6 +11813,12 @@
|
|||||||
var object = { '0': 'a', '1': 'b', 'length': 2 };
|
var object = { '0': 'a', '1': 'b', 'length': 2 };
|
||||||
deepEqual(_.pairs(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']]);
|
||||||
|
});
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user