mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Rename multiValue param to multiVal. [ci skip]
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -9474,13 +9474,13 @@
|
|||||||
/**
|
/**
|
||||||
* Creates an object composed of the inverted keys and values of `object`.
|
* Creates an object composed of the inverted keys and values of `object`.
|
||||||
* If `object` contains duplicate values, subsequent values overwrite property
|
* If `object` contains duplicate values, subsequent values overwrite property
|
||||||
* assignments of previous values unless `multiValue` is `true`.
|
* assignments of previous values unless `multiVal` is `true`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Object
|
* @category Object
|
||||||
* @param {Object} object The object to invert.
|
* @param {Object} object The object to invert.
|
||||||
* @param {boolean} [multiValue] Allow multiple values per key.
|
* @param {boolean} [multiVal] Allow multiple values per key.
|
||||||
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
|
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
|
||||||
* @returns {Object} Returns the new inverted object.
|
* @returns {Object} Returns the new inverted object.
|
||||||
* @example
|
* @example
|
||||||
@@ -9490,14 +9490,14 @@
|
|||||||
* _.invert(object);
|
* _.invert(object);
|
||||||
* // => { '1': 'c', '2': 'b' }
|
* // => { '1': 'c', '2': 'b' }
|
||||||
*
|
*
|
||||||
* // with `multiValue`
|
* // with `multiVal`
|
||||||
* _.invert(object, true);
|
* _.invert(object, true);
|
||||||
* // => { '1': ['a', 'c'], '2': ['b'] }
|
* // => { '1': ['a', 'c'], '2': ['b'] }
|
||||||
*/
|
*/
|
||||||
function invert(object, multiValue, guard) {
|
function invert(object, multiVal, guard) {
|
||||||
return arrayReduce(keys(object), function(result, key) {
|
return arrayReduce(keys(object), function(result, key) {
|
||||||
var value = object[key];
|
var value = object[key];
|
||||||
if (multiValue && !guard) {
|
if (multiVal && !guard) {
|
||||||
if (hasOwnProperty.call(result, value)) {
|
if (hasOwnProperty.call(result, value)) {
|
||||||
result[value].push(key);
|
result[value].push(key);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user