Skip to content

Commit 4dc060d

Browse files
committed
added README
1 parent 54558a0 commit 4dc060d

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
# pretify-deep-diff
3+
4+
A utility to prettify the results of `deep-diff` with emojis and localization support.
5+
6+
## Installation
7+
8+
To install the package, use npm:
9+
10+
```bash
11+
npm install pretify-deep-diff
12+
```
13+
14+
## Usage
15+
16+
Here's an example of how to use `pretify-deep-diff`:
17+
18+
```javascript
19+
const diff = require('deep-diff');
20+
const pretifyDeepDiff = require('pretify-deep-diff');
21+
22+
const lhs = {
23+
name: 'John',
24+
age: 30,
25+
pets: ['dog', 'cat'],
26+
address: {
27+
city: 'Chicago',
28+
street: 'Main St'
29+
}
30+
};
31+
32+
const rhs = {
33+
name: 'Jane',
34+
age: 31,
35+
pets: ['dog', 'parrot'],
36+
city: 'New York'
37+
};
38+
39+
const changes = diff(lhs, rhs);
40+
41+
console.log(pretifyDeepDiff(changes, { locale: 'ru' }));
42+
```
43+
44+
### Output
45+
46+
```text
47+
Добавлено:
48+
➕ Добавлено: city = "New York"
49+
50+
❌ Удалено:
51+
❌ Удалено: address
52+
53+
✏️ Изменено:
54+
✏️ Изменено: name с "John" на "Jane"
55+
✏️ Изменено: age с 30 на 31
56+
✏️ Изменено: pets.1 с "cat" на "parrot"
57+
```
58+
59+
## Options
60+
61+
- `locale`: Specify the locale (`en` or `ru`). Default is `en`.
62+
- `customTexts`: An object to customize text templates.
63+
64+
## Localization
65+
66+
The library supports localization through JSON files in the `locales` directory.

0 commit comments

Comments
 (0)