CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
map.js54 linesDownload Raw Back to lodash-es
1import arrayMap from './_arrayMap.js';2import baseIteratee from './_baseIteratee.js';3import baseMap from './_baseMap.js';4import isArray from './isArray.js';5 6/**7 * Creates an array of values by running each element in `collection` thru8 * `iteratee`. The iteratee is invoked with three arguments:9 * (value, index|key, collection).10 *11 * Many lodash methods are guarded to work as iteratees for methods like12 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.13 *14 * The guarded methods are:15 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,16 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,17 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,18 * `template`, `trim`, `trimEnd`, `trimStart`, and `words`19 *20 * @static21 * @memberOf _22 * @since 0.1.023 * @category Collection24 * @param {Array|Object} collection The collection to iterate over.25 * @param {Function} [iteratee=_.identity] The function invoked per iteration.26 * @returns {Array} Returns the new mapped array.27 * @example28 *29 * function square(n) {30 *   return n * n;31 * }32 *33 * _.map([4, 8], square);34 * // => [16, 64]35 *36 * _.map({ 'a': 4, 'b': 8 }, square);37 * // => [16, 64] (iteration order is not guaranteed)38 *39 * var users = [40 *   { 'user': 'barney' },41 *   { 'user': 'fred' }42 * ];43 *44 * // The `_.property` iteratee shorthand.45 * _.map(users, 'user');46 * // => ['barney', 'fred']47 */48function map(collection, iteratee) {49  var func = isArray(collection) ? arrayMap : baseMap;50  return func(collection, baseIteratee(iteratee, 3));51}52 53export default map;54 
basant307/AI_Governance_Project · CoolFace