Tabnine Logo For Javascript
mapValues
Code IndexAdd Tabnine to your IDE (free)

How to use
mapValues
function
in
lodash

Best JavaScript code snippets using lodash.mapValues(Showing top 15 results out of 315)

origin: wise-old-man/wise-old-man

async function syncInitialValues(playerId: number, latest: Snapshot) {
 // Find or create (if doesn't exist) the player's initial values
 const [initial] = await InitialValues.findOrCreate({ where: { playerId } });

 mapValues(latest, (value, key) => {
  if (value > -1 && initial[key] === -1) {
   initial[key] = value;
  }
 });

 await initial.save();
 return initial;
}
origin: ryrudnev/spa-react-redux-example

const mapDispatchToProps = (dispatch, ownProps) => {
   const bindTable = actionCreator => actionCreator.bind(null, ownProps.table);

   // Bind the first parameter on `ownProps.table`
   const tableACs = mapValues(bindTable, tableActions);

   // Wrap action creators with `dispatch`
   const boundTableACs = bindActionCreators(tableACs, dispatch);

   const computedActions = {
    ...boundTableACs,
    dispatch,
   };

   return () => computedActions;
  }
origin: mgcrea/node-mediainfo-parser

const transformResponse = (res) => {
 /* eslint-disable no-param-reassign */
 if (res && res.file) {
  const tracks = Array.isArray(res.file.track) ? res.file.track : [res.file.track];
  res.file.track = tracks.map(track => mapValues(track, mapValue));
 }
 return res;
}
origin: sfroestl/angular-react-migration

function toProps(propTypes, controller) {
  return mapValues(propTypes, (val, key) => {
    return controller[key];
  });
}
origin: TryGhost/Ghost-CLI

/**
   * Gets the available process managers (if any) from this extension
   * By default it checks the package.json for any listed ones, but subclasses
   * can override this method to do it a different way.
   *
   * @property processManagers
   * @type Object
   * @public
   */
  get processManagers() {
    if (!this.pkg || !this.pkg['ghost-cli'] || !this.pkg['ghost-cli']['process-managers']) {
      return {};
    }

    return mapValues(this.pkg['ghost-cli']['process-managers'], relPath => path.join(this.dir, relPath));
  }
origin: bukinoshita/open-source

export default function getMajorLanguage(languages) {
 const sumLinesOfCode = reduce((sum, linesOfCode) => sum + linesOfCode, 0)(
  languages,
 )

 const highUsageLanguages = flow(
  pickBy((value, key) => (value > 10000 ? key : null)),
  keys,
 )(languages)

 const mostPopularLanguage = flow(
  mapValues((value, key) => value / sumLinesOfCode),
  obj => [keys(obj).reduce((a, b) => (obj[a] > obj[b] ? a : b), null)],
  filter(value => value),
 )(languages)

 return union([...highUsageLanguages, ...mostPopularLanguage])
}
origin: wise-old-man/wise-old-man

/**
 * Gets the all the player deltas (gains), for every period.
 */
async function getPlayerDeltas(playerId: number) {
 const initial = await InitialValues.findOne({ where: { playerId } });
 const latest = await snapshotService.findLatest(playerId);

 const periodDeltas = await Promise.all(
  PERIODS.map(async period => {
   const deltas = await getPlayerPeriodDeltas(playerId, period, latest, initial);
   return { period, deltas };
  })
 );

 // Turn an array of deltas, into an object, using the period as a key,
 // then include only the deltas array in the final object, not the period fields
 return mapValues(keyBy(periodDeltas, 'period'), p => p.deltas);
}
origin: TryGhost/nodecmsguide

async function updateArchive({ timestamp, data }, archive) {
 const preppedData = archive
  ? {
   timestamp,
   data: mapValues(data, (projectData, name) => {
    const projectArchive = removeOutdated(archive.data[name] || [], 30)
    return [...projectData, ...projectArchive]
   }),
  }
  : { timestamp, data }
 const content = JSON.stringify(preppedData)
 if (archive) {
  await editGist(content, archive.id)
 } else {
  await createGist(content)
 }
 return preppedData
}
origin: wise-old-man/wise-old-man

/**
 * Finds all player snapshots, grouped by period.
 *
 * Ex:
 * {
 *    day: [...],
 *    week: [...],
 *    etc
 * }
 */
async function getAllGrouped(playerId) {
 if (!playerId) {
  throw new BadRequestError(`Invalid player id.`);
 }

 const partials = await Promise.all(
  PERIODS.map(async period => {
   const list = await getAllInPeriod(playerId, period);
   return { period, snapshots: list };
  })
 );

 // Turn an array of snapshots, into an object, using the period as a key,
 // then include only the snapshots array in the final object, not the period fields
 return mapValues(keyBy(partials, 'period'), p => p.snapshots);
}
origin: zetekla/react-diff-view

const createEventsBindingSelector = (ownEvents = {}) => {
  const ownEventEntries = Object.entries(ownEvents);

  return createSelector(
    // Bind args of all event callbacks to given input
    (events, arg) => {
      const customEvents = mapValues(events, fn => () => fn(arg));
      return ownEventEntries.reduce(
        (events, [name, ownCallback]) => {
          const customCallback = events[name];
          const callback = customCallback ? composeCallback(customCallback, ownCallback) : ownCallback;

          return {
            ...events,
            [name]: callback
          };
        },
        customEvents
      );
    },
    // [events, {change, side}]
    (prev, next) => shallowEquals(prev[0], next[0]) && shallowEquals(prev[1], next[1])
  );
}
origin: wise-old-man/wise-old-man

const countMap = mapValues(
 keyBy(
  participantCount.map((c: any) => ({
origin: fabrix-app/fabrix

private _parseQuery(data) {
  return mapValues(data, value => {
   if (value === 'true' || value === 'false') {
    value = value === 'true'
   }

   if (value === '%00' || value === 'null') {
    value = null
   }

   const parseValue = parseFloat(value)

   if (!isNaN(parseValue) && isFinite(value)) {
    value = parseValue
   }

   return value
  })
 }
origin: ryrudnev/spa-react-redux-example

mapValues(
 ac => ac(table),
 { getOptions,
  getInitial,
  getData,
  isTriggerFetch,
  isFetching,
  isError,
 })
origin: Keziyah/ReactAnimationsTechTalk

mapValues(metaModels, defineModel => defineModel(db))
origin: sfroestl/angular-react-migration

function toBindings(propTypes) {
  return mapValues(propTypes, () => '<');
}
lodash(npm)mapValues

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • fs-extra
    fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • ms
    Tiny millisecond conversion utility
  • minimist
    parse argument options
  • mime-types
    The ultimate javascript content-type utility.
  • handlebars
    Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • axios
    Promise based HTTP client for the browser and node.js
  • mongodb
    The official MongoDB driver for Node.js
  • colors
    get colors in your node.js console
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now