Merge pull request #138 from calibr/yjs
updating YArray's iterator to iterate Types correctly
This commit is contained in:
		
						commit
						74e5243742
					
				@ -209,6 +209,22 @@ test('event target is set correctly (remote user)', async function array12 (t) {
 | 
			
		||||
  await compareUsers(t, users)
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
test('should correctly iterate an array containing types', async function iterate1 (t) {
 | 
			
		||||
  const y = new Y.Y()
 | 
			
		||||
  const arr = y.define('arr', Y.Array)
 | 
			
		||||
  const numItems = 10
 | 
			
		||||
  for(let i = 0; i < numItems; i++) {
 | 
			
		||||
    const map = new Y.Map()
 | 
			
		||||
    map.set('value', i)
 | 
			
		||||
    arr.push([map])
 | 
			
		||||
  }
 | 
			
		||||
  let cnt = 0
 | 
			
		||||
  for(let item of arr) {
 | 
			
		||||
    t.assert(item.get('value') === cnt++, 'value is correct')
 | 
			
		||||
  }
 | 
			
		||||
  y.destroy()
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
var _uniqueNumber = 0
 | 
			
		||||
function getUniqueNumber () {
 | 
			
		||||
  return _uniqueNumber++
 | 
			
		||||
 | 
			
		||||
@ -189,6 +189,7 @@ export class YArray extends Type {
 | 
			
		||||
        let content
 | 
			
		||||
        if (this._item instanceof Type) {
 | 
			
		||||
          content = this._item
 | 
			
		||||
          this._item = this._item._right
 | 
			
		||||
        } else {
 | 
			
		||||
          content = this._item._content[this._itemElement++]
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user