@@ -21,81 +21,72 @@ describe('easysync-assembler', function () {
2121
2222 it ( 'smartOpAssembler ignore additional pure keeps (no attributes)' , async function ( ) {
2323 const x = '-c*3*4+6|1+1=5' ;
24- const iter = Changeset . opIterator ( x ) ;
2524 const assem = Changeset . smartOpAssembler ( ) ;
26- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
25+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
2726 assem . endDocument ( ) ;
2827 expect ( assem . toString ( ) ) . to . equal ( '-c*3*4+6|1+1' ) ;
2928 } ) ;
3029
3130 it ( 'smartOpAssembler merge consecutive + ops without multiline' , async function ( ) {
3231 const x = '-c*3*4+6*3*4+1*3*4+9=5' ;
33- const iter = Changeset . opIterator ( x ) ;
3432 const assem = Changeset . smartOpAssembler ( ) ;
35- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
33+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
3634 assem . endDocument ( ) ;
3735 expect ( assem . toString ( ) ) . to . equal ( '-c*3*4+g' ) ;
3836 } ) ;
3937
4038 it ( 'smartOpAssembler merge consecutive + ops with multiline' , async function ( ) {
4139 const x = '-c*3*4+6*3*4|1+1*3*4|9+f*3*4+k=5' ;
42- const iter = Changeset . opIterator ( x ) ;
4340 const assem = Changeset . smartOpAssembler ( ) ;
44- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
41+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
4542 assem . endDocument ( ) ;
4643 expect ( assem . toString ( ) ) . to . equal ( '-c*3*4|a+m*3*4+k' ) ;
4744 } ) ;
4845
4946 it ( 'smartOpAssembler merge consecutive - ops without multiline' , async function ( ) {
5047 const x = '-c-6-1-9=5' ;
51- const iter = Changeset . opIterator ( x ) ;
5248 const assem = Changeset . smartOpAssembler ( ) ;
53- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
49+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
5450 assem . endDocument ( ) ;
5551 expect ( assem . toString ( ) ) . to . equal ( '-s' ) ;
5652 } ) ;
5753
5854 it ( 'smartOpAssembler merge consecutive - ops with multiline' , async function ( ) {
5955 const x = '-c-6|1-1|9-f-k=5' ;
60- const iter = Changeset . opIterator ( x ) ;
6156 const assem = Changeset . smartOpAssembler ( ) ;
62- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
57+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
6358 assem . endDocument ( ) ;
6459 expect ( assem . toString ( ) ) . to . equal ( '|a-y-k' ) ;
6560 } ) ;
6661
6762 it ( 'smartOpAssembler merge consecutive = ops without multiline' , async function ( ) {
6863 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 ) ;
7064 const assem = Changeset . smartOpAssembler ( ) ;
71- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
65+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
7266 assem . endDocument ( ) ;
7367 expect ( assem . toString ( ) ) . to . equal ( '-c*3*4=6*2*4=1*3*4=r' ) ;
7468 } ) ;
7569
7670 it ( 'smartOpAssembler merge consecutive = ops with multiline' , async function ( ) {
7771 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 ) ;
7972 const assem = Changeset . smartOpAssembler ( ) ;
80- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
73+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
8174 assem . endDocument ( ) ;
8275 expect ( assem . toString ( ) ) . to . equal ( '-c*3*4=6*2*4|1=1*3*4|b=h*3*4=b' ) ;
8376 } ) ;
8477
8578 it ( 'smartOpAssembler ignore + ops with ops.chars === 0' , async function ( ) {
8679 const x = '-c*3*4+6*3*4+0*3*4+1+0*3*4+1' ;
87- const iter = Changeset . opIterator ( x ) ;
8880 const assem = Changeset . smartOpAssembler ( ) ;
89- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
81+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
9082 assem . endDocument ( ) ;
9183 expect ( assem . toString ( ) ) . to . equal ( '-c*3*4+8' ) ;
9284 } ) ;
9385
9486 it ( 'smartOpAssembler ignore - ops with ops.chars === 0' , async function ( ) {
9587 const x = '-c-6-0-1-0-1' ;
96- const iter = Changeset . opIterator ( x ) ;
9788 const assem = Changeset . smartOpAssembler ( ) ;
98- while ( iter . hasNext ( ) ) assem . append ( iter . next ( ) ) ;
89+ for ( const op of Changeset . deserializeOps ( x ) ) assem . append ( op ) ;
9990 assem . endDocument ( ) ;
10091 expect ( assem . toString ( ) ) . to . equal ( '-k' ) ;
10192 } ) ;
@@ -136,7 +127,12 @@ describe('easysync-assembler', function () {
136127
137128 it ( 'smartOpAssembler clear should empty internal assemblers' , async function ( ) {
138129 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+ } ;
140136 const assem = Changeset . smartOpAssembler ( ) ;
141137 assem . append ( iter . next ( ) ) ;
142138 assem . append ( iter . next ( ) ) ;
0 commit comments