1-
21## Config
32
43#### ` .include: ChangeType | ChangeType[] `
54
6- || |
7- | - | - |
5+ | | |
6+ | --------------- | ------------------------------------------------------------------------------------- |
87| ** Description** | Include only these change types from the diff result. Can be combined with ` exclude ` . |
9- | ** Default** | ` [ChangeType.NOOP, ChangeType.ADD, ChangeType.UPDATE, ChangeType.REMOVE] ` |
8+ | ** Default** | ` [ChangeType.NOOP, ChangeType.ADD, ChangeType.UPDATE, ChangeType.REMOVE] ` |
109
1110``` javascript
1211diff (a, b, { include: [ChangeType .ADD ] }); // only additions
@@ -19,10 +18,11 @@ diff(a, b, {
1918---
2019
2120#### ` .exclude: ChangeType | ChangeType[] `
22- |||
23- | -| -|
21+
22+ | | |
23+ | --------------- | ------------------------------------------------------------------------------- |
2424| ** Description** | Excludes the change types from the diff result. Can be combined with ` include ` . |
25- | ** Default** | ` [] ` |
25+ | ** Default** | ` [] ` |
2626
2727``` javascript
2828diff (a, b, { exclude: ChangeType .NOOP });
@@ -34,10 +34,10 @@ diff(a, b, { exclude: [ChangeType.ADD, ChangeType.NOOP] });
3434
3535#### ` .strict: boolean `
3636
37- || |
38- | - | - |
37+ | | |
38+ | --------------- | -------------------------------------- |
3939| ** Description** | Performs loose type check if disabled. |
40- | ** Default** | ` true ` |
40+ | ** Default** | ` true ` |
4141
4242``` javascript
4343const a = { foo: 1 };
@@ -52,10 +52,10 @@ console.log(diff(a, b, { strict: false }).equal); // true
5252
5353#### ` .showUpdatedOnly: boolean `
5454
55- || |
56- | - | - |
55+ | | |
56+ | --------------- | ----------------------------------------------------------------------------------------------------------------------- |
5757| ** Description** | ` @sandboxed/diff ` creates a ` ChangeType.REMOVE ` entry for every ` ChangeType.UPDATE ` . This flags prevents this behavior. |
58- | ** Default** | ` false ` |
58+ | ** Default** | ` false ` |
5959
6060``` javascript
6161const a = { foo: ' baz' };
@@ -65,27 +65,28 @@ console.log(diff(a, b, { showUpdatedOnly: true }));
6565```
6666
6767** Output** :
68+
6869``` javascript
6970[
7071 { type: ' noop' , str: ' {' , depth: 0 , path: [] },
7172 {
7273 type: ' update' ,
7374 str: ' "foo": "bar",' ,
7475 depth: 1 ,
75- path: [ ' foo' , { deleted: false , value: ' bar' } ]
76+ path: [' foo' , { deleted: false , value: ' bar' }],
7677 },
77- { type: ' noop' , str: ' }' , depth: 0 , path: [] }
78- ]
78+ { type: ' noop' , str: ' }' , depth: 0 , path: [] },
79+ ];
7980```
8081
8182---
8283
8384#### ` .pathHints: PatHints `
8485
85- || |
86- | - | - |
86+ | | |
87+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------- |
8788| ** Description** | Hashmap of ` map ` and ` set ` path hints. These strings will be used in the ` path ` array to provide a hit about the object's type. |
88- | ** Default** | ` { map: '__MAP__', set: '__SET__' } ` |
89+ | ** Default** | ` { map: '__MAP__', set: '__SET__' } ` |
8990
9091⚠️ Warning: ** Complex keys are not recursively diffed** , they are treated as references only.
9192** Assume that any string entry in the path array comes from plain objects, and numeric entries come from arrays** . Without these hints, tracking back to the origin can be difficult, though can be disabled if not needed.
@@ -104,10 +105,10 @@ console.log(result[1].path); // ['__MAP__', 'foo', { deleted: false, value: 'bar
104105
105106#### ` .redactKeys: Array<string> `
106107
107- || |
108- | - | - |
109- | ** Description** | List of keys that should be redacted from the output. Works with ` string ` based keys and serialized ` Symbol ` .|
110- | ** Default** | ` [ 'password', 'secret', 'token', 'Symbol(password)', 'Symbol (secret)', 'Symbol(token)' ] ` |
108+ | | |
109+ | --------------- | ------------------------------------------------------------------------------------------------------------- |
110+ | ** Description** | List of keys that should be redacted from the output. Works with ` string ` based keys and serialized ` Symbol ` . |
111+ | ** Default** | ` [ 'password', 'secret', 'token', 'Symbol(password)', 'Symbol (secret)', 'Symbol(token)' ] ` |
111112
112113⚠️ Warning: Only the result ` str ` is redacted, the ` path ` array still contains the reference to the actual values. Be careful when using this for logging.
113114
@@ -119,47 +120,48 @@ console.log(diff(a, b, { showUpdatedOnly: true }));
119120```
120121
121122** Output** :
123+
122124``` javascript
123125[
124126 { type: ' noop' , str: ' {' , depth: 0 , path: [] },
125127 {
126128 type: ' update' ,
127129 str: ' "password": "*****",' ,
128130 depth: 1 ,
129- path: [ ' password' , { deleted: false , value: ' secret' } ]
131+ path: [' password' , { deleted: false , value: ' secret' }],
130132 },
131- { type: ' noop' , str: ' }' , depth: 0 , path: [] }
132- ]
133+ { type: ' noop' , str: ' }' , depth: 0 , path: [] },
134+ ];
133135```
134136
135137---
136138
137139#### ` .maxDepth: number `
138140
139- || |
140- | - | - |
141+ | | |
142+ | --------------- | ------------------------------------------------------------------------------- |
141143| ** Description** | Max depth that the diffing function can traverse. Throws when reaching the max. |
142- | ** Default** | ` 50 ` |
143- | ** Throws** | ` Max depth exceeded! ` |
144+ | ** Default** | ` 50 ` |
145+ | ** Throws** | ` Max depth exceeded! ` |
144146
145147---
146148
147149#### ` .maxKeys: number `
148150
149- || |
150- | - | - |
151+ | | |
152+ | --------------- | ------------------------------------------------------------------------- |
151153| ** Description** | Max keys the diffing function can traverse. Throws when reaching the max. |
152- | ** Default** | ` 50 ` |
153- | ** Throws** | ` Object is too big to continue! Aborting. ` |
154+ | ** Default** | ` 50 ` |
155+ | ** Throws** | ` Object is too big to continue! Aborting. ` |
154156
155157---
156158
157159#### ` .timeout: number `
158160
159- || |
160- | - | - |
161+ | | |
162+ | --------------- | --------------------------------------------- |
161163| ** Description** | Milliseconds before throwing a timeout error. |
162- | ** Default** | ` 1000 ` |
163- | ** Throws** | ` Diff took too much time! Aborting. ` |
164+ | ** Default** | ` 1000 ` |
165+ | ** Throws** | ` Diff took too much time! Aborting. ` |
164166
165167⚠️ Warning: The diffing function does not check for object size in memory. The process can still hang if the system is unable to handle the object in memory.
0 commit comments