@@ -21,81 +21,72 @@ describe('easysync-assembler', function () {
21
21
22
22
it ( 'smartOpAssembler ignore additional pure keeps (no attributes)' , async function ( ) {
23
23
const x = '-c*3*4+6|1+1=5' ;
24
- const iter = Changeset . opIterator ( x ) ;
25
24
const assem = Changeset . smartOpAssembler ( ) ;
26
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
25
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
27
26
assem . endDocument ( ) ;
28
27
expect ( assem . toString ( ) ) . to . equal ( '-c*3*4+6|1+1' ) ;
29
28
} ) ;
30
29
31
30
it ( 'smartOpAssembler merge consecutive + ops without multiline' , async function ( ) {
32
31
const x = '-c*3*4+6*3*4+1*3*4+9=5' ;
33
- const iter = Changeset . opIterator ( x ) ;
34
32
const assem = Changeset . smartOpAssembler ( ) ;
35
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
33
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
36
34
assem . endDocument ( ) ;
37
35
expect ( assem . toString ( ) ) . to . equal ( '-c*3*4+g' ) ;
38
36
} ) ;
39
37
40
38
it ( 'smartOpAssembler merge consecutive + ops with multiline' , async function ( ) {
41
39
const x = '-c*3*4+6*3*4|1+1*3*4|9+f*3*4+k=5' ;
42
- const iter = Changeset . opIterator ( x ) ;
43
40
const assem = Changeset . smartOpAssembler ( ) ;
44
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
41
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
45
42
assem . endDocument ( ) ;
46
43
expect ( assem . toString ( ) ) . to . equal ( '-c*3*4|a+m*3*4+k' ) ;
47
44
} ) ;
48
45
49
46
it ( 'smartOpAssembler merge consecutive - ops without multiline' , async function ( ) {
50
47
const x = '-c-6-1-9=5' ;
51
- const iter = Changeset . opIterator ( x ) ;
52
48
const assem = Changeset . smartOpAssembler ( ) ;
53
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
49
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
54
50
assem . endDocument ( ) ;
55
51
expect ( assem . toString ( ) ) . to . equal ( '-s' ) ;
56
52
} ) ;
57
53
58
54
it ( 'smartOpAssembler merge consecutive - ops with multiline' , async function ( ) {
59
55
const x = '-c-6|1-1|9-f-k=5' ;
60
- const iter = Changeset . opIterator ( x ) ;
61
56
const assem = Changeset . smartOpAssembler ( ) ;
62
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
57
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
63
58
assem . endDocument ( ) ;
64
59
expect ( assem . toString ( ) ) . to . equal ( '|a-y-k' ) ;
65
60
} ) ;
66
61
67
62
it ( 'smartOpAssembler merge consecutive = ops without multiline' , async function ( ) {
68
63
const x = '-c*3*4=6*2*4=1*3*4=f*3*4=2*3*4=a=k=5' ;
69
- const iter = Changeset . opIterator ( x ) ;
70
64
const assem = Changeset . smartOpAssembler ( ) ;
71
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
65
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
72
66
assem . endDocument ( ) ;
73
67
expect ( assem . toString ( ) ) . to . equal ( '-c*3*4=6*2*4=1*3*4=r' ) ;
74
68
} ) ;
75
69
76
70
it ( 'smartOpAssembler merge consecutive = ops with multiline' , async function ( ) {
77
71
const x = '-c*3*4=6*2*4|1=1*3*4|9=f*3*4|2=2*3*4=a*3*4=1=k=5' ;
78
- const iter = Changeset . opIterator ( x ) ;
79
72
const assem = Changeset . smartOpAssembler ( ) ;
80
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
73
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
81
74
assem . endDocument ( ) ;
82
75
expect ( assem . toString ( ) ) . to . equal ( '-c*3*4=6*2*4|1=1*3*4|b=h*3*4=b' ) ;
83
76
} ) ;
84
77
85
78
it ( 'smartOpAssembler ignore + ops with ops.chars === 0' , async function ( ) {
86
79
const x = '-c*3*4+6*3*4+0*3*4+1+0*3*4+1' ;
87
- const iter = Changeset . opIterator ( x ) ;
88
80
const assem = Changeset . smartOpAssembler ( ) ;
89
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
81
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
90
82
assem . endDocument ( ) ;
91
83
expect ( assem . toString ( ) ) . to . equal ( '-c*3*4+8' ) ;
92
84
} ) ;
93
85
94
86
it ( 'smartOpAssembler ignore - ops with ops.chars === 0' , async function ( ) {
95
87
const x = '-c-6-0-1-0-1' ;
96
- const iter = Changeset . opIterator ( x ) ;
97
88
const assem = Changeset . smartOpAssembler ( ) ;
98
- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
89
+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
99
90
assem . endDocument ( ) ;
100
91
expect ( assem . toString ( ) ) . to . equal ( '-k' ) ;
101
92
} ) ;
@@ -136,7 +127,12 @@ describe('easysync-assembler', function () {
136
127
137
128
it ( 'smartOpAssembler clear should empty internal assemblers' , async function ( ) {
138
129
const x = '-c*3*4+6|3=az*asdf0*1*2*3+1=1-1+1*0+1=1-1+1|c=c-1' ;
139
- const iter = Changeset . opIterator ( x ) ;
130
+ const ops = Changeset . deserializeOps ( x ) ;
131
+ const iter = {
132
+ _n : ops . next ( ) ,
133
+ hasNext ( ) { return ! this . _n . done ; } ,
134
+ next ( ) { const v = this . _n . value ; this . _n = ops . next ( ) ; return v ; } ,
135
+ } ;
140
136
const assem = Changeset . smartOpAssembler ( ) ;
141
137
assem . append ( iter . next ( ) ) ;
142
138
assem . append ( iter . next ( ) ) ;
0 commit comments