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 - npm Package Compare versions

Comparing version 2.4.1 to 3.0.0

100

index.js
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize modern exports="npm" -o ./npm/`
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
* lodash 3.0.0 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var createCallback = require('lodash.createcallback'),
forOwn = require('lodash.forown');
var arrayMap = require('lodash._arraymap'),
baseCallback = require('lodash._basecallback'),
baseEach = require('lodash._baseeach'),
isArray = require('lodash.isarray');
/**
* Creates an array of values by running each element in the collection
* through the callback. The callback is bound to `thisArg` and invoked with
* three arguments; (value, index|key, collection).
* The base implementation of `_.map` without support for callback shorthands
* or `this` binding.
*
* If a property name is provided for `callback` the created "_.pluck" style
* callback will return the property value of the given element.
* @private
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function baseMap(collection, iteratee) {
var result = [];
baseEach(collection, function(value, key, collection) {
result.push(iteratee(value, key, collection));
});
return result;
}
/**
* Creates an array of values by running each element in `collection` through
* `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
* arguments; (value, index|key, collection).
*
* If an object is provided for `callback` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
* If a property name is provided for `predicate` the created "_.property"
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
* @static
* @memberOf _
* @alias collect
* @category Collections
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [callback=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback, respectively.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {Array} Returns a new array of the results of each `callback` execution.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Array} Returns the new mapped array.
* @example
*
* _.map([1, 2, 3], function(num) { return num * 3; });
* _.map([1, 2, 3], function(n) { return n * 3; });
* // => [3, 6, 9]
*
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
* // => [3, 6, 9] (property order is not guaranteed across environments)
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; });
* // => [3, 6, 9] (iteration order is not guaranteed)
*
* var characters = [
* { 'name': 'barney', 'age': 36 },
* { 'name': 'fred', 'age': 40 }
* var users = [
* { 'user': 'barney' },
* { 'user': 'fred' }
* ];
*
* // using "_.pluck" callback shorthand
* _.map(characters, 'name');
* // using the "_.property" callback shorthand
* _.map(users, 'user');
* // => ['barney', 'fred']
*/
function map(collection, callback, thisArg) {
var index = -1,
length = collection ? collection.length : 0;
callback = createCallback(callback, thisArg, 3);
if (typeof length == 'number') {
var result = Array(length);
while (++index < length) {
result[index] = callback(collection[index], index, collection);
}
} else {
result = [];
forOwn(collection, function(value, key, collection) {
result[++index] = callback(value, key, collection);
});
}
return result;
function map(collection, iteratee, thisArg) {
var func = isArray(collection) ? arrayMap : baseMap;
iteratee = baseCallback(iteratee, thisArg, 3);
return func(collection, iteratee);
}
module.exports = map;

@@ -1,3 +0,3 @@

Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas,
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>

@@ -22,2 +22,2 @@

OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "lodash.map",
"version": "2.4.1",
"description": "The Lo-Dash function `_.map` as a Node.js module generated by lodash-cli.",
"homepage": "http://lodash.com/custom-builds",
"version": "3.0.0",
"description": "The modern build of lodash’s `_.map` as a module.",
"homepage": "https://lodash.com/",
"icon": "https://lodash.com/icon.svg",
"license": "MIT",
"keywords": ["functional", "lodash", "lodash-modularized", "server", "util"],
"keywords": "lodash, lodash-modularized, stdlib, util",
"author": "John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
"contributors": [
"John-David Dalton <john.david.dalton@gmail.com> (http://allyoucanleet.com/)",
"Benjamin Tan <demoneaux@gmail.com> (https://d10.github.io/)",
"Blaine Bublitz <blaine@iceddev.com> (http://www.iceddev.com/)",
"Kit Cambridge <github@kitcambridge.be> (http://kitcambridge.be/)",
"Mathias Bynens <mathias@qiwi.be> (http://mathiasbynens.be/)"
"Mathias Bynens <mathias@qiwi.be> (https://mathiasbynens.be/)"
],
"bugs": "https://github.com/lodash/lodash-cli/issues",
"repository": { "type": "git", "url": "https://github.com/lodash/lodash-cli.git" },
"repository": "lodash/lodash",
"scripts": { "test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\"" },
"dependencies": {
"lodash.createcallback": "~2.4.1",
"lodash.forown": "~2.4.1"
"lodash._arraymap": "^3.0.0",
"lodash._basecallback": "^3.0.0",
"lodash._baseeach": "^3.0.0",
"lodash.isarray": "^3.0.0"
}
}

@@ -1,15 +0,20 @@

# lodash.map v2.4.1
# lodash.map v3.0.0
The [Lo-Dash](http://lodash.com/) function [`_.map`](http://lodash.com/docs#map) as a [Node.js](http://nodejs.org/) module generated by [lodash-cli](https://npmjs.org/package/lodash-cli).
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.map` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.
## Author
## Installation
| [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") |
|---|
| [John-David Dalton](http://allyoucanleet.com/) |
Using npm:
## Contributors
```bash
$ {sudo -H} npm i -g npm
$ npm i --save lodash.map
```
| [![twitter/blainebublitz](http://gravatar.com/avatar/ac1c67fd906c9fecd823ce302283b4c1?s=70)](https://twitter.com/blainebublitz "Follow @BlaineBublitz on Twitter") | [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|---|---|
| [Blaine Bublitz](http://www.iceddev.com/) | [Kit Cambridge](http://kitcambridge.be/) | [Mathias Bynens](http://mathiasbynens.be/) |
In Node.js/io.js:
```js
var map = require('lodash.map');
```
See the [documentation](https://lodash.com/docs#map) or [package source](https://github.com/lodash/lodash/blob/3.0.0-npm-packages/lodash.map) for more details.
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