Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.mapvalues

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.mapvalues

The Lo-Dash function `_.mapValues` as a Node.js module generated by lodash-cli.

  • 2.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
decreased by-6.49%
Maintainers
4
Weekly downloads
 
Created

What is lodash.mapvalues?

The lodash.mapvalues package is a utility library that provides a method to create a new object with the same keys as the original object, but with values generated by running each own enumerable string-keyed property of the object through a provided function.

What are lodash.mapvalues's main functionalities?

Transform Object Values

This feature allows you to transform the values of an object based on a function. In this example, the values of the 'users' object are transformed to just their ages.

const mapValues = require('lodash.mapvalues');
const users = { 'fred': { 'age': 40 }, 'pebbles': { 'age': 1 } };
const result = mapValues(users, function(o) { return o.age; });
console.log(result); // { 'fred': 40, 'pebbles': 1 }

Modify Values Based on Key

This feature allows you to modify the values of an object based on both the value and the key. In this example, the values are transformed to a string that includes both the key and the age.

const mapValues = require('lodash.mapvalues');
const users = { 'fred': { 'age': 40 }, 'pebbles': { 'age': 1 } };
const result = mapValues(users, function(o, key) { return key + ' is ' + o.age; });
console.log(result); // { 'fred': 'fred is 40', 'pebbles': 'pebbles is 1' }

Other packages similar to lodash.mapvalues

Keywords

FAQs

Package last updated on 03 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc