Permalink
Cannot retrieve contributors at this time
36 lines (34 sloc)
1.17 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/lodash/keyBy.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseAssignValue = require('./_baseAssignValue'), | |
createAggregator = require('./_createAggregator'); | |
/** | |
* Creates an object composed of keys generated from the results of running | |
* each element of `collection` thru `iteratee`. The corresponding value of | |
* each key is the last element responsible for generating the key. The | |
* iteratee is invoked with one argument: (value). | |
* | |
* @static | |
* @memberOf _ | |
* @since 4.0.0 | |
* @category Collection | |
* @param {Array|Object} collection The collection to iterate over. | |
* @param {Function} [iteratee=_.identity] The iteratee to transform keys. | |
* @returns {Object} Returns the composed aggregate object. | |
* @example | |
* | |
* var array = [ | |
* { 'dir': 'left', 'code': 97 }, | |
* { 'dir': 'right', 'code': 100 } | |
* ]; | |
* | |
* _.keyBy(array, function(o) { | |
* return String.fromCharCode(o.code); | |
* }); | |
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } | |
* | |
* _.keyBy(array, 'dir'); | |
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } | |
*/ | |
var keyBy = createAggregator(function(result, value, key) { | |
baseAssignValue(result, key, value); | |
}); | |
module.exports = keyBy; |