forked from wI2L/jsondiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
31 lines (26 loc) · 1006 Bytes
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package jsondiff
// An Option changes the default behavior of a Differ.
type Option func(*Differ)
// Factorize enables factorization of operations.
func Factorize() Option {
return func(o *Differ) { o.opts.factorize = true }
}
// Rationalize enables rationalization of operations.
func Rationalize() Option {
return func(o *Differ) { o.opts.rationalize = true }
}
// Equivalent disables the generation of operations for
// arrays of equal length and content that are not ordered.
func Equivalent() Option {
return func(o *Differ) { o.opts.equivalent = true }
}
// Invertible enables the generation of an invertible
// patch, by preceding each remove and replace operation
// by a test operation that verifies the value at the
// path that is being removed/replaced.
// Note that copy operations are not invertible, and as
// such, using this option disable the usage of copy
// operation in favor of add operations.
func Invertible() Option {
return func(o *Differ) { o.opts.invertible = true }
}