File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ yarn add populate-array
1111```
1212
1313## Import
14+
1415``` javascript
1516// ES6:
1617import {populateArray } from ' populate-array' ;
@@ -44,39 +45,38 @@ for (const user of users) {
4445populateArray (users , ' country' , {
4546 each: getCountryFn
4647});
47-
4848// Result:
49- // @formatter:off
49+
5050[
51- {
52- id: 1 ,
53- name: ' John Doe' ,
54- country: {
55- name: ' United States' ,
56- iso2: ' US'
51+ {
52+ id: 1 ,
53+ name: ' John Doe' ,
54+ country: {
55+ name: ' United States' ,
56+ iso2: ' US'
57+ }
5758 }
58- }
59- // ... and so on
59+ // ... and so on
6060]
61- // @formatter:on
6261```
6362
6463## Arguments
64+
6565The populateArray function takes three arguments:
6666
6767- ` array ` : The array of objects to populate.
6868- ` path ` : The path of the objects to populate.
6969- ` options ` : The options object.
7070
7171** Path Note:**
72- This package makes use of ` lodash.get ` to get the value of a key in an object and ` lodash.set ` to set the value of a key in an object.
72+ This package makes use of ` lodash.get ` to get the value of a key in an object and ` lodash.set ` to set the value of a key
73+ in an object.
7374So nested keys are supported. e.g. ` user.address.city ` using dot notation.
7475
7576## Just that?
7677
7778No!! ☺️ There's more to the ` populateArray ` function, and they are packed in its options.
7879
79-
8080## Options
8181
8282- [ as] ( #as )
You can’t perform that action at this time.
0 commit comments