This repository was archived by the owner on Feb 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-17
lines changed Expand file tree Collapse file tree 2 files changed +14
-17
lines changed Original file line number Diff line number Diff line change 11import isLogic from './isLogic' ;
22import getOperator from './getOperator' ;
33
4- function createJsonLogic ( ) {
5- const operations = { }
6- const visitors = { }
4+ function createJsonLogic ( operations = { } , visitors = { } ) {
5+ Object . keys ( operations ) . forEach ( function ( name ) {
6+ const operation = operations [ name ] ;
7+
8+ addOperation ( operation . code || name , operation ) ;
9+ } ) ;
10+
11+ Object . keys ( visitors ) . forEach ( function ( name ) {
12+ const visitor = visitors [ name ] ;
13+
14+ addVisitor ( visitor . code || name , visitor ) ;
15+ } ) ;
716
817 function addOperation ( name , code ) {
918 operations [ name ] = code ;
@@ -91,7 +100,7 @@ function createJsonLogic() {
91100 rm_operation : removeOperation ,
92101 add_visitor : addVisitor ,
93102 rm_visitor : removeVisitor ,
94- }
103+ } ;
95104}
96105
97106export default createJsonLogic ;
Original file line number Diff line number Diff line change @@ -8,19 +8,7 @@ import getValues from "./helpers/getValues";
88import usesData from "./helpers/usesData" ;
99import ruleLike from "./helpers/ruleLike" ;
1010
11- const jsonLogic = createJsonLogic ( ) ;
12-
13- Object . keys ( operations ) . forEach ( function ( name ) {
14- const operation = operations [ name ] ;
15-
16- jsonLogic . add_operation ( operation . code || name , operation ) ;
17- } ) ;
18-
19- Object . keys ( visitors ) . forEach ( function ( name ) {
20- const visitor = visitors [ name ] ;
21-
22- jsonLogic . add_visitor ( visitor . code || name , visitor ) ;
23- } ) ;
11+ const jsonLogic = createJsonLogic ( operations , visitors ) ;
2412
2513// restore original public API
2614jsonLogic . is_logic = isLogic ;
You can’t perform that action at this time.
0 commit comments