@@ -16,47 +16,41 @@ console.log(JSON.stringify(basicMap, null, 2));
1616// Map with custom key tokens and values
1717console . log ( '\n2. Map with custom user IDs and profile data:' ) ;
1818const userMap = TemplateJson . gen ( [
19- 'map' ,
20- [ 'list' , 'user_' , [ 'pick' , '001' , '002' , '003' , '004' , '005' ] ] ,
21- [
22- 'obj' ,
23- [
24- [ 'name' , [ 'str' , [ 'list' , [ 'pick' , 'John' , 'Jane' , 'Bob' , 'Alice' ] , ' ' , [ 'pick' , 'Doe' , 'Smith' , 'Johnson' ] ] ] ] ,
25- [ 'age' , [ 'int' , 18 , 65 ] ] ,
26- [ 'active' , 'bool' ] ,
27- ] ,
28- ] ,
29- 2 ,
30- 4 ,
19+ 'map' ,
20+ [ 'list' , 'user_' , [ 'pick' , '001' , '002' , '003' , '004' , '005' ] ] ,
21+ [
22+ 'obj' ,
23+ [
24+ [ 'name' , [ 'str' , [ 'list' , [ 'pick' , 'John' , 'Jane' , 'Bob' , 'Alice' ] , ' ' , [ 'pick' , 'Doe' , 'Smith' , 'Johnson' ] ] ] ] ,
25+ [ 'age' , [ 'int' , 18 , 65 ] ] ,
26+ [ 'active' , 'bool' ] ,
27+ ] ,
28+ ] ,
29+ 2 ,
30+ 4 ,
3131] ) ;
3232console . log ( JSON . stringify ( userMap , null , 2 ) ) ;
3333
3434// Map with complex nested structures
3535console . log ( '\n3. Map with API endpoints and their configurations:' ) ;
3636const apiMap = TemplateJson . gen ( [
37- 'map' ,
38- [ 'list' , 'api/' , [ 'pick' , 'users' , 'posts' , 'comments' , 'auth' ] ] ,
39- [
40- 'obj' ,
41- [
42- [ 'method' , [ 'str' , [ 'pick' , 'GET' , 'POST' , 'PUT' , 'DELETE' ] ] ] ,
43- [ 'timeout' , [ 'int' , 1000 , 5000 ] ] ,
44- [ 'retries' , [ 'int' , 0 , 3 ] ] ,
45- [ 'auth_required' , 'bool' ] ,
46- ] ,
47- ] ,
48- 3 ,
49- 3 ,
37+ 'map' ,
38+ [ 'list' , 'api/' , [ 'pick' , 'users' , 'posts' , 'comments' , 'auth' ] ] ,
39+ [
40+ 'obj' ,
41+ [
42+ [ 'method' , [ 'str' , [ 'pick' , 'GET' , 'POST' , 'PUT' , 'DELETE' ] ] ] ,
43+ [ 'timeout' , [ 'int' , 1000 , 5000 ] ] ,
44+ [ 'retries' , [ 'int' , 0 , 3 ] ] ,
45+ [ 'auth_required' , 'bool' ] ,
46+ ] ,
47+ ] ,
48+ 3 ,
49+ 3 ,
5050] ) ;
5151console . log ( JSON . stringify ( apiMap , null , 2 ) ) ;
5252
5353// Map with guaranteed size
5454console . log ( '\n4. Map with exactly 2 entries:' ) ;
55- const fixedMap = TemplateJson . gen ( [
56- 'map' ,
57- [ 'pick' , 'key1' , 'key2' , 'key3' ] ,
58- [ 'or' , 'str' , 'int' , 'bool' ] ,
59- 2 ,
60- 2 ,
61- ] ) ;
55+ const fixedMap = TemplateJson . gen ( [ 'map' , [ 'pick' , 'key1' , 'key2' , 'key3' ] , [ 'or' , 'str' , 'int' , 'bool' ] , 2 , 2 ] ) ;
6256console . log ( JSON . stringify ( fixedMap , null , 2 ) ) ;
0 commit comments