.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / map-obj / readme.md
1 # map-obj [![Build Status](https://travis-ci.org/sindresorhus/map-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/map-obj)
2
3 > Map object keys and values into a new object
4
5
6 ## Install
7
8 ```
9 $ npm install --save map-obj
10 ```
11
12
13 ## Usage
14
15 ```js
16 const mapObj = require('map-obj');
17
18 const newObject = mapObj({foo: 'bar'}, (key, value) => [value, key]);
19 //=> {bar: 'foo'}
20 ```
21
22
23 ## API
24
25 ### mapObj(source, mapper, [options])
26
27 #### source
28
29 Type: `Object`
30
31 Source object to copy properties from.
32
33 #### mapper
34
35 Type: `Function`
36
37 Mapping function.
38
39 - It has signature `mapper(sourceKey, sourceValue, source)`.
40 - It must return a two item array: `[targetKey, targetValue]`.
41
42 #### deep
43
44 Type: `boolean`<br>
45 Default: `false`
46
47 Recurse nested objects and objects in arrays.
48
49 #### target
50
51 Type: `Object`<br>
52 Default: `{}`
53
54 Target object to map properties on to.
55
56
57 ## Related
58
59 - [filter-obj](https://github.com/sindresorhus/filter-obj) - Filter object keys and values into a new object
60 - [object-assign](https://github.com/sindresorhus/object-assign) - Copy enumerable own properties from one or more source objects to a target object
61
62
63 ## License
64
65 MIT © [Sindre Sorhus](https://sindresorhus.com)