Socket
Socket
Sign inDemoInstall

lodash.map

Package Overview
Dependencies
Maintainers
4
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.map

The modern build of lodash’s `_.map` as a module.


Version published
Weekly downloads
2.3M
increased by3.74%
Maintainers
4
Weekly downloads
 
Created

What is lodash.map?

The lodash.map package is a utility library that provides a method for creating a new array populated with the results of calling a provided function on every element in the calling array. It is part of the larger Lodash library, which offers a wide range of utility functions for common programming tasks.

What are lodash.map's main functionalities?

Basic Mapping

This feature allows you to apply a function to each element in an array and create a new array with the results. In this example, each number in the array is multiplied by 2.

const _ = require('lodash.map');
const array = [1, 2, 3, 4];
const result = _.map(array, function(n) { return n * 2; });
console.log(result); // [2, 4, 6, 8]

Mapping with Objects

This feature allows you to map over the values of an object and create a new array with the results. In this example, the ages of the users are extracted into a new array.

const _ = require('lodash.map');
const users = { 'fred': { 'user': 'fred', 'age': 40 }, 'pebbles': { 'user': 'pebbles', 'age': 1 } };
const result = _.map(users, function(user) { return user.age; });
console.log(result); // [40, 1]

Mapping with Index

This feature allows you to use the index of each element in the array during the mapping process. In this example, each number is multiplied by its index.

const _ = require('lodash.map');
const array = [1, 2, 3, 4];
const result = _.map(array, function(n, index) { return n * index; });
console.log(result); // [0, 2, 6, 12]

Other packages similar to lodash.map

Keywords

FAQs

Package last updated on 26 Jan 2015

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