Skip to content

Commit 7332cad

Browse files
committed
Refactor docs
1 parent 560143c commit 7332cad

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

readme.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ yarn add populate-array
1111
```
1212

1313
## Import
14+
1415
```javascript
1516
// ES6:
1617
import {populateArray} from 'populate-array';
@@ -44,39 +45,38 @@ for (const user of users) {
4445
populateArray(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+
6565
The 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.
7374
So nested keys are supported. e.g. `user.address.city` using dot notation.
7475

7576
## Just that?
7677

7778
No!! ☺️ There's more to the `populateArray` function, and they are packed in its options.
7879

79-
8080
## Options
8181

8282
- [as](#as)

0 commit comments

Comments
 (0)