|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
666 bytes
|
| Line | |
|---|
| 1 | var baseAssignValue = require('./_baseAssignValue');
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * The inverse of `_.toPairs`; this method returns an object composed
|
|---|
| 5 | * from key-value `pairs`.
|
|---|
| 6 | *
|
|---|
| 7 | * @static
|
|---|
| 8 | * @memberOf _
|
|---|
| 9 | * @since 4.0.0
|
|---|
| 10 | * @category Array
|
|---|
| 11 | * @param {Array} pairs The key-value pairs.
|
|---|
| 12 | * @returns {Object} Returns the new object.
|
|---|
| 13 | * @example
|
|---|
| 14 | *
|
|---|
| 15 | * _.fromPairs([['a', 1], ['b', 2]]);
|
|---|
| 16 | * // => { 'a': 1, 'b': 2 }
|
|---|
| 17 | */
|
|---|
| 18 | function fromPairs(pairs) {
|
|---|
| 19 | var index = -1,
|
|---|
| 20 | length = pairs == null ? 0 : pairs.length,
|
|---|
| 21 | result = {};
|
|---|
| 22 |
|
|---|
| 23 | while (++index < length) {
|
|---|
| 24 | var pair = pairs[index];
|
|---|
| 25 | baseAssignValue(result, pair[0], pair[1]);
|
|---|
| 26 | }
|
|---|
| 27 | return result;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | module.exports = fromPairs;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.