Skip to content

Commit d0d944d

Browse files
committed
(feat)Add method JSONLogic.Clone.
1 parent 36eb902 commit d0d944d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

jsonlogic.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,19 @@ func AddOperation(name string, op Operation) {
129129
func (jl *JSONLogic) AddOperation(name string, op Operation) {
130130
jl.ops[name] = op
131131
}
132+
133+
// Clone is equivalent to DefaultJSONLogic.Clone.
134+
func Clone() *JSONLogic {
135+
return DefaultJSONLogic.Clone()
136+
}
137+
138+
// Clone clones a JSONLogic instance.
139+
func (jl *JSONLogic) Clone() *JSONLogic {
140+
ret := &JSONLogic{
141+
ops: make(map[string]Operation),
142+
}
143+
for k, v := range jl.ops {
144+
ret.ops[k] = v
145+
}
146+
return ret
147+
}

0 commit comments

Comments
 (0)