fix #485 - forEach index

This commit is contained in:
Kevin Jahns
2023-06-27 12:21:40 +02:00
parent 3c98d97369
commit 7ced59c847
2 changed files with 18 additions and 2 deletions

View File

@@ -5,6 +5,21 @@ import * as t from 'lib0/testing'
import * as prng from 'lib0/prng'
import * as math from 'lib0/math'
/**
* foreach has correct index - see yjs#485
*
* @param {t.TestCase} tc
*/
export const testArrayIndexIssue485 = tc => {
const doc = new Y.Doc()
const yarr = doc.getArray()
yarr.push([1, 2])
yarr.forEach((el, index) => {
t.info('index: ' + index)
t.assert(yarr.get(index) === el)
})
}
/**
* @param {t.TestCase} tc
*/