Acme.BookStore.HttpApi.Host/node_modules/collection-map/README.md
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
# collection-map [](https://www.npmjs.com/package/collection-map) [](https://npmjs.org/package/collection-map) [](https://npmjs.org/package/collection-map) [](https://travis-ci.org/jonschlinkert/collection-map)
> Returns an array of mapped values from an array or object.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save collection-map
```
Inspired by the [collections/map](http://moutjs.com/) util in mout.
## Usage
```js
var map = require('collection-map');
```
### objects
```js
var res = map({a: 'foo', b: 'bar', c: 'baz'}, function(item, key, obj) {
return item;
});
console.log(res);
// => ['foo', 'bar', 'baz']
var res = map({a: 'foo', b: 'bar', c: 'baz'}, function(item, key, obj) {
return key;
});
console.log(res);
// => ['a', 'b', 'c']
```
### arrays
```js
var res = map(['foo', 'bar', 'baz'], function(item, index, array) {
return item;
});
console.log(res);
// => ['foo', 'bar', 'baz']
var res = map(['foo', 'bar', 'baz'], function(item, index, array) {
return index;
});
console.log(res);
// => [0, 1, 2]
```
### strings
A string may be passed as the second argument, for getting properties:
```js
var obj = {
a: {aaa: 'one', bbb: 'four', ccc: 'seven'},
b: {aaa: 'two', bbb: 'five', ccc: 'eight'},
后面还有 73 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
