1- var framework = require ( '../index' ) ;
1+ var cube = x => x * x * x ;
22
3- var q = SCHEMA ( 'test' ) . create ( 'q' ) ;
4- var x = SCHEMA ( 'test' ) . create ( 'x' ) ;
5- var w = SCHEMA ( 'test' ) . create ( 'w' ) ;
6-
7- w . define ( 'firstname' , 'String(10)' ) ;
8-
9- q . define ( 'name' , 'string(5)' , true ) ;
10- q . define ( 'arr' , '[x]' , true ) ;
11- q . define ( 'dep' , w , true ) ;
12- x . define ( 'age' , Number , false ) ;
13- x . define ( 'note' , String , false ) ;
14-
15- q . setValidation ( function ( name , value , index ) {
16- // console.log('–––> q', name, value);
17- } ) ;
18-
19- x . setValidation ( function ( name , value ) {
20- // console.log('–––> x', name, value);
21- } ) ;
22-
23- var qi = { } ;
24- qi . dep = { } ;
25- qi . arr = [ { age : 300 , note : 'FET' } ] ;
26- qi . dep . lastname = 'Sirka' ;
27- qi . dep . firstname = 'Peter' ;
28- qi . name = 'ASDASKDSADSALDKASLDJLSJ' ;
29-
30- console . log ( q . prepare ( qi ) ) ;
31-
32- /*
33- var xi = x.create();
34- xi.age = 30;
35- xi.note = 'Peter';
36- qi.arr.push(xi);
37-
38- xi = x.create();
39- xi.age = 23;
40- xi.note = 'Jano';
41- qi.arr.push(xi);
42- */
43- //qi.$validate();
44-
45- Array . prototype . compare = function ( id , arr , keys , callback ) {
46-
47- var self = this ;
48- var cache = { } ;
49-
50- for ( var i = 0 , length = arr . length ; i < length ; i ++ ) {
51- var key = arr [ i ] [ id ] ;
52- if ( key === undefined )
53- continue ;
54- cache [ key ] = i ;
55- }
56-
57- var kl = keys . length ;
58-
59- for ( var i = 0 , length = self . length ; i < length ; i ++ ) {
60- var a = self [ i ] ;
61- var key = a [ id ] ;
62-
63- if ( ! key )
64- continue ;
65-
66- var index = cache [ key ] ;
67-
68- if ( index === undefined ) {
69- callback ( 0 , item ) ;
70- continue ;
71- }
72-
73- var b = arr [ index ] ;
74-
75- for ( var j = 0 ; j < kl ; j ++ ) {
76-
77- var k = keys [ j ] ;
78- var av = a [ k ] ;
79- var bv = b [ k ] ;
80-
81- if ( av === bv )
82- continue ;
83-
84-
85- }
86-
87- }
88- } ;
89-
90- var arr1 = [ { id : 1 , name : 'Peter' , age : 25 } , { id : 2 , name : 'Lucia' , age : 19 } , { id : 3 , name : 'Jozef' , age : 33 } ] ;
91- var arr2 = [ { id : 2 , name : 'Lucka' , age : 5 } , { id : 3 , name : 'Peter' , age : 50 } , { id : 1 , name : 'Peter' , age : 20 } , { id : 5 , name : 'New' , age : 33 } ] ;
92-
93- arr1 . compare ( 'id' , arr2 , [ 'name' , 'age' ] , function ( type , item ) {
94- console . log ( type , item ) ;
95- } ) ;
3+ console . log ( cube ( 23 ) ) ;
0 commit comments